Skip to main content

hydra-auto-schema

codecov

This tool greatly improves the experience of developing a project with Hydra by enabling rich IDE support for Hydra config files.

📢 If you are thinking of using Hydra for a PyTorch or Jax-based ML project, you might want to take a look at the Research Project Template where this plugin was originally created. This is also where this plugin is best integrated!

With this, you'll now get to see:

  • the list of available configuration options in a given config
  • the default values for each entry
  • the documentation associated with each entry (taken from the source code of the _target_ callable!) Additionally
  • A warning is displayed when a value is unexpected, or of the wrong type.

All-in-all, this helps to prevent errors, and gives your codebase the same kind of neatness and safety that type hints do.

Demo

https://github.com/user-attachments/assets/08f52d47-ebba-456d-95ef-ac9525d8e983

Installation

Requirements

At the moment, we assume that you are using VSCode as your code editor. We use the yaml extension by RedHat, and install it for you if it isn't already. However any IDE with a YAML language server should be fairly easy to make work. Please make an issue if this doesn't work with your IDE.

uv (recommended)

uv add hydra-auto-schema

Note: This plugin needs to be installed in your project's virtual environment. It should not be installed as an isolated tool using uv tool. This is because the plugin needs to import the modules where the _target_s are defined in order to inspect their signature.

pip

pip install hydra-auto-schema

Usage (CLI)

Generate the yaml schemas for all the configs in the current folder:

hydra-auto-schema

Watch for changes in the configs folder and update the schemas as needed:

hydra-auto-schema configs --watch

Usage (Hydra)

This package includes a Hydra plugin. By default, it will try to update all the schema files in your project's config directory when Hydra's main function is called.

You don't really need to call anything for this to happen! Just keep using Hydra like you used to, and hopefully your config files will just feel much better to use! 😁

To configure how the auto schema plugin is called by Hydra, you can add the following block somwehere before your main Hydra function:

from hydra_plugins.auto_schema import auto_schema_plugin

auto_schema_plugin.config = auto_schema_plugin.AutoSchemaPluginConfig(
    schemas_dir=... # Path where you want the schema files to be saved. Defaults to ".schemas",
    regen_schemas=False,  # Whether to regenerate schemas even if the config did not change.
    stop_on_error=False,
    quiet=True,
    add_headers=False,  # controls whether to add headers, use vscode settings, or either.
)

How to Contribute

This is a very new tool, and we'd love to get your feedback! Please feel free to make an Issue if you have any questions or feedback. We'll be happy to assist you.

Metadata

Release files for hydra-auto-schema 0.0.7

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

Source distribution (sdist)

Source distribution for hydra-auto-schema 0.0.7
File Size Uploaded
hydra_auto_schema-0.0.7.tar.gz 87.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hydra-auto-schema 0.0.7
File Interpreter ABI Platform
hydra_auto_schema-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 114.7 kB

Release files / hydra_auto_schema-0.0.7.tar.gz

Download URL hydra_auto_schema-0.0.7.tar.gz
Size 87.5 kB
Tags Source
SHA-256 checksum
How to use checksums
75ae95d70f22beeb627ae3ca9fd38402cff3ae989f75f208e6b987a411611d40
BLAKE2b-256 checksum
How to use checksums
9fe162d0bbe1a2df4eb0ffbf59258ca18cefbfaa2615b0d00ae5fb2a41e294ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 10, 2025.

Transparency log

Release files / hydra_auto_schema-0.0.7-py3-none-any.whl

Download URL hydra_auto_schema-0.0.7-py3-none-any.whl
Size 27.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0616e237a1c77e731e397bacff1acdda27e7727058b699bd14d2e72473ceefb1
BLAKE2b-256 checksum
How to use checksums
96dea6a6a6bdcdff185dbc4309a50405a1ea6005b9edd4c64bb3d415a3bd0592
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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