Configuration
Configuration singleton for YAML config with merge and environment overrides.
The redup_servicekit.config module contains:
- class ConfigSingleton[source]
Bases:
objectSingleton for loading and merging YAML configuration.
Supports deep merge of additional YAML files or dicts, and override of config values from environment variables. Use
___(triple underscore) in env names for nesting; use__(double) for spaces in key names. Comma-separated env values become lists.Example:
>>> from pathlib import Path >>> from redup_servicekit.config import ConfigSingleton >>> ConfigSingleton.load(Path("/config/config.yaml")) >>> ConfigSingleton.merge(Path("/config/config.local.yaml")) # if exists >>> ConfigSingleton.inject_os_envs() >>> config = ConfigSingleton.get()
- classmethod load(config_path)[source]
Load configuration from a YAML file.
- Parameters:
config_path (str or path-like) – Path to a
.yamlfile.- Returns:
The loaded config as a dict.
- Return type:
dict
- Raises:
ValueError – If the path does not exist or is not a
.yamlfile.
- classmethod get()[source]
Return the current configuration dict.
- Returns:
The config dict.
- Return type:
dict
- Raises:
ValueError – If configuration has not been loaded.