Then we can configparse with driconfig as follows:
from datetime import date
from typing importDictfrom driconfig import DriConfig, DriConfigConfigDict
from pydantic import BaseModel
classDateInterval(BaseModel):
"""Model for the `date_interval` configuration."""
start: date
end: date
classAppConfig(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"
}
}
"""
FAQs
Pydantic-ish YAML configuration management.
We found that driconfig demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Elastic’s return to open source with the AGPL license has been met with skepticism, as many developers see it as a strategic move rather than a genuine effort to restore user trust and freedoms.
A new "revival hijack" supply chain attack targets deleted Python packages, with an estimated 22K packages at risk. Socket can detect and block hijacked packages that have added malicious code.