Notebook to pipeline stage
notebook-to-pipeline-stage · v1.0.0
ivyx
Use when someone wants to turn an experiment notebook (.ipynb) into a pipeline step, a DVC stage or a reproducible script (notebook'u pipeline'a almak, betiğe çevirmek) so training runs outside the notebook; extracts the script and declares the stage.
Who is asked
Risk medium: you are asked when it loads, and that yes covers reading its files in the same chat.
Tools it may call
While this skill is active, a call to any other tool is refused. These still meet every policy rule; the list narrows, it approves nothing.
ipynbViewer.describeipynbViewer.toPipelineStagemlops.pipeline.describemlops.dvc.statusWhat it tells the agent
The published SKILL.md, as written.
--- name: notebook-to-pipeline-stage description: Use when someone wants to turn an experiment notebook (.ipynb) into a pipeline step, a DVC stage or a reproducible script (notebook'u pipeline'a almak, betiğe çevirmek) so training runs outside the notebook; extracts the script and declares the stage. allowed-tools: ipynbViewer.describe ipynbViewer.toPipelineStage mlops.pipeline.describe mlops.dvc.status metadata: risk: medium ---
From a notebook to a pipeline stage
The script and the stage are written by one capability from the notebook's
own cells. You do not write the .py file or edit dvc.yaml by hand, and
you do not run the stage: the person runs it when they are ready.
1. Read the notebook
ipynbViewer.describe with outputs: "text" and the notebook's path
exactly as the person wrote it, folder included (notebooks/train.ipynb,
never train.ipynb). If it answers No notebook at with the bare
file name, you dropped the folder: call it again with the full path. From
the code cells, write down:
- the files it reads (every path passed to a read call);
- the files it writes (models, metrics, figures);
- which written file holds metrics (a json with numbers);
- any cell that is exploration rather than the pipeline (a
head(), a plot, a magic line), to warn about.
2. Check the pipeline
mlops.pipeline.describe: which engine the project binds and the stages
it has. The stage name is the notebook's file stem (train_v2 for
notebooks/train_v2.ipynb) and the script is src/<stem>.py. If the
pipeline already has a stage of that name, or src/<stem>.py exists, stop
here and tell the person: replacing a stage or a script is their decision,
made in a later message. Never pass force.
3. Convert
ipynbViewer.toPipelineStage with:
path: the notebook, with its folder;name: the stem from step 2 (the person's name for it when they gave one);script:src/<name>.py, never the path of a script that exists;deps: the files from step 1 the notebook reads. Never put the notebook itself indeps: the engine would rerun the old script on every notebook edit and record it as reproduced;outs: the files it writes, except the metrics file;metrics: the metrics file.
Do not pass force. Read ok, script, stage, commented, notes and problem from the
answer. commented lists lines the extraction turned into comments (a
magic or a display call); report each one.
4. Confirm and report
mlops.dvc.status when the engine is DVC: the new stage shows as not yet
run. Say:
- the script path and the stage name;
- its dependencies, outputs and metrics, as declared;
- the lines that were commented out and whether any of them mattered;
- the one rule: edit the script from now on, or re-run this conversion after editing the notebook, because the notebook is not a dependency.
- Offer to run the pipeline; do not run it yourself.