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, config_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, config_name="main_config", config_dir="configs"
        )
    )
$ 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.1.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 hydra-qol 0.1.0
File Size Uploaded
hydra_qol-0.1.0.tar.gz 14.3 kB Details

Built distribution (wheel)

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

Total release size: 29.3 kB

Release files / hydra_qol-0.1.0.tar.gz

Download URL hydra_qol-0.1.0.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e30fd05d90ed14f83e3917e05bbb3460f2f5a7cadf51c1e44a407116c7dcee9e
BLAKE2b-256 checksum
How to use checksums
55c127ea6396f342079db047237dbadd8e3c8a7380055c8ab37e33f3d061e254
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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.1.0-py3-none-any.whl

Download URL hydra_qol-0.1.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7aa053202f60a9b6c6d2056a15ad39ab7ea66c76bfbc943f27a164ec9bea0f0f
BLAKE2b-256 checksum
How to use checksums
41cee56beaa0956ba376f208bc25e9caa4b3ca6162d04fd67d48029b21e3b8f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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 history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

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