Construct config
ΒΆ
Loads values from the sources passed in (in order) and creates an instance of the config schema specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_schema |
Type[~ConfigClass] |
a subclass of ConfigSchema (or Pydantic's BaseModel) to validate config values with |
required |
sources |
Union[Sequence[Union[flex_config.config_source.ConfigSource, Callable[[Dict[str, Any]], flex_config.config_source.ConfigSource]]], flex_config.config_source.ConfigSource, Callable[[Dict[str, Any]], flex_config.config_source.ConfigSource]] |
A list of ConfigSources to be loaded and merged in the order they were passed in |
required |
Returns:
Type | Description |
---|---|
~ConfigClass |
An instance of the config schema passed in containing values loaded (in order) from the sources passed in |
Exceptions:
Type | Description |
---|---|
TypeError |
If config_schema passed in is not a subclass of ConfigSchema (which is just a renamed and re-exported pydantic.BaseModel which you could subclass instead if you already have it imported) |
ValidationError |
If there are issues validating the compiled config values e.g. missing values or values that couldn't be converted to their specified type |
Source code in flex_config\__init__.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|