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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hydra_qol-0.2.0.tar.gz | 14.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hydra_qol-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.2 kB
Release files / hydra_qol-0.2.0.tar.gz
| Download URL | hydra_qol-0.2.0.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cee2b3ede9d6360cf74e59f972368710ab1cfaebe59b5811939f1e77c6b1fd5a
|
|
BLAKE2b-256 checksum How to use checksums |
f7a133fd48bef9e8bf483ad04a7c42062a2f768fea52922f169e765062cb77a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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.0-py3-none-any.whl
| Download URL | hydra_qol-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4536c51d450973613c1db29f79587dadb24eff7d994a031427c6a64028362ac5
|
|
BLAKE2b-256 checksum How to use checksums |
7f3cb7885a9cea2de28a9e276bea0561ff80285cf460a11f5d037ceb93b55a83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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}
|