eyconf.config.file.EYConf¶
- class eyconf.config.file.EYConf(schema: type[D], validator: Validator[D] | None = None)¶
Configuration class.
This class is used to generate a default configuration file from a schema represented by a dataclass.
It allows to generate, validate and load a configuration file.
Attributes
Get the configuration data.
pathMethods
__init__(schema[, validator])Return the configs' defaults (inferred from schema) as yaml.
get_file()Get the path to the configuration file.
overwrite(data)Overwrite the configuration with provided data.
reload()Reload the configuration by reloading and validating the file.
reset()Reset the configuration file to the default values.
to_dict()Convert the configuration data to a dictionary.
to_yaml()Convert the configuration data to a yaml string.
update(data)Update the configuration with provided data.
validate()Validate the current data against the schema.
- property data: D¶
Get the configuration data.
- default_yaml() str¶
Return the configs’ defaults (inferred from schema) as yaml.
You may overwrite this method to customize the default configuration generation.
- overwrite(data: dict | D)¶
Overwrite the configuration with provided data.
If the provided data is missing required fields, an error will be raised.
- reload()¶
Reload the configuration by reloading and validating the file.
- reset()¶
Reset the configuration file to the default values.
This will overwrite the existing configuration file!
- update(data: dict[str, Any])¶
Update the configuration with provided data.
This applies an partial update to the existing configuration data. Only the provided keys will be updated, others will remain unchanged.
- validate()¶
Validate the current data against the schema.