0Pricing
MLOps Academy · Lesson

Define a Pipeline with DVC Stages

Wire steps together in dvc.yaml with dependencies.

Define a Pipeline with DVC Stages is a free MLOps Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MLOps Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Meet dvc.yaml

DVC describes your whole pipeline in one file called dvc.yaml. It lists each stage, the command it runs, and what it depends on. 📄

Add a Stage with dvc stage add

You rarely hand-write the file. The dvc stage add command builds a stage entry for you from flags you pass on the command line.

dvc stage add -n prep \
  -d data/raw.parquet -o data/prepared \
  python prep.py

The -d Flag Means Dependency

The -d flag declares a dependency: a file or script the stage reads. DVC watches these to know when the stage needs to re-run.

The -o Flag Means Output

The -o flag declares an output the stage produces. DVC tracks these files so later stages can depend on them in turn.

Wiring Stages Together

You connect stages by making one stage's output the next stage's dependency. That shared file is the link that forms the pipeline graph.

What a Stage Looks Like in YAML

Each stage in dvc.yaml has a cmd plus its deps and outs. This is the readable record of how your model was built.

stages:
  prep:
    cmd: python prep.py
    deps:
      - data/raw.parquet
    outs:
      - data/prepared

Run the Pipeline with dvc repro

The dvc repro command executes the pipeline in dependency order, running each stage only if its inputs changed.

dvc repro

DVC Builds the DAG for You

From the deps and outs, DVC infers the full DAG automatically. You never specify run order by hand; the graph decides it.

Visualize It with dvc dag

Run dvc dag to print the pipeline as a graph in your terminal. It is a quick way to confirm stages are wired the way you expect.

dvc dag

dvc.lock Records What Ran

After a run, DVC writes dvc.lock with the exact hashes of every input and output. Commit it so teammates reproduce the same result.

The Pipeline Lives in Git

dvc.yaml and dvc.lock are plain text, so they live in Git alongside your code. Your whole pipeline becomes versioned and reviewable.

Quick Check

Test your grasp of DVC stage flags.

Recap: Pipelines in dvc.yaml

You wired stages with deps and outs in dvc.yaml, then ran the graph with dvc repro. DVC tracks order and results for you. 🔗

Frequently asked questions

Is the “Define a Pipeline with DVC Stages” lesson free?

Yes — the full text of “Define a Pipeline with DVC Stages” is free to read here on the web, and the MLOps Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MLOps Academy course, upgrade to CoddyKit PRO.

What will I learn in “Define a Pipeline with DVC Stages”?

Wire steps together in dvc.yaml with dependencies. You practise MLOps Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start MLOps Academy?

No prior experience is required. MLOps Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Define a Pipeline with DVC Stages” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this MLOps Academy lesson?

Yes. Every MLOps Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Stages: Ingest, Prep, Train, Eval
  2. Define a Pipeline with DVC Stages
  3. Cache and Skip Unchanged Steps
  4. Parameterize Runs with params.yaml
← Back to MLOps Academy