hpcflow.sdk.config package#
Submodules#
hpcflow.sdk.config.callbacks module#
Module that defines built-in callback functions for configuration item values.
- hpcflow.sdk.config.callbacks.callback_bool(config, value)#
- hpcflow.sdk.config.callbacks.callback_file_paths(config, file_path)#
- hpcflow.sdk.config.callbacks.callback_vars(config, value)#
Substitute configuration variables.
- hpcflow.sdk.config.callbacks.check_load_data_files(config, value)#
Check data files (e.g. task schema files) can be loaded successfully. This is only done on config.set (and not on config.get or config._validate) because it could be expensive in the case of remote files.
- hpcflow.sdk.config.callbacks.set_callback_file_paths(config, value)#
Check the file(s) is/are accessible. This is only done on config.set (and not on config.get or config._validate) because it could be expensive in the case of remote files.
hpcflow.sdk.config.cli module#
Module defining a function that returns the click CLI group for manipulating the app configuration.
- hpcflow.sdk.config.cli.CLI_exception_wrapper_gen(*exception_cls)#
Decorator factory
- hpcflow.sdk.config.cli.custom_warning_formatter(message, category, filename, lineno, file=None, line=None)#
Simple warning formatter that shows just the warning type and the message. We use this in the CLI, to avoid producing distracting output.
- hpcflow.sdk.config.cli.get_config_CLI(app)#
Generate the configuration CLI for the app.
- hpcflow.sdk.config.cli.warning_formatter(func=<function custom_warning_formatter>)#
Context manager for modifying the warnings formatter.
- Parameters:
func (function to set as the warnings.formatwarning function.) –
hpcflow.sdk.config.config module#
- class hpcflow.sdk.config.config.Config(app, options, config_dir, config_invocation_key, logger, uid=None, callbacks=None, variables=None, **overrides)#
Bases:
object
Application configuration as defined in one or more config files.
- Parameters:
options (ConfigOptions) –
- to_string : get a formatted string
- get_configurable : list all configurable items
- get : get a configuration item
- set_value : set a configuration item
- unset_value : unset a configuration item
- append_value : append a value to a list configuration item
- prepend_value : prepend a value to a list configuration item
- pop_value : pop a value from a list configuration item
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.
- append(name, value, is_json=False)#
- get(name, include_overrides=True, raise_on_missing=False, as_str=False, callback=True, default_value=None)#
Get a configuration item.
Notes
- get_all(include_overrides=True, as_str=False)#
Get all configurable items.
- get_configurable()#
Get a list of all configurable keys.
- pop(name, index)#
- prepend(name, value, is_json=False)#
- 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)#
- 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)#
- class hpcflow.sdk.config.config.ConfigOptions(default_directory, directory_env_var, sentry_DSN, sentry_traces_sample_rate, sentry_env, default_config=<factory>, extra_schemas=<factory>)#
Bases:
object
Application-level options for configuration
- Parameters:
default_directory (Path | str) –
directory_env_var (str) –
sentry_DSN (str) –
sentry_traces_sample_rate (float) –
sentry_env (str) –
default_config (Dict | None) –
extra_schemas (List[Schema] | None) –
- default_config: Dict | None#
- default_directory: Path | str#
- directory_env_var: str#
- extra_schemas: List[Schema] | None#
- sentry_DSN: str#
- sentry_env: str#
- sentry_traces_sample_rate: float#
hpcflow.sdk.config.config_file module#
hpcflow.sdk.config.errors module#
- exception hpcflow.sdk.config.errors.ConfigChangeFileUpdateError(names, err, message=None)#
Bases:
ConfigError
Raised when the updating of the config YAML file fails.
- exception hpcflow.sdk.config.errors.ConfigChangeInvalidError(name, message=None)#
Bases:
ConfigError
Raised when trying to set an invalid key in the Config.
- exception hpcflow.sdk.config.errors.ConfigChangeInvalidJSONError(name, json_str, err, message=None)#
Bases:
ConfigError
Raised when attempting to set a config key using an invalid JSON string.
- exception hpcflow.sdk.config.errors.ConfigChangePopIndexError(name, length, index, message=None)#
Bases:
ConfigError
Raised when trying to pop an item from a config item with an invalid index.
- exception hpcflow.sdk.config.errors.ConfigChangeTypeInvalidError(name, typ, message=None)#
Bases:
ConfigError
Raised when trying to modify a config item using a list operation, when the config item is not a list.
- exception hpcflow.sdk.config.errors.ConfigChangeValidationError(name, validation_err, message=None)#
Bases:
ConfigError
Raised when a change to the configurable data would invalidate the config.
- exception hpcflow.sdk.config.errors.ConfigDefaultValidationError(validation_err, message=None)#
Bases:
ConfigError
Raised when the specified default configuration in the ConfigOptions object is invalid.
- exception hpcflow.sdk.config.errors.ConfigError#
Bases:
Exception
Raised when a valid configuration can not be associated with the current invocation.
- exception hpcflow.sdk.config.errors.ConfigFileInvocationIncompatibleError(message='No config could be found that matches the current invocation.')#
Bases:
ConfigError
Raised when, given the run time information of the invocation, no compatible configuration can be found in the config file.
- exception hpcflow.sdk.config.errors.ConfigFileValidationError#
Bases:
ConfigError
- exception hpcflow.sdk.config.errors.ConfigInvocationKeyNotFoundError(invoc_key, file_path, available_keys)#
Bases:
ConfigError
Raised when a configuration invocation key is passed but it is not a valid key.
- Return type:
None
- exception hpcflow.sdk.config.errors.ConfigItemAlreadyUnsetError(name, message=None)#
Bases:
ConfigError
- exception hpcflow.sdk.config.errors.ConfigItemCallbackError(name, callback, err, message=None)#
Bases:
ConfigError
- exception hpcflow.sdk.config.errors.ConfigNonConfigurableError(name, message=None)#
Bases:
ConfigError
- exception hpcflow.sdk.config.errors.ConfigUnknownItemError(name, message=None)#
Bases:
ConfigError
- exception hpcflow.sdk.config.errors.ConfigUnknownOverrideError(name, message=None)#
Bases:
ConfigError
- exception hpcflow.sdk.config.errors.ConfigValidationError(message, meta_data=None)#
Bases:
ConfigError
Raised when the matching config data is invalid.
- exception hpcflow.sdk.config.errors.MissingEnvironmentFileError(file_name, err, message=None)#
Bases:
ConfigError
Raised when an environment file specified in the config file does not exist.
- exception hpcflow.sdk.config.errors.MissingTaskSchemaFileError(file_name, err, message=None)#
Bases:
ConfigError
Raised when a task schema file specified in the config file does not exist.