hpcflow.sdk.config.config_file.ConfigFile#

class hpcflow.sdk.config.config_file.ConfigFile(directory, logger, config_options)#

Bases: object

Configuration file.

Parameters:
  • directory – The directory containing the configuration file.

  • logger (logging.Logger) – Where to log messages.

  • config_options (ConfigOptions) – Configuration options.

Methods

add_default_config

Add a new default config to the config file, and create the file if it doesn't exist.

get_config_file_path

Get the path to the configuration file.

get_config_item

Get a configuration item.

get_invoc_data

Get the invocation data for the given configuration.

get_invocation

Get the invocation for the given configuration.

is_item_set

Determine if a configuration item is set.

rename_config_key

Change the config key of the loaded config.

save

Write the (modified) configuration to the configuration file.

select_invocation

Select a matching configuration for this invocation using run-time info.

update_invocation

Modify the invocation parameters of the loaded config.

Attributes

contents

The cached contents of the config file.

data

The parsed contents of the config file.

data_rt

The parsed contents of the config file where the alternate parser was used.

path

The path to the config file.

logger

Where to log messages.

directory

The directory containing the configuration file.

add_default_config(config_options, name=None)#

Add a new default config to the config file, and create the file if it doesn’t exist.

Parameters:
Return type:

str

property contents: str#

The cached contents of the config file.

property data: ConfigDict#

The parsed contents of the config file.

property data_rt: ConfigDict#

The parsed contents of the config file where the alternate parser was used.

directory#

The directory containing the configuration file.

static get_config_file_path(directory)#

Get the path to the configuration file.

Parameters:

directory (Path) –

Return type:

Path

get_config_item(config_key, name, *, raise_on_missing=False, default_value=None)#

Get a configuration item.

Parameters:
  • config_key (str) – The name of the configuration within the configuration file.

  • name (str) – The name of the configuration item.

  • raise_on_missing (bool) – Whether to raise an error if the config item is absent.

  • default_value – The default value to use when the config item is absent (and raise_on_missing is not specified).

Return type:

Any | None

get_invoc_data(config_key)#

Get the invocation data for the given configuration.

Parameters:

config_key (str) – The name of the configuration within the configuration file.

Return type:

DefaultConfiguration

get_invocation(config_key)#

Get the invocation for the given configuration.

Parameters:

config_key (str) – The name of the configuration within the configuration file.

Return type:

InvocationDescriptor

is_item_set(config_key, name)#

Determine if a configuration item is set.

Parameters:
  • config_key (str) – The name of the configuration within the configuration file.

  • name (str) – The name of the configuration item.

Return type:

bool

logger#

Where to log messages.

property path: Path#

The path to the config file.

rename_config_key(config_key, new_config_key)#

Change the config key of the loaded config.

Parameters:
  • config_key (str) – The old name of the configuration within the configuration file.

  • new_config_key (str) – The new name of the configuration.

Return type:

None

save()#

Write the (modified) configuration to the configuration file.

Return type:

None

static select_invocation(configs, run_time_info, path, config_key=None)#

Select a matching configuration for this invocation using run-time info.

Parameters:
  • configs (dict[str, Any]) –

  • run_time_info (dict[str, Any]) –

  • path (PathLike) –

  • config_key (str | None) –

Return type:

str

update_invocation(config_key, environment_setup=None, match=None)#

Modify the invocation parameters of the loaded config.

Parameters:
  • config_key (str) – The name of the configuration within the configuration file.

  • environment_setup (str | None) – The new value of the environment_setup key.

  • match (dict[str, str | list[str]] | None) – The new values to merge into the match key.

Return type:

None