dae.configuration package

Subpackages

Submodules

dae.configuration.gpf_config_parser module

class dae.configuration.gpf_config_parser.DefaultBox(*args: Any, **kwargs: Any)[source]

Bases: Box

class dae.configuration.gpf_config_parser.FrozenBox(*args: Any, **kwargs: Any)[source]

Bases: DefaultBox

class dae.configuration.gpf_config_parser.GPFConfigParser[source]

Bases: object

Class that handles reading, validation and parsing of all GPF config files.

Supports loading from YAML and TOML files. Parsing used depends on type specified in filename:

.yaml, .yml - YAML parse .toml, .conf - TOML parse

classmethod collect_directory_configs(dirname: str) List[str][source]
filetype_parsers: dict = {'.conf': <function loads>, '.toml': <function loads>, '.yaml': <function safe_load>, '.yml': <function safe_load>}
classmethod load_config(filename: str, schema: dict, default_config_filename: str | None = None, default_config: dict | None = None) Box[source]

Load a file and return a processed configuration.

classmethod load_config_raw(filename: str) Dict[str, Any][source]
classmethod load_directory_configs(dirname: str, schema: dict, default_config_filename: str | None = None, default_config: dict | None = None) List[Box][source]

Find and load all configs in a given root directory.

static merge_config(config: Dict[str, Any], default_config: Dict[str, Any] | None = None) Dict[str, Any][source]
classmethod modify_tuple(tup: Box, new_values: Dict[str, Any]) Box[source]
static parse_and_interpolate(content: str, parser: ~typing.Callable[[str], dict] = <function safe_load>, conf_dir: str | None = None) dict[source]

Parse text content and perform variable interpolation on result.

classmethod parse_and_interpolate_file(filename: str | PathLike, conf_dir: str | None = None) dict[source]

Open a file and interpolate it’s contents.

static process_config(config: Dict[str, Any], schema: dict, default_config: Dict[str, Any] | None = None, conf_dir: str | None = None) Box[source]

Pass an interpolated config to validation and prepare it for use.

default_config: interpolated configuration to use for defaults where values in the main configuration are missing.

static validate_config(config: Dict[str, Any], schema: dict, conf_dir: str | None = None) dict[source]

Perform validation on a parsed config.

class dae.configuration.gpf_config_parser.GPFConfigValidator(*args, **kwargs)[source]

Bases: Validator

Validator class with various extra cerberus features for GPF.

Supports:

“coerce”: “abspath” - transform a relative path in configuration to an absolute path

