hpcflow.sdk.config.config.Config#
- class hpcflow.sdk.config.config.Config(app, options, logger, config_dir, config_invocation_key, uid=None, callbacks=None, variables=None, **overrides)#
Bases:
object
Application configuration as defined in one or more config files.
Notes
On modifying/setting existing values, modifications are not automatically copied to the configuration file; use save() to save to the file. Items in overrides are not saved into the file.
Methods
Append a value to a list-like configuration item.
Get a configuration item.
Get all configurable items.
Get a list of all configurable keys.
Remove a value from a specified index of a list-like configuration item.
Prepend a value to a list-like configuration item.
Decorator to register a function as a configuration callback for a specified configuration item name, to be invoked on get of the item.
Decorator to register a function as a configuration callback for a specified configuration item name, to be invoked on set of the item.
Save any modified/unset configuration items into the file.
Set the value of a configuration item.
Format the instance in a string, optionally exclude some keys.
Unset the value of a configuration item.
- Parameters:
app (BaseApp) –
options (ConfigOptions) –
logger (logging.Logger) –
config_dir (Optional[PathLike]) –
config_invocation_key (Optional[str]) –
- append(name, value, is_json=False)#
Append a value to a list-like configuration item.
- get(name, include_overrides=True, raise_on_missing=False, as_str=False, callback=True, default_value=None)#
Get a configuration item.
- get_all(include_overrides=True, as_str=False)#
Get all configurable items.
- get_configurable()#
Get a list of all configurable keys.
- pop(name, index)#
Remove a value from a specified index of a list-like configuration item.
- prepend(name, value, is_json=False)#
Prepend a value to a list-like configuration item.
- register_config_get_callback(name)#
Decorator to register a function as a configuration callback for a specified configuration item name, to be invoked on get of the item.
- register_config_set_callback(name)#
Decorator to register a function as a configuration callback for a specified configuration item name, to be invoked on set of the item.
- save()#
Save any modified/unset configuration items into the file.
- set(name, value, is_json=False, callback=True)#
Set the value of a configuration item.
- to_string(exclude=None, just_meta=False)#
Format the instance in a string, optionally exclude some keys.
- Parameters:
exclude (List | None) – List of keys to exclude. Optional.
just_meta – If True, just return a str of the meta-data. This is useful to show during initialisation, in the case where the configuration is otherwise invalid.
- unset(name)#
Unset the value of a configuration item.