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.3

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.3
File Size Uploaded Provenance Actions
hydra_qol-0.2.3.tar.gz 15.5 kB Without provenance Details for hydra_qol-0.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 31.8 kB

Release files / hydra_qol-0.2.3.tar.gz

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

Download URL hydra_qol-0.2.3-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d3bddb24c7d4929de9870df4130ac1ac508e908a4623b6456469e2f61c1e87e
BLAKE2b-256 checksum
How to use checksums
b8e2942970fce87bfc2a8f71e6a819c1a54e1c6b5d4eb84b47950b01590e2a28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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.3

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