Skip to main content

dvcgen

Write your DVC pipeline once, in Python.

dvcgen is an early-stage command-line tool for generating DVC pipeline files from lightweight declarations embedded in Python pipeline scripts.

Current Status

Implemented:

  • A Python package named dvcgen
  • A dvcgen console command
  • CLI argument parsing for pipeline script paths
  • CLI input validation and overwrite protection
  • Public declaration helpers: stage(), dep(), out(), and param()
  • Python script inspection for top-level literal declarations
  • dvc.yaml generation
  • params.yaml generation

Installation

uv tool install dvcgen

Or run without installing:

uvx dvcgen --help

Usage

Show CLI help:

dvcgen --help

Generate DVC files from one or more Python pipeline scripts:

dvcgen pipeline/*.py

The command writes dvc.yaml and params.yaml in the current directory. Stage names are derived from input Python filenames. For example, pipeline/train.py becomes the train stage.

By default, dvcgen refuses to overwrite existing dvc.yaml or params.yaml files. Use --force when you intentionally want to replace them:

dvcgen --force pipeline/*.py

Write files to another directory with --output-dir:

dvcgen --output-dir generated pipeline/*.py

Bad inputs fail with an error message and a non-zero exit code. Successful runs print the files that were written.

Inspect declarations from Python without executing the pipeline script:

from dvcgen.inspect import inspect_file

declarations = inspect_file("pipeline/train.py")
print(declarations.deps)
print(declarations.outs)
print(declarations.params)

Release

Publishing is intentionally manual while the project is early stage. Build and validate artifacts before uploading anything:

uv run python -m build
uv run twine check dist/*

Use TestPyPI first when rehearsing a release. Create a TestPyPI API token, then upload with the token as the password:

uv run twine upload --repository testpypi dist/*

Use the production PyPI repository only when the version, changelog, and package name decision are ready:

uv run twine upload dist/*

For both repositories, use __token__ as the username and the repository API token as the password. Avoid committing tokens or storing them in project files.

Before the first production upload, decide whether to publish the current minimal release to reserve the dvcgen package name on PyPI. Once a version is uploaded to PyPI or TestPyPI, that exact version cannot be uploaded again; bump the version before retrying with changed artifacts.

Planned MVP

The intended MVP is:

  1. Pipeline scripts declare dependencies, outputs, and parameters in Python.
  2. dvcgen inspects those declarations without executing the scripts.
  3. dvcgen writes dvc.yaml and params.yaml.

Example API:

from dvcgen import dep, out, param, stage

stage(
    cmd="python -m pipeline.train",
    wdir=".",
    desc="Train model",
    frozen=False,
    always_changed=False,
)

TRAIN_DATA = dep("data/processed.csv")
MODEL = out("models/model.pkl")

LR = param("train.lr", 0.001)

stage() declares metadata for the generated DVC stage. It is optional; when it is omitted, dvcgen keeps the default command:

"cmd": "python pipeline/train.py"

Supported stage fields are:

  • cmd: override the command DVC runs for this stage
  • wdir: stage working directory
  • desc: human-readable stage description
  • frozen: protect the stage from reproduction
  • always_changed: always consider the stage changed

wdir, desc, frozen, and always_changed are emitted only when explicitly provided. Each pipeline script may declare at most one stage().

out() also accepts DVC output options as keyword arguments:

MODEL = out("models/model.pkl", cache=False, persist=True)

Supported output options are cache, remote, persist, desc, and push. Plain out("path") declarations continue to generate simple string entries. Metrics and plots are separate DVC stage metadata and are not modeled as out() options.

Running:

dvcgen pipeline/train.py

Generates dvc.yaml:

"stages":
  "train":
    "cmd": "python pipeline/train.py"
    "deps":
      - "pipeline/train.py"
      - "data/processed.csv"
    "outs":
      - "models/model.pkl"
    "params":
      - "train.lr"

And params.yaml:

"train":
  "lr": 0.001

Metadata

Release files for dvcgen 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dvcgen 0.9.0
File Size Uploaded Provenance Actions
dvcgen-0.9.0.tar.gz 72.6 kB Without provenance Details for dvcgen-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dvcgen 0.9.0
File Interpreter ABI Platform Actions
dvcgen-0.9.0-py3-none-any.whl Python 3 none any Details for dvcgen-0.9.0-py3-none-any.whl

Total release size: 83.0 kB

Release files / dvcgen-0.9.0.tar.gz

Download URL dvcgen-0.9.0.tar.gz
Size 72.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a75dbb68ba7515f3e4f914c0f22476ff76e37a6a13a23e989800a8e00627934d
BLAKE2b-256 checksum
How to use checksums
606af7c2af18401120186c44bc6de8aa2fdae9391d6b4668a0e70278a5c1b8f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Release files / dvcgen-0.9.0-py3-none-any.whl

Download URL dvcgen-0.9.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a6d9a181d6b80bc596032a76e2c898540ce79b97e0d94e5250c68dffcfa35b9
BLAKE2b-256 checksum
How to use checksums
69a665424cdda15d5baf0f8e19a27c66ecc60efbcdfacba4bd6b54b9d6932904
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Security for dvcgen 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page