Running notebooks remotely
Leveraging Jupyter notebooks with ZenML.
A Jupyter notebook is often the fastest way to prototype an ML experiment, but sooner or later you will want to execute heavy‑weight ZenML steps or pipelines on a remote stack. This tutorial shows how to
Understand the limitations of defining steps inside notebook cells;
Execute a single step remotely from a notebook; and
Promote your notebook code to a full pipeline that can run anywhere.
Why there are limitations
When you call a step or pipeline from a notebook, ZenML needs to export the cell code into a standalone Python module that gets packaged into a Docker image. Any magic commands, cross‑cell references or missing imports break that process. Keep your cells pure and self‑contained and you are good to go.
Checklist for step cells
Only regular Python code – no Jupyter magics (
%…
) or shell commands (!…
).Do not access variables or functions defined in other notebook cells. Import from
.py
files instead.Include all imports you need inside the cell (including
from zenml import step
).
Run a single step remotely
You can treat a ZenML @step
like a normal Python function call. ZenML will automatically create a temporary pipeline with just this one step and run it on your active stack.
Tip: If you prefer YAML, you can also pass a
config_path
when calling the step.
Next steps – from notebook to production
Once your logic stabilizes it usually makes sense to move code out of the notebook and into regular Python modules so that it can be version‑controlled and tested. At that point just assemble the same steps inside a @pipeline
function and trigger it from the CLI or a CI workflow.
Last updated
Was this helpful?