eyconf.config.file.EYConf¶
- class eyconf.config.file.EYConf(schema: type[D])¶
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.
pathallow_additional_propertiesMethods
__init__(schema)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.
reset()Reset the configuration by reloading and validating the file.
to_dict([include_additional])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.
- reset()¶
Reset the configuration by reloading and validating the file.
- to_dict(include_additional: bool = False) dict¶
Convert the configuration data to a dictionary.
- Parameters:
include_additional (bool) – Whether to include extra data not part of the schema.
- update(data: dict)¶
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.