Config
Base class of every configuration: YAML on disk, JSON Schema for tools.
Usage
Config(**data)Subclasses declare fields as pydantic models do. A config is frozen, refuses unknown fields and refuses non-finite floats, so its YAML, its JSON and its schema agree. Validation errors are ConfigError.
Examples
>>> class SelectConfig(Config):
... metric: str = "rmse"
... tolerance: float = 0.05
>>> SelectConfig.from_yaml("tolerance: 0.1\n").to_yaml()‘metric: rmse: 0.1’
Methods
| Name | Description |
|---|---|
| dump() | Write to_yaml() to a UTF-8 file. |
| from_yaml() | Validate a configuration from YAML text. |
| json_schema() | The JSON Schema (draft 2020-12) of this configuration. |
| load() | Read and validate a configuration from a UTF-8 YAML file. |
| to_yaml() | The configuration as YAML, every default filled in, fields in declaration order. |
dump()
Write to_yaml() to a UTF-8 file.
Usage
dump(path)from_yaml()
Validate a configuration from YAML text.
Usage
from_yaml(text)json_schema()
The JSON Schema (draft 2020-12) of this configuration.
Usage
json_schema()load()
Read and validate a configuration from a UTF-8 YAML file.
Usage
load(path)to_yaml()
The configuration as YAML, every default filled in, fields in declaration order.
Usage
to_yaml()