hpcflow.app.WorkflowTemplate#

class hpcflow.app.WorkflowTemplate(name, doc=None, tasks=<factory>, loops=<factory>, workflow=None, resources=None, environments=None, env_presets=None, source_file=None, store_kwargs=<factory>, merge_resources=True, merge_envs=True)#

Bases: WorkflowTemplate

Class to represent initial parametrisation of a hpcFlow workflow, with limited validation logic.

Parameters:
  • name (str) – A string name for the workflow. By default this name will be used in combination with a date-time stamp when generating a persistent workflow from the template.

  • tasks (list[Task]) – A list of Task objects to include in the workflow.

  • loops (list[Loop]) – A list of Loop objects to include in the workflow.

  • workflow (hpcflow.app.Workflow | None) – The associated concrete workflow.

  • resources (dict[str, dict] | list[ResourceSpec] | ResourceList) – Template-level resources to apply to all tasks as default values. This can be a dict that maps action scopes to resources (e.g. {“any”: {“num_cores”: 2}}) or a list of ResourceSpec objects, or a ResourceList object.

  • environments (Dict[str, Dict[str, Any]] | None) – The execution environments to use.

  • env_presets (List[str] | str | None) – The environment presets to use.

  • source_file (str | None) – The file this was derived from.

  • store_kwargs (Dict | None) – Additional arguments to pass to the persistent data store constructor.

  • merge_resources (bool | None) – If True, merge template-level resources into element set resources. If False, template-level resources are ignored.

  • merge_envs (bool | None) – Whether to merge the environemtns into task resources.

  • doc (List[str] | str | None) –

Methods

from_JSON_file

Load from a JSON file.

from_JSON_string

Load from a JSON string.

from_YAML_file

Load from a YAML file.

from_YAML_string

Load from a YAML string.

from_file

Load from either a YAML or JSON file, depending on the file extension.

from_json_like

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

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

app

doc

Documentation information.

env_presets

The environment presets to use.

environments

The execution environments to use.

merge_envs

Whether to merge the environemtns into task resources.

merge_resources

Whether to merge template-level resources into element set resources.

resources

Template-level resources to apply to all tasks as default values.

source_file

The file this was derived from.

workflow

The associated concrete workflow.

name

A string name for the workflow.

tasks

A list of Task objects to include in the workflow.

loops

A list of Loop objects to include in the workflow.

store_kwargs

Additional arguments to pass to the persistent data store constructor.

app = BaseApp(name='hpcFlow', version='0.2.0a180')#
doc: List[str] | str | None = None#

Documentation information.

env_presets: str | List[str] | None = None#

The environment presets to use.

environments: Dict[str, Dict[str, Any]] | None = None#

The execution environments to use.

classmethod from_JSON_file(path, variables=None)#

Load from a JSON file.

Parameters:
  • path (PathLike) – The path to the JSON file containing the workflow template parametrisation.

  • variables (Dict[str, str] | None) – String variables to substitute in the file given by path.

Return type:

WorkflowTemplate

classmethod from_JSON_string(string, variables=None)#

Load from a JSON string.

Parameters:
  • string (str) – The JSON string containing the workflow template parametrisation.

  • variables (Dict[str, str] | None) – String variables to substitute in string.

Return type:

WorkflowTemplate

classmethod from_YAML_file(path, variables=None)#

Load from a YAML file.

Parameters:
  • path (PathLike) – The path to the YAML file containing the workflow template parametrisation.

  • variables (Dict[str, str] | None) – String variables to substitute in the file given by path.

Return type:

WorkflowTemplate

classmethod from_YAML_string(string, variables=None)#

Load from a YAML string.

Parameters:
  • string (str) – The YAML string containing the workflow template parametrisation.

  • variables (Dict[str, str] | None) – String variables to substitute in string.

Return type:

WorkflowTemplate

classmethod from_file(path, template_format=None, variables=None)#

Load from either a YAML or JSON file, depending on the file extension.

Parameters:
  • path (PathLike) – The path to the file containing the workflow template parametrisation.

  • template_format (str | None) – The file format to expect at path. One of “json” or “yaml”, if specified. By default, “yaml”.

  • variables (Dict[str, str] | None) – String variables to substitute in the file given by path.

Return type:

WorkflowTemplate

classmethod from_json_like(json_like, shared_data=None)#

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

Parameters:
  • json_like (Union[Dict, List]) – The data to deserialise.

  • shared_data (Optional[Dict[str, ObjectList]]) – Shared context data.

Return type:

The deserialised object.

loops: List[app.Loop] | None#

A list of Loop objects to include in the workflow.

merge_envs: bool | None = True#

Whether to merge the environemtns into task resources.

merge_resources: bool | None = True#

Whether to merge template-level resources into element set resources.

name: str#

A string name for the workflow.

resources: Dict[str, Dict] | None = None#

Template-level resources to apply to all tasks as default values.

source_file: str | None = None#

The file this was derived from.

store_kwargs: Dict | None#

Additional arguments to pass to the persistent data store constructor.

tasks: List[app.Task] | None#

A list of Task objects to include in the workflow.

to_dict()#

Serialize this object as a dictionary.

to_json_like(dct=None, shared_data=None, exclude=None, 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.

workflow: app.Workflow | None = None#

The associated concrete workflow.