python-api
Use DVC as a Python library for streaming reads, fsspec filesystem access, Repo automation, params/metrics/experiments inspection, and safe exception handling.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- python-api
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use DVC as a Python library for streaming reads, fsspec filesystem access, Repo automation, params/metrics/experiments inspection, and safe exception handling.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md8.5 KB
- 参考文档references/filesystem-access.md6.0 KB
- 参考文档references/troubleshooting.md5.5 KB
- 脚本scripts/dvc_api_smoke.py7.3 KB
03 SKILL.md 正文
DVC Python API
Use this sub-skill when an agent needs to call DVC from Python instead of shelling out to the dvc console script. It covers the supported dvc.api surface, DVCFileSystem/fsspec-style access, selected Repo methods for scripted automation, and common failure modes.
Start Here
- For one tracked file, prefer
dvc.api.open()when streaming anddvc.api.read()only when loading the full file is acceptable. - For directory listings, globs, recursive downloads, or path metadata, prefer
dvc.api.DVCFileSystemoverdvc.api.read(). - For pipeline mutation or automation, use
dvc.repo.Repoas a context manager and call public methods such asadd(),run(),reproduce(),status(),push(),pull(), anddiff(). - For params, metrics, artifacts, and experiments, use the public
dvc.apihelpers first; drop toRepoonly when the helper does not expose the needed operation. - For remote credentials/backends, remember extras such as
s3,gs,azure,ssh,gdrive,webdav,webhdfs,hdfs, andossare optional and may not be installed.
References
references/api-reference.mdlists public signatures, return shapes, and safe usage patterns.references/filesystem-access.mdexplains streaming reads,get_url(),DVCFileSystem, fsspec-style workflows, revisions, remotes, and config injection.references/troubleshooting.mdmaps common Python API errors to fixes.scripts/dvc_api_smoke.pyis a safe helper for verifying the installed package, opening a user-supplied tracked file, and showing optional metadata.
Routing Notes
- Use
../data-and-pipelines/SKILL.mdfor CLI/stage concepts before translating them toRepo.run()orRepo.reproduce(). - Use the sibling
metrics-params-plotssub-skill for metric, parameter, and plot semantics when available; this sub-skill only covers Python call shapes. - Use
../experiments/SKILL.mdfor experiment workflows; this sub-skill coversdvc.api.exp_show()anddvc.api.exp_save()integration points. - Use
../remotes-and-cache/SKILL.mdfor remote configuration, cache, optional storage extras, and push/pull behavior.
Safe Defaults
- Do not import private DVC modules for user-facing automation unless you are diagnosing DVC internals; prefer
dvc.apianddvc.repo.Repo. - Do not call
dvc.api.open()outside awithblock; it intentionally raisesAttributeErroron attribute access before entering the context. - Do not use write modes with
dvc.api.open(); only read modes are supported and non-read modes raiseValueError. - Do not treat
dvc.api.get_url()as proof that a remote object exists; it resolves the configured cache/remote URL for a tracked output. - Do not load large files with
dvc.api.read()when a streaming reader orDVCFileSystem.open()would avoid memory pressure.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).