checkers = ()
coercers = ('abspath',)
default_setters = ()
normalization_rules = {'coerce': {'oneof': [{'type': 'callable'}, {'type': 'list', 'schema': {'oneof': [{'type': 'callable'}, {'type': 'string', 'allowed': ('abspath',)}]}}, {'type': 'string', 'allowed': ('abspath',)}]}, 'default': {'nullable': True}, 'default_setter': {'oneof': [{'type': 'callable'}, {'type': 'string', 'allowed': ()}]}, 'purge_unknown': {'type': 'boolean'}, 'rename': {'type': 'hashable'}, 'rename_handler': {'oneof': [{'type': 'callable'}, {'type': 'list', 'schema': {'oneof': [{'type': 'callable'}, {'type': 'string', 'allowed': ('abspath',)}]}}, {'type': 'string', 'allowed': ('abspath',)}]}}
rules = {'allof': {'logical': 'allof', 'type': 'list'}, 'allow_unknown': {'oneof': [{'type': 'boolean'}, {'type': ['dict', 'string'], 'check_with': 'bulk_schema'}]}, 'allowed': {'type': 'container'}, 'anyof': {'logical': 'anyof', 'type': 'list'}, 'check_with': {'oneof': [{'type': 'callable'}, {'type': 'list', 'schema': {'oneof': [{'type': 'callable'}, {'type': 'string', 'allowed': ()}]}}, {'type': 'string', 'allowed': ()}]}, 'coerce': {'oneof': [{'type': 'callable'}, {'type': 'list', 'schema': {'oneof': [{'type': 'callable'}, {'type': 'string', 'allowed': ('abspath',)}]}}, {'type': 'string', 'allowed': ('abspath',)}]}, 'contains': {'empty': False}, 'default': {'nullable': True}, 'default_setter': {'oneof': [{'type': 'callable'}, {'type': 'string', 'allowed': ()}]}, 'dependencies': {'check_with': 'dependencies', 'type': ('dict', 'hashable', 'list')}, 'depends_global': {'type': 'string'}, 'empty': {'type': 'boolean'}, 'excludes': {'schema': {'type': 'hashable'}, 'type': ('hashable', 'list')}, 'forbidden': {'type': 'list'}, 'items': {'check_with': 'items', 'type': 'list'}, 'keysrules': {'check_with': 'bulk_schema', 'forbidden': ['rename', 'rename_handler'], 'type': ['dict', 'string']}, 'max': {'nullable': False}, 'maxlength': {'type': 'integer'}, 'meta': {}, 'min': {'nullable': False}, 'minlength': {'type': 'integer'}, 'noneof': {'logical': 'noneof', 'type': 'list'}, 'nullable': {'type': 'boolean'}, 'oneof': {'logical': 'oneof', 'type': 'list'}, 'purge_unknown': {'type': 'boolean'}, 'readonly': {'type': 'boolean'}, 'regex': {'type': 'string'}, 'rename': {'type': 'hashable'}, 'rename_handler': {'oneof': [{'type': 'callable'}, {'type': 'list', 'schema': {'oneof': [{'type': 'callable'}, {'type': 'string', 'allowed': ('abspath',)}]}}, {'type': 'string', 'allowed': ('abspath',)}]}, 'require_all': {'type': 'boolean'}, 'required': {'type': 'boolean'}, 'schema': {'anyof': [{'check_with': 'schema'}, {'check_with': 'bulk_schema'}], 'type': ['dict', 'string']}, 'type': {'check_with': 'type', 'type': ['string', 'list']}, 'valuesrules': {'check_with': 'bulk_schema', 'forbidden': ['rename', 'rename_handler'], 'type': ['dict', 'string']}}
validation_rules = {'allof': {'logical': 'allof', 'type': 'list'}, 'allow_unknown': {'oneof': [{'type': 'boolean'}, {'type': ['dict', 'string'], 'check_with': 'bulk_schema'}]}, 'allowed': {'type': 'container'}, 'anyof': {'logical': 'anyof', 'type': 'list'}, 'check_with': {'oneof': [{'type': 'callable'}, {'type': 'list', 'schema': {'oneof': [{'type': 'callable'}, {'type': 'string', 'allowed': ()}]}}, {'type': 'string', 'allowed': ()}]}, 'contains': {'empty': False}, 'dependencies': {'check_with': 'dependencies', 'type': ('dict', 'hashable', 'list')}, 'depends_global': {'type': 'string'}, 'empty': {'type': 'boolean'}, 'excludes': {'schema': {'type': 'hashable'}, 'type': ('hashable', 'list')}, 'forbidden': {'type': 'list'}, 'items': {'check_with': 'items', 'type': 'list'}, 'keysrules': {'check_with': 'bulk_schema', 'forbidden': ['rename', 'rename_handler'], 'type': ['dict', 'string']}, 'max': {'nullable': False}, 'maxlength': {'type': 'integer'}, 'meta': {}, 'min': {'nullable': False}, 'minlength': {'type': 'integer'}, 'noneof': {'logical': 'noneof', 'type': 'list'}, 'nullable': {'type': 'boolean'}, 'oneof': {'logical': 'oneof', 'type': 'list'}, 'readonly': {'type': 'boolean'}, 'regex': {'type': 'string'}, 'require_all': {'type': 'boolean'}, 'required': {'type': 'boolean'}, 'schema': {'anyof': [{'check_with': 'schema'}, {'check_with': 'bulk_schema'}], 'type': ['dict', 'string']}, 'type': {'check_with': 'type', 'type': ['string', 'list']}, 'valuesrules': {'check_with': 'bulk_schema', 'forbidden': ['rename', 'rename_handler'], 'type': ['dict', 'string']}}

dae.configuration.study_config_builder module

class dae.configuration.study_config_builder.ConfigDumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)[source]

Bases: Dumper

increase_indent(flow=False, indentless=False)[source]
class dae.configuration.study_config_builder.StudyConfigBuilder(config_dict: Dict[str, Any])[source]

Bases: object

Class used for building study configurations from dictionaries.

build_config() str[source]
class dae.configuration.study_config_builder.TOMLDict(dict=None, /, **kwargs)[source]

Bases: UserDict

Class that transforms Python dictionaries to TOML dictionaries.

static from_dict(input_dict)[source]

Construct TOMLDict from a Python dictionary.

Any dictionaries or lists in the dictionary’s values are also converted.

class dae.configuration.study_config_builder.TOMLList(initlist=None)[source]

Bases: UserList

Class that transforms Python dictionaries to TOML dictionaries.

static from_list(input_list)[source]

Construct TOMLList from a Python list.

Any dictionaries or lists in the list’s element are also converted.

dae.configuration.utils module

dae.configuration.utils.validate_existing_path(field: str, value: str, error)[source]
dae.configuration.utils.validate_path(field: str, value: str, error)[source]

Module contents