Communitygithub.com

DVC(数据版本控制)

用于机器学习项目的数据版本控制。在 Git 旁跟踪大型数据集和模型,构建可复现的 ML 流水线,并通过指标比较运行实验。支持 S3、GCS、Azure 和本地文件系统等任意存储后端。

DVC(数据版本控制) 是什么?

DVC(数据版本控制)是一个将 Git 扩展到机器学习项目的开源工具,它允许开发者跟踪大型数据集、模型和 ML 流水线,同时保持 Git 工作流程的优势。该技能涵盖了 DVC 的安装、数据文件跟踪、远程存储配置、可复现流水线构建、实验跟踪以及指标与图表可视化。最显着的优势在于它能够处理大型二进制文件,这些文件通过存储为 Git 提交的轻量级 .dvc 指针文件进行管理,而实际内容则存储在 S3、GCS、Azure 或本地文件系统等远程存储中。用户可以通过 `dvc repro` 根据依赖关系变化选择性地重新运行流水线阶段,使用 `dvc exp run` 在无需分支的情况下运行实验,并使用 `dvc metrics show` 和 `dvc plots show` 比较指标与图表。DVC 提供了 Python 和 CLI 接口,用于数据访问和流水线定义,支持 AWS、GCP、Azure 等主要云计算平台,是现代 MLOps 工作流程中不可或缺的工具。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/dvc

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

DVC(数据版本控制) 是做什么的?

安装

# 安装 DVC 并支持云存储
pip install dvc[s3]    # 用于 AWS S3
pip install dvc[gs]    # 用于 Google Cloud Storage
pip install dvc[azure] # 用于 Azure Blob Storage
pip install dvc[all]   # 所有远程存储

# 在 Git 仓库中初始化 DVC
cd my-ml-project
git init
dvc init

跟踪数据文件

# track_data.sh — 将大文件添加到 DVC 跟踪而非 Git
# 添加大型数据集
dvc add data/training_images/
dvc add data/dataset.csv

# DVC 创建 .dvc 文件(小型指针)—— 将它们提交到 Git
git add data/training_images.dvc data/dataset.csv.dvc .gitignore
git commit -m "使用 DVC 跟踪训练数据"

配置远程存储

# setup_remote.sh — 配置 DVC 存储实际文件内容的位置
# S3
dvc remote add -d myremote s3://my-bucket/dvc-storage

# Google Cloud Storage
dvc remote add -d myremote gs://my-bucket/dvc-storage

# 本地/网络路径
dvc remote add -d myremote /mnt/shared/dvc-storage

# 将数据推送到远程存储
dvc push

# 从远程存储拉取数据(在另一台机器上或克隆后)
dvc pull

构建可复现的流水线

# dvc.yaml — 定义 ML 流水线阶段及其依赖项和输出
stages:
  prepare:
    cmd: python src/prepare.py
    deps:
      - src/prepare.py
      - data/raw/
    outs:
      - data/processed/

  train:
    cmd: python src/train.py
    deps:
      - src/train.py
      - data/processed/
    params:
      - train.epochs
      - train.learning_rate
      - train.batch_size
    outs:
      - models/model.pkl
    metrics:
      - metrics/train.json:
          cache: false

  evaluate:
    cmd: python src/evaluate.py
    deps:
      - src/evaluate.py
      - models/model.pkl
      - data/processed/
    metrics:
      - metrics/eval.json:
          cache: false
    plots:
      - metrics/confusion_matrix.csv:
          x: predicted
          y: actual
# params.yaml — 流水线参数(由 DVC 跟踪)
train:
  epochs: 50
  learning_rate: 0.001
  batch_size: 32
# 运行整个流水线(仅重新运行已更改的阶段)
dvc repro

# 运行特定阶段
dvc repro train

实验跟踪

# experiments.sh — 运行并比较 ML 实验
# 运行带有修改参数的实验
dvc exp run --set-param train.learning_rate=0.01

# 并行运行多个实验
dvc exp run --set-param train.learning_rate=0.001 --queue
dvc exp run --set-param train.learning_rate=0.01 --queue
dvc exp run --set-param train.learning_rate=0.1 --queue
dvc queue start --jobs 3

# 比较实验
dvc exp show
dvc exp diff

# 将成功的实验应用到工作区
dvc exp apply exp-abc123

# 将实验推送到 Git 分支
dvc exp push origin exp-abc123

指标与图表

# train.py — 输出 DVC 跟踪指标的训练脚本
import json
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, f1_score
import yaml
import pickle

# 加载参数
with open("params.yaml") as f:
    params = yaml.safe_load(f)["train"]

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

model = RandomForestClassifier(n_estimators=params["epochs"])
model.fit(X_train, y_train)

preds = model.predict(X_test)
metrics = {
    "accuracy": accuracy_score(y_test, preds),
    "f1_score": f1_score(y_test, preds, average="weighted"),
}

with open("metrics/train.json", "w") as f:
    json.dump(metrics, f, indent=2)

with open("models/model.pkl", "wb") as f:
    pickle.dump(model, f)
# 查看实验间的指标
dvc metrics show
dvc metrics diff

# 生成图表
dvc plots show metrics/confusion_matrix.csv
dvc plots diff  # 比较实验间的图表

无需克隆即可访问数据

# 从任何 DVC 仓库获取跟踪文件,无需完整克隆
dvc get https://github.com/org/ml-repo data/processed/dataset.csv
dvc import https://github.com/org/ml-repo models/model.pkl
# dvc_api.py — 以编程方式访问 DVC 跟踪的文件
import dvc.api

# 从 DVC 仓库读取文件
with dvc.api.open("data/dataset.csv", repo="https://github.com/org/ml-repo") as f:
    import pandas as pd
    df = pd.read_csv(f)

# 获取跟踪文件的 URL
url = dvc.api.get_url("models/model.pkl", repo="https://github.com/org/ml-repo")

关键概念

  • .dvc 文件:提交到 Git 的小型指针文件,引用远程存储中的大型数据
  • dvc repro:复现流水线——仅重新运行依赖项已更改的阶段
  • 实验:无分支的实验跟踪——运行、比较并应用结果
  • 参数:由 DVC 跟踪的 YAML 参数文件,用于可复现的配置
  • 指标:JSON/YAML 指标文件,带有内置的比较工具
  • 远程存储:S3、GCS、Azure、SSH、HDFS——数据保留在您希望的位置

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

TerminalSkills/skills

>- Lovable (formerly GPT Engineer) is a browser-based AI app builder that turns a natural-language description into a working full-stack web app with a built-in backend, authentication, database and one-click publishing. Use when the user wants to prototype or ship a web app with Lovable, write effective Lovable prompts, connect Supabase or GitHub, review generated security rules, or move a Lovable project into their own editor.

相关技能