ConfigLoader

class tolteca.utils.ConfigLoader(files=None, load_sys_config=True, load_user_config=True, runtime_context_dir=None, env_files=None)[source]

Bases: ObjectProxy

A helper class to load config files for tolteca.

The config paths are loaded in the following order:

system_config_path < user_config_path < standalone_config_files

Parameters
fileslist

A list of YAML config file paths. The config dict get merged in their order in the list.

load_sys_configbool

If True, load the built-in config file (sys_config_path).

load_user_configbool

If True, load the user config file (user_config_path).

runtime_context_dirstr, pathlib.Path, optional

If specified, load the runtime context from this path.

env_fileslist

A list of systemd env file paths. The env dict get merged in their order in the list.

Attributes Summary

logger

sys_config_path

user_config_path

Methods Summary

get_config()

Return the merged config dict from all config file paths.

get_config_paths()

Return the merged config paths list from all config file paths.

get_env()

Return the merged env dict from all env file paths.

get_runtime_context([...])

Return the runtime context.

load_config_from_files(filepaths[, schema])

Attributes Documentation

logger = <Logger ConfigLoader (DEBUG)>
sys_config_path = PosixPath('/Users/ma/Codes/toltec/py/tolteca/tolteca/data/tolteca.yaml')
user_config_path = PosixPath('/Users/ma/Library/Application Support/tolteca/tolteca.yaml')

Methods Documentation

get_config()[source]

Return the merged config dict from all config file paths.

Note that this only compile the user supplied config files via filepaths in the constructor and the sys/user config files.

It does not load the config from the runtime context dir.

get_config_paths()[source]

Return the merged config paths list from all config file paths.

get_env()[source]

Return the merged env dict from all env file paths.

get_runtime_context(include_config_as_default=True, include_config_as_override=False)[source]

Return the runtime context.

Returns None when the runtime_context_dir is not set.

The include_config_as_* can be set to True to include the config dict from the get_config(). When as default, the config dict is made available to the runtime context config through the ConfigBackend.set_default_config, when as override, it is made available to the runtime context config trough the ConfigBackend.set_override_config.

classmethod load_config_from_files(filepaths, schema=None)[source]