ZenML Tutorial: Build Your First Production-Ready ML Pipeline in Minutes
A hands-on ZenML tutorial: install the CLI, define a pipeline with steps, run with automatic caching, and track artifacts in the dashboard.
In this tutorial you will build your first ZenML pipeline β from installing the CLI to running a reproducible ML workflow with caching and versioning. ZenML is a Python-native framework, so everything happens in a few lines of code.
π Want to deploy ZenML yourself?
Docker configs, system requirements, and installation guides β all on one page.
View ZenML Tool Page βStep 1: Install and Connect
Install ZenML with pip, then point the client at your self-hosted server (or use the local default).
pip install zenml zenml init zenml connect --url http://localhost:8080
Step 2: Define Your First Pipeline
A pipeline is just a Python function decorated with @pipeline. Each step gets its own decorator and runs in isolation:
from zenml import pipeline, step
@step
def load_data() -> dict:
return {"samples": 1000, "features": 8}
@step
def train_model(data: dict) -> str:
return f"trained on {data['samples']} samples"
@pipeline
def training_pipeline():
data = load_data()
train_model(data)
if __name__ == "__main__":
training_pipeline()
Step 3: Run It β Then Run It Again
Execute the script. The first run trains your model; the second run is cached β ZenML detects unchanged steps and skips them. This is where production MLOps starts: every run is versioned, every artifact is tracked, and nothing is silently lost.
βοΈ Pro tip: swap the local orchestrator for a Kubernetes or cloud stack and the exact same pipeline runs in production. No code changes needed.
Step 4: Visualize and Track
Open the ZenML dashboard to inspect pipeline runs, compare model versions, and browse artifacts. The dashboard is served by the ZenML server β the same container you deploy with docker-compose.
| Command | What It Does |
|---|---|
zenml pipeline run list | List all pipeline runs with status |
zenml model list | Show registered model versions |
zenml stack list | View and switch between stacks |
Next Steps: Add an Agent Workflow
Once your pipeline is solid, extend it to the agent era: add RAG retrieval steps, evaluate LLM responses, and orchestrate agent calls as first-class pipeline steps. ZenML gives you one framework for classical ML and LLMOps alike.
π Want to deploy ZenML yourself?
Docker configs, system requirements, and installation guides β all on one page.
View ZenML Tool Page β