hpcflow.sdk.core.workflow.WorkflowTemplate#
- class hpcflow.sdk.core.workflow.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:
JSONLike
Class to represent initial parametrisation of a {app_name} 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 (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 (Mapping[str, Mapping[str, Any]] | None) – The execution environments to use.
env_presets (str | list[str] | None) – The environment presets to use.
source_file (str | None) – The file this was derived from.
store_kwargs (dict[str, Any]) – Additional arguments to pass to the persistent data store constructor.
merge_resources (bool) – If True, merge template-level resources into element set resources. If False, template-level resources are ignored.
merge_envs (bool) – Whether to merge the environemtns into task resources.
Methods
Load from a JSON file.
Load from a JSON string.
Load from a YAML file.
Load from a YAML string.
Load from either a YAML or JSON file, depending on the file extension.
Make an instance of this class from JSON (or YAML) data.
Serialize this object as a dictionary.
Serialize this object as an object structure that can be trivially converted to JSON.
Attributes
Documentation information.
The environment presets to use.
The execution environments to use.
Whether to merge the environemtns into task resources.
Whether to merge template-level resources into element set resources.
Template-level resources to apply to all tasks as default values.
The file this was derived from.
The associated concrete workflow.
A string name for the workflow.
A list of Task objects to include in the workflow.
A list of Loop objects to include in the workflow.
Additional arguments to pass to the persistent data store constructor.
- classmethod from_JSON_file(path, variables=None)#
Load from a JSON file.
- Parameters:
- Return type:
- classmethod from_JSON_string(string, variables=None)#
Load from a JSON string.
- Parameters:
- Return type:
- classmethod from_YAML_file(path, variables=None)#
Load from a YAML file.
- Parameters:
- Return type:
- classmethod from_YAML_string(string, variables=None)#
Load from a YAML string.
- Parameters:
- Return type:
- 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 (Literal['yaml', 'json'] | 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:
- 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.
- resources: Resources = None#
Template-level resources to apply to all tasks as default values.
- store_kwargs: dict[str, Any]#
Additional arguments to pass to the persistent data store constructor.
- 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.