Skip to content

iterative/dvcyaml-schema

Repository files navigation

dvcyaml-schema

JSON Schema for dvc.yaml file format, generated using Pydantic.

It can provide better autocompletion, validation, and linting for dvc.yaml files.

Usage

Visual Studio Code (with YAML Extension):

If you have installed the YAML Extension, it will automatically fetch the latest dvc.yaml schema, and work out of the box.

Alternatively, you can explicitly configure it by adding the following to your settings:

{
  "yaml.schemas": {
    "https://raw.githubusercontent.com/iterative/dvcyaml-schema/master/schema.json":
        "dvc.yaml"
  }
}

You can also specify custom URL or path instead for debugging/testing purposes.

JetBrain IDEs (PyCharm, Intellij IDEA, et al.)

JetBrain IDEs automatically fetch the latest dvc.yaml schema and should work without additional setup.

If you're using an older version or encounter any issues, refer to this guide for assistance.

Other Editors

dvc.yaml schema is available in JSON Schema Store, so it will be pulled automatically in editors that support it natively or through plugins.

To add it manually, use the following URL to obtain the latest JSON schema for dvc.yaml:

https://raw.githubusercontent.com/iterative/dvcyaml-schema/master/schema.json

Check the documentation of your specific editor or IDE for details on how to configure schemas.

Important Files:

  1. schema.json
  2. gen.py
  3. examples
  4. tests.py

Contributing

  1. Setup your environment (you'll need python3.10+ and pip).

    $ python3 -m venv .venv
    $ source .venv/bin/activate
    $ pip install -r requirements.txt
    $ pre-commit install
  2. Generate the schema.

    The schema is generated using Pydantic through the gen.py script. You can make adjustments to the script as needed.

    To manually generate the schema, run:

    $ ./gen.py schema.json
  3. (Optional) Add valid and invalid yaml examples.

  4. Run tests using:

    $ pytest
  5. Git-add the changes and then commit. pre-commit hook should run automatically and format/lint code, regenerate new schema, and run tests.

    $ git add -p
    $ git commit -m "<message>"

    If the hook makes additional changes, stage them and attempt the commit again.

  6. Send us a pull request. 🤗