0Pricing
MLOps Academy · 课时

使用 DVC 阶段定义流程

在 dvc.yaml 中通过依赖关系连接各个步骤

使用 DVC 阶段定义流程 是 CoddyKit 上的免费 MLOps Academy 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 MLOps Academy 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 MLOps Academy 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

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. 🔗

常见问题解答

「使用 DVC 阶段定义流程」课时是免费的吗?

是的 — 「使用 DVC 阶段定义流程」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 MLOps Academy 课程的其余内容,请升级到 CoddyKit PRO。 MLOps Academy 课程共包含 4 节课。

「使用 DVC 阶段定义流程」这节课中我会学到什么?

在 dvc.yaml 中通过依赖关系连接各个步骤 你通过在浏览器中直接运行的动手代码来练习 MLOps Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 MLOps Academy 需要有经验吗?

无需任何先前经验。CoddyKit 上的 MLOps Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。

「使用 DVC 阶段定义流程」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 MLOps Academy 课中编写并运行代码吗?

能。每节 MLOps Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 阶段:摄取、准备、训练、评估
  2. 使用 DVC 阶段定义流程
  3. 缓存并跳过未改变的步骤
  4. 使用 params.yaml 参数化运行
← 返回 MLOps Academy