hpcflow.app.Environment#

class hpcflow.app.Environment(name, setup=None, specifiers=None, executables=None, doc='', setup_label=None, _hash_value=None)#

Bases: Environment

An execution environment that contains a number of executables.

Parameters:
  • name (str) – The name of the environment.

  • setup (list[str]) – Commands to run to enter the environment.

  • specifiers (dict[str, str]) – Dictionary of attributes that may be used to supply additional key/value pairs to look up an environment by.

  • executables (list[Executable]) – List of abstract executables in the environment.

  • setup_label (str) – String label of the environment setup helper that generated this environment, if it was generated in that way.

  • doc (str)

  • _hash_value (str | None)

Methods

copy

Return a copy of this environment, optionally with some modified attributes.

from_json_like

Make an instance of this class from JSON (or YAML) data.

get_id

Get a hash of the specified name and specifiers dict.

get_specs_fmt

Formatted specifiers string for the provided specifiers.

to_dict

Serialize this object as a dictionary.

to_json_like

Serialize this object as an object structure that can be trivially converted to JSON.

Attributes

BUILTIN_ENV_SOURCE

string used in an Environment's source_file if it is builtin.

DEFAULT_CONFIGURED_ENVS_FILE

default file name within the config directory in which to store configured environment definitions.

documentation

id

An ID that can be used to compare if two environments are equivalent, in the sense that they must not be defined together.

source_file

If this environment was defined in a file, get the path to that file.

specs_fmt

Formatted specifiers string.

name

The name of the environment.

doc

Documentation for the environment.

specifiers

Dictionary of attributes that may be used to supply additional key/value pairs to look up an environment by.

executables

List of abstract executables in the environment.

setup

Commands to run to enter the environment.

setup_label

A label that identifies the env setup command that was used to define the environment.

BUILTIN_ENV_SOURCE: ClassVar[Literal['<builtin>']] = '<builtin>'#

string used in an Environment’s source_file if it is builtin.

DEFAULT_CONFIGURED_ENVS_FILE: ClassVar[str] = 'configured_envs.yaml'#

default file name within the config directory in which to store configured environment definitions.

copy(name=None, setup=None, specifiers=None, executables=None, doc='')#

Return a copy of this environment, optionally with some modified attributes.

In the special case of copying a built-in environment, the is_built_in specifier will be removed.

Parameters:
Return type:

Self

doc#

Documentation for the environment.

property documentation: str#
executables#

List of abstract executables in the environment.

classmethod from_json_like(json_like, shared_data=None)#

Make an instance of this class from JSON (or YAML) data.

Parameters:
  • json_like (str | Mapping[str, JSONed] | Sequence[Mapping[str, JSONed]] | None) – The data to deserialise.

  • shared_data (Mapping[str, ObjectList[JSONable]] | None) – Shared context data.

Return type:

The deserialised object.

static get_id(name, specifiers)#

Get a hash of the specified name and specifiers dict.

Parameters:
  • name (str)

  • specifiers (Mapping[str, str] | None)

Return type:

int

static get_specs_fmt(specifiers)#

Formatted specifiers string for the provided specifiers.

Parameters:

specifiers (Mapping[str, str] | None)

property id: int#

An ID that can be used to compare if two environments are equivalent, in the sense that they must not be defined together.

name#

The name of the environment.

setup: tuple[str, ...] | None#

Commands to run to enter the environment.

setup_label#

A label that identifies the env setup command that was used to define the environment.

property source_file: Literal['<builtin>'] | Path | None#

If this environment was defined in a file, get the path to that file.

specifiers: Mapping[str, Any]#

Dictionary of attributes that may be used to supply additional key/value pairs to look up an environment by.

property specs_fmt: str#

Formatted specifiers string.

to_dict()#

Serialize this object as a dictionary.

Return type:

dict[str, Any]

to_json_like(dct=None, shared_data=None, exclude=(), path=None)#

Serialize this object as an object structure that can be trivially converted to JSON. Note that YAML can also be produced from the result of this method; it just requires a different final serialization step.

Parameters:
  • dct (dict[str, JSONable] | None)

  • shared_data (_JSONDeserState)

  • exclude (Container[str | None])

  • path (list | None)

Return type:

tuple[JSONDocument, _JSONDeserState]