YAML-based configuration with Pydantic validation and dynamic object instantiation.
Why EzConfy?
ML projects constantly deal with configuration: learning rates, model parameters, dataset options, augmentation pipelines. EzConfy gives you typed, validated configs with automatic object wiring — without the complexity of a full framework like Hydra.
from ezconfy import ConfigBuilder
cfg = ConfigBuilder.from_files(config_paths="config.yaml", schema_path="schema.yaml")
print(cfg.training.batch_size) # validated, typed access
What you get
| Feature | Description |
|---|---|
| Pydantic validation | Type checking with clear error messages |
| Schema-aware casting | Strings become Path objects, etc. — before constructors run |
| Dynamic instantiation | Construct any Python class from YAML via _target_type_ |
| Placeholders | ${key}, attribute access, method calls, arithmetic |
| Multi-file merge | Split configs across files, override per experiment |
| Code generation | Generate Pydantic models for editor autocompletion |
Installation
pip install ezconfy
Requires Python 3.11+.
Quick Start
config.yaml
lr: 0.001
batch_size: 32
data_path: ./data
schema.yaml
lr: float
batch_size: int
data_path: pathlib:Path
train.py
from ezconfy import ConfigBuilder
cfg = ConfigBuilder.from_files(
config_paths="config.yaml",
schema_path="schema.yaml",
)
print(cfg.lr) # 0.001 (float)
print(cfg.batch_size) # 32 (int)
print(cfg.data_path) # PosixPath('data') — automatically cast
Schema
A schema file describes the expected shape and types of your configuration:
types:
OptimizerType:
- adam
- sgd
- rmsprop
schema:
model:
hidden_dims: list[int]
training:
batch_size: int = 32
num_epochs: int = 10
shuffle: bool = true
dropout: float?
optimizer: OptimizerType
If no types are needed, the entire YAML is treated as the root schema (no schema: wrapper required).
Supported type syntax
| Syntax | Meaning |
|---|---|
int, float, str, bool |
Primitive types |
type? |
Optional (defaults to None) |
type = value |
Type with default |
list[T] |
List of T |
A | B |
Union type |
[a, b, c] |
Enum |
Child < Parent |
Model inheritance |
pathlib:Path |
External type (import path) |
/path/to/file.py:ClassName |
External type (file path) |
Object Instantiation
Construct Python objects directly from config using _target_type_:
dataset:
_target_type_: mypackage.data:MyDataset
_init_args_:
num_classes: 100
root: /data
Use _init_method_ for alternative constructors (e.g. from_pretrained):
encoder:
_target_type_: mypackage.models:BertEncoder
_init_method_: from_pretrained
_init_args_:
model_name: bert-base-uncased
Placeholders & Expressions
Reference other config values with ${key}. Supports attribute access, method calls, and arithmetic:
lr: 0.001
warmup_lr: ${lr * 10} # arithmetic
num_classes: 10
dataset:
_target_type_: mypackage.data:MyDataset
_init_args_:
num_classes: ${num_classes} # scalar reference
model:
_target_type_: mypackage.models:Classifier
_init_args_:
in_features: ${dataset.num_classes} # attribute access
params: ${encoder.parameters()} # method call
Objects are instantiated in topological order based on their dependencies — forward references work automatically.
Multi-file Configs & Overrides
Pass multiple files — they are deep-merged in order (later files win on conflicts):
cfg = ConfigBuilder.from_files(
config_paths=["base.yaml", "experiment.yaml"],
)
Apply programmatic overrides on top:
cfg = ConfigBuilder.from_files(
config_paths="config.yaml",
overrides={"training": {"batch_size": 64}},
)
Patch a single list element instead of restating the whole list — ... keeps the other elements:
callbacks:
- ...
- _id_: early_stopping
_init_args_:
patience: 20
Code Generation CLI
Generate a Pydantic model file from a schema for editor autocompletion and static analysis:
ezconfy generate schema.yaml -o models.py
Documentation
Full documentation: alessioarcara.github.io/EzConfy
License
Metadata
Release files for ezconfy 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 | |
|---|---|---|---|
| ezconfy-0.2.0.tar.gz | 133.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ezconfy-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 153.1 kB
Release files / ezconfy-0.2.0.tar.gz
| Download URL | ezconfy-0.2.0.tar.gz |
|---|---|
| Size | 133.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d67fac2701655340b79909644f20e2163bc54b14cc0f41f8d5cef1707b5d68e6
|
|
BLAKE2b-256 checksum How to use checksums |
f6cc463488d3ca69be1f80b310f712434b5963e35ccf7bb57cef5546d7b3fb80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.
Transparency logRelease files / ezconfy-0.2.0-py3-none-any.whl
| Download URL | ezconfy-0.2.0-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b1d3fb2da6601fe91a94e1f22b9decc647100cd216a91adcdc7ff90a4e9c244
|
|
BLAKE2b-256 checksum How to use checksums |
f5a3d28c388efaff0d65903d547ed510e486789d448717cf10a8a7683446a2d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.
Transparency log