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.
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.
- app = BaseApp(name='hpcFlow', version='0.2.0a181')#
- 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 (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:
- 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.
- merge_resources: bool | None = True#
Whether to merge template-level resources into element set resources.
- resources: Dict[str, Dict] | None = None#
Template-level resources to apply to all tasks as default values.
- 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.