Pydantic-ish YAML configuration management.
Project description
DriConfig
A Pydantic-ish way to manage your project's YAML configurations.
| CI/CD | |
| Package |
Documentation: https://dribia.github.io/driconfig
Source Code: https://github.com/dribia/driconfig
The usage of YAML files to store configurations and parameters is widely accepted in the Python community, especially in Data Science environments. DriConfig provides a clean interface between your Python code and these YAML configuration files.
Installation
This project resides in the Python Package Index (PyPI), so it can easily be installed with pip:
pip install driconfig
Usage
You can import the DriConfig class from the driconfig package and create your own configuration classes.
from driconfig import DriConfig
Examples
Let's say we have a YAML configuration file config.yaml with the following data:
# config.yaml
model_parameters:
eta: 0.2
gamma: 2
lambda: 1
date_interval:
start: 2021-01-01
end: 2021-12-31
Then we can configparse with driconfig as follows:
from datetime import date
from typing import Dict
from driconfig import DriConfig, DriConfigConfigDict
from pydantic import BaseModel
class DateInterval(BaseModel):
"""Model for the `date_interval` configuration."""
start: date
end: date
class AppConfig(DriConfig):
"""Interface for the config/config.yaml file."""
"""Configure the YAML file location."""
model_config = DriConfigConfigDict(
config_folder=".",
config_file_name="config.yaml",
)
model_parameters: Dict[str, float]
date_interval: DateInterval
config = AppConfig()
print(config.model_dump_json(indent=4))
"""
{
"model_parameters": {
"eta": 0.2,
"gamma": 2.0,
"lambda": 1.0
},
"date_interval": {
"start": "2021-01-01",
"end": "2021-12-31"
}
}
"""
Contributing
Poetry is the best way to interact with this project. To install it, follow the official Poetry installation guide.
With poetry installed, one can install the project dependencies with:
poetry install
Then, to run the project unit tests:
make test
To run the linters (ruff and mypy):
make lint
License
driconfig is distributed under the terms of the
MIT license.
Check the LICENSE file for further details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file driconfig-1.1.1.tar.gz.
File metadata
- Download URL: driconfig-1.1.1.tar.gz
- Upload date:
- Size: 128.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a7d4306d71f8ed8231e9bfbbe113394e30ac222f8873319c4ffdf5c9ca78b39
|
|
| MD5 |
f160ec8f3f26895c27db28dd2d98815a
|
|
| BLAKE2b-256 |
cf7c76db8d8a44505902d4b5dbb7087252ec2a4c98d922a52882719dffa21b4b
|
File details
Details for the file driconfig-1.1.1-py3-none-any.whl.
File metadata
- Download URL: driconfig-1.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7696b452a5596c8322823b14f2b629483a51e4dd4c3ea81e4f848c84a9e38fe7
|
|
| MD5 |
4ddaeb7daaa0acf40cfad202d3d4d676
|
|
| BLAKE2b-256 |
b3f6eefe52f4e821962dd39caebe89173528c2f26da6f08a53c6277327c455a0
|