Converting Notebooks Skill
Transforms notebook experiments into production-ready, self-executing Python scripts.
Contents
- Examples
- Canonical output structure: PEP 723 header, constants, helper functions,
main().
- Canonical output structure: PEP 723 header, constants, helper functions,
Output Conventions
- Filename:
YYYYMMDD_<name>.py(today's date by default) - Saved outputs (images, CSVs):
YYYYMMDD_<name>.png/.csv - Output directory: same as script unless
--output-diris specified
Quick Checklist
# /// scriptblock first (before module docstring).- Dependencies: list third-party packages; omit stdlib; skip version if unknown.
- Module docstring: Google style, English; translate Japanese math comments.
- Constants section: all hardcoded literals in
UPPER_SNAKE_CASE. - Output helper
_out(name)→ prefixes every saved file withYYYYMMDD_. matplotlib.use("Agg")immediately afterimport matplotlib.- Every function/class: Google docstring + full type hints.
main() -> Nonereads as a high-level narrative; delegate logic to helpers.print()for result tables/metrics;logging.info()for pipeline progress.- Reproducibility: set
RANDOM_SEEDconstant; call seed functions at top ofmain().