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

Append a value to a list-like configuration item.

get

Get a configuration item.

get_all

Get all configurable items.

get_configurable

Get a list of all configurable keys.

pop

Remove a value from a specified index of a list-like configuration item.

prepend

Prepend a value to a list-like configuration item.

register_config_get_callback

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

Decorator to register a function as a configuration callback for a specified configuration item name, to be invoked on set of the item.

reset

Reset to the default configuration.

save

Save any modified/unset configuration items into the file.

set

Set the value of a configuration item.

to_string

Format the instance in a string, optionally exclude some keys.

unset

Unset the value of a configuration item.

Parameters:
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.

reset()#

Reset to the default configuration.

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.