Skip to main content

hydra-qol

Quality-of-life helpers for Hydra: register dataclass-based configs in one call, prepare composed configs for logging, and check that all YAML config files in a project are valid without running any experiments.

Installation

uv add hydra-qol
# or
pip install hydra-qol

Requires Python 3.11+, hydra-core 1.4+ (a pre-release at the time of writing) and omegaconf 2.4+.

What's in the box

Function Purpose
register_hydra_config(Config, groups, schema_name=...) Stores the main config class and all config-group options in Hydra's ConfigStore, after checking the classes for common mistakes.
prepare_for_logging(hydra_config) Turns a composed config into a plain dict (enums → strings, interpolations resolved, subconfigs tagged with their type), ready for wandb.init(config=...).
check_configs(Config, groups, schema_name=..., config_dir=...) Composes every YAML file in config_dir and instantiates Config from it; prints a report and returns an exit code.
validate_configs(...) Same as check_configs, but returns a list of CheckResult objects instead of printing. Handy in a test suite.

Quick start

# main.py
import hydra
from omegaconf import DictConfig, OmegaConf
from hydra_qol import prepare_for_logging, register_hydra_config

from my_project.config import CONFIG_GROUPS, Config


@hydra.main(config_path="configs", config_name="main_config")
def main(hydra_config: DictConfig) -> None:
    config = OmegaConf.to_object(hydra_config)
    assert isinstance(config, Config)
    config_for_logging = prepare_for_logging(hydra_config)
    ...


if __name__ == "__main__":
    register_hydra_config(Config, CONFIG_GROUPS, schema_name="main_config")
    main()
# check_configs.py
import sys

from hydra_qol import check_configs

from my_project.config import CONFIG_GROUPS, Config

if __name__ == "__main__":
    sys.exit(
        check_configs(
            Config, CONFIG_GROUPS, schema_name="main_config", config_dir="configs"
        )
    )

Config-group options are checked one at a time on top of the schema, so the schema's defaults list has to select an option for every config group. If the defaults list lives in a YAML file instead (i.e. @hydra.main(config_name="default_config") together with register_hydra_config(..., schema_name="base_config")), pass that file as well: check_configs(..., schema_name="base_config", config_with_defaults="default_config", ...).

$ python check_configs.py
OK    dm/celeba_male_smiling.yaml (dm=celeba_male_smiling)
OK    good_run.yaml (--config-name good_run)
FAIL  model/single_linear_layer.yaml (model=single_linear_layer)
Traceback (most recent call last):
  ...
hydra.errors.ConfigCompositionException: Could not override 'model.num_hiden'.

1 config file(s) are invalid:
  - model/single_linear_layer.yaml (model=single_linear_layer)

A complete, annotated example project that uses these functions can be found at wearepal/hydra-example. The full documentation lives in docs/ and is built with Sphinx:

uv sync --group docs
uv run sphinx-build -b html docs docs/_build/html

Development

uv sync                # installs test, lint and docs dependencies
uv run pytest
uv run ruff check && uv run ruff format --check
uv run ty check

Acknowledgements

register_hydra_config and prepare_for_logging originate from ranzen (Apache 2.0).

License

Apache 2.0, see LICENSE.

Metadata

Release files for hydra-qol 0.2.2

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-qol 0.2.2
File Size Uploaded Provenance
hydra_qol-0.2.2.tar.gz 15.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hydra-qol 0.2.2
File Interpreter ABI Platform
hydra_qol-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 31.2 kB

Release files / hydra_qol-0.2.2.tar.gz

Download URL hydra_qol-0.2.2.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b2b43278bd4402fa6339cef922fb291c9b41b3504742bb1f09dee793059e4d02
BLAKE2b-256 checksum
How to use checksums
b9549872752f31a6f4dda6e5aaaad6b987ecc425d6a879235762587e0a8b7a34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / hydra_qol-0.2.2-py3-none-any.whl

Download URL hydra_qol-0.2.2-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e55dbf8859465e8a0091a58be0c28f348f063bdbcb8555a9f57360740b4ae69
BLAKE2b-256 checksum
How to use checksums
dd093fcde23271cf9938cded817d1caa881fb59114c0510a8a19680cb258ff8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for hydra-qol 0.2.2

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.

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