omegakit
Composable YAML configuration and Python object construction, powered by OmegaConf. Requires Python 3.12 or newer. The runtime dependencies are OmegaConf and typing_extensions.
Install with pip install omegakit. omegakit builds on OmegaConf but is not affiliated
with or endorsed by the OmegaConf project.
from omegakit import instantiate, load_config
config = load_config("app.yaml", overrides=["worker.timeout=30"])
worker = instantiate(config.worker)
# defaults.yaml
timeout: 10
retries: 3
# app.yaml
worker:
$base: ~import defaults.yaml
$class: myapp.Worker
timeout: 20
Configuration syntax
~import file.yamlreplaces a node with another file. Paths are relative to the importing file;~import file.yaml#workerselects a subnode. Cycles are rejected.$basemerges a mapping or list of mappings underneath the current node. Later bases win over earlier bases; the current node wins over all bases.$defaultssupplies defaults to dict-valued siblings. Item values win.$classimports and calls a Python class or callable with the node's arguments. Nested class nodes are instantiated recursively. Afrom_configmethod, if present, receives the materialized argument mapping instead of constructor keyword arguments.$refimports an object without calling it. It is supported inside an instantiated tree and cannot have sibling arguments (except$meta).$partial: truereturns afunctools.partial; the value must betrueorfalse.prepare(config)also defers the top-level call; nested objects are still built during preparation. Call-time arguments win over config arguments.$metais removed by default;load_config(..., keep_meta=True)preserves it. Instantiation always ignores metadata.keep_targets=Falseremoves construction keys.- Every
$-prefixed key is reserved. Loading keeps unknown ones, but instantiating a node with a$key that is not allowed there raises.
Assembly runs imports, bases, and defaults, then applies overrides. Only structural
references are resolved during assembly; other interpolations stay lazy and resolve
against the assembled configuration. ??? can be filled by consumers and fails when
accessed or instantiated if still missing. Overrides accept dictionaries, DictConfig,
or OmegaConf key=value dotlists; they do not rerun structural assembly.
Errors raised by a constructor or from_config keep their type and get a note naming
the failing node. The complete rules are in the
configuration contracts.
Configurable provides a default from_config implementation. With a dataclass
schema, class Model(Configurable[ModelConfig]), the config is validated and typed
before from_config receives it; see the
typed-configs guide. validate(cfg, schema=AppConfig)
checks a loaded config without building anything; see the
validation guide.
omegakit json-schema turns the same dataclasses into a JSON Schema for YAML
editors; see the editor-schemas guide. walk traverses
mapping nodes depth-first, parents before children. The optional expected argument
to instantiate and prepare is a typing hint, not runtime validation: with it, the
result is typed as that class, and without it as Any. overrides is keyword-only.
Optional resolvers
Nothing is registered on import, and this library does not load .env files. Each
resolver module carries its own dependencies, so omegakit.resolvers itself exports
nothing; import from the module, such as omegakit.resolvers.paths.
from pathlib import Path
from omegakit.resolvers.paths import register_paths_resolver
register_paths_resolver({"data_dir": Path("/srv/data")})
# YAML: dataset: ${paths:data_dir}/training
Paths are copied as strings; relative paths remain relative and unknown keys return None. The caller defines the project layout.
from omegakit.resolvers.torch import register_torch_resolvers
register_torch_resolvers()
# YAML: dtype: ${dtype:float32}
# YAML: use_cuda: ${cuda_available:}
Install PyTorch separately for your platform before enabling these resolvers. It is
not a package dependency. Importing the resolver module does not import Torch;
registration without Torch raises an explanatory ImportError. Individual functions
register_torch_dtype_resolver and register_cuda_available_resolver are available.
Register resolvers before loading configs. Registration is global to OmegaConf and
refuses existing names unless replace=True is supplied. Resolver results are cached
per config; replacing a resolver does not clear caches on existing configs.
Development
uv sync
uv run pytest
uv run ruff check
uv run ruff format --check
uv run pydoclint src
uv run pyright
uv run sphinx-build -W docs docs/_build
uv build
Tests that require a real Torch installation skip when it is absent.
This package imports and calls Python objects specified by configs, so configs must come from trusted sources. Assembly currently relies on private OmegaConf node APIs; the supported OmegaConf range is intentionally constrained to 2.3.x.
Metadata
Release files for omegakit 0.4.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 | Provenance | Actions |
|---|---|---|---|---|
| omegakit-0.4.0.tar.gz | 18.8 kB | Without provenance | Details for omegakit-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| omegakit-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for omegakit-0.4.0-py3-none-any.whl |
Total release size: 43.4 kB
Release files / omegakit-0.4.0.tar.gz
| Download URL | omegakit-0.4.0.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a2f575c0f7a5108a07cb6924ff55e03d1754ec62ff6fc053b0f342f79c3577c
|
|
BLAKE2b-256 checksum How to use checksums |
7af28989f8f641f5de8028edc1528113dd7ab35eb1ac690d6dabadb9f1dab751
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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 / omegakit-0.4.0-py3-none-any.whl
| Download URL | omegakit-0.4.0-py3-none-any.whl |
|---|---|
| Size | 24.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8ff8349d977850c89f7a66293a1784d128fb9025bf14a7ce64bfa979c33f574
|
|
BLAKE2b-256 checksum How to use checksums |
2bbebf00d46df728fbffd639ac006e78fcbddba27ffea0c1fda272afddbf1688
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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 omegakit 0.4.0
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.