hpcflow.sdk.core.task.Task#
- class hpcflow.sdk.core.task.Task(schema, repeats=None, groups=None, resources=None, inputs=None, input_files=None, sequences=None, input_sources=None, nesting_order=None, env_preset=None, environments=None, allow_non_coincident_task_sources=False, element_sets=None, output_labels=None, sourceable_elem_iters=None, merge_envs=True)#
Bases:
JSONLike
Parametrisation of an isolated task for which a subset of input values are given “locally”. The remaining input values are expected to be satisfied by other tasks/imports in the workflow.
- Parameters:
schema (TaskSchema | list[TaskSchema]) – A (list of) TaskSchema object(s) and/or a (list of) strings that are task schema names that uniquely identify a task schema. If strings are provided, the TaskSchema object will be fetched from the known task schemas loaded by the app configuration.
groups (list[ElementGroup]) –
resources (dict) –
inputs (list[InputValue]) – A list of InputValue objects.
sequences (list[ValueSequence]) –
input_sources (dict[str, InputSource]) –
nesting_order (list) –
env_preset (str) –
allow_non_coincident_task_sources (bool) – If True, if more than one parameter is sourced from the same task, then allow these sources to come from distinct element sub-sets. If False (default), only the intersection of element sub-sets for all parameters are included.
element_sets (list[ElementSet]) –
output_labels (list[OutputLabel]) –
merge_envs (bool) – If True, merge environment presets (set via the element set env_preset key) into resources using the “any” scope. If False, these presets are ignored. This is required on first initialisation, but not on subsequent re-initialisation from a persistent workflow.
Methods
Add an element group to this task.
Get all the schema actions and their indices.
Make an instance of this class from JSON (or YAML) data.
For each input parameter of this task, generate a list of possible input sources that derive from inputs or outputs of this and other provided tasks.
Get a dict whose keys are normalised input paths (without the "inputs" prefix), and whose values are InputStatus objects.
Get the element set indices of this task for which a specified parameter type is locally provided.
Get the schema action at the given index.
Get the unique name of each in a list of tasks.
Check if an given input type must be specified in the parametrisation of this element set.
Set up the resolution of details of elements (especially multiplicities and how iterations are nested) within an element set.
Get all provided parameter labelled types and whether they are inputs and outputs, considering all element sets.
Set up parameters parsed by value sequences.
Serialize this object as a dictionary.
Serialize this object as an object structure that can be trivially converted to JSON.
Return a copy where any schema input defaults are saved to a persistent workflow.
Attributes
Normalised paths for all schema input types.
The set of all schema input types (over all specified schemas).
The inputs to this task's schemas.
The set of all schema output types (over all specified schemas).
The outputs from this task's schemas.
All the sourced normalised paths, including of sub-values.
The input types defined by this task.
Artefact directory name.
The element sets.
The index of this task within the workflow's tasks.
Insertion ID.
Task name.
Get input types for each schema that are non-universal.
The total number of schema actions.
The number of element sets.
The goal of this task.
The labels on the outputs of the task.
The single task schema, if only one, else raises.
All the task schemas.
The schema's input types that this task doesn't define.
The task's inputs that are undefined.
Get input types that are associated with all schemas
Whether to merge
environments
intoresources
using the "any" scope on first initialisation.The template workflow that this task is within.
- add_group(name, where, group_by_distinct)#
Add an element group to this task.
- Parameters:
name (str) –
where (ElementFilter) –
group_by_distinct (ParameterPath) –
- all_schema_actions()#
Get all the schema actions and their indices.
- property all_schema_input_normalised_paths#
Normalised paths for all schema input types.
- property all_schema_input_types#
The set of all schema input types (over all specified schemas).
- property all_schema_inputs: Tuple[SchemaInput]#
The inputs to this task’s schemas.
- property all_schema_output_types#
The set of all schema output types (over all specified schemas).
- property all_schema_outputs: Tuple[SchemaOutput]#
The outputs from this task’s schemas.
- property all_sourced_normalised_paths#
All the sourced normalised paths, including of sub-values.
- property defined_input_types#
The input types defined by this task.
- property dir_name#
Artefact directory name.
- property element_sets#
The element sets.
- 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.
- get_available_task_input_sources(element_set, source_tasks=None)#
For each input parameter of this task, generate a list of possible input sources that derive from inputs or outputs of this and other provided tasks.
Note this only produces a subset of available input sources for each input parameter; other available input sources may exist from workflow imports.
- Parameters:
element_set (ElementSet) –
source_tasks (List[WorkflowTask] | None) –
- Return type:
- get_input_statuses(elem_set)#
Get a dict whose keys are normalised input paths (without the “inputs” prefix), and whose values are InputStatus objects.
- Parameters:
elem_set (ElementSet) – The element set for which input statuses should be returned.
- Return type:
- get_param_provided_element_sets(labelled_path)#
Get the element set indices of this task for which a specified parameter type is locally provided.
- get_schema_action(idx)#
Get the schema action at the given index.
- static get_task_unique_names(tasks)#
Get the unique name of each in a list of tasks.
- property index#
The index of this task within the workflow’s tasks.
- property insert_ID#
Insertion ID.
- is_input_type_required(typ, element_set)#
Check if an given input type must be specified in the parametrisation of this element set.
A schema input need not be specified if it is only required to generate an input file, and that input file is passed directly.
- Parameters:
typ (str) –
element_set (ElementSet) –
- Return type:
- merge_envs#
Whether to merge
environments
intoresources
using the “any” scope on first initialisation.
- property name#
Task name.
- property non_universal_input_types#
Get input types for each schema that are non-universal.
- property num_element_sets#
The number of element sets.
- property objective#
The goal of this task.
- property output_labels#
The labels on the outputs of the task.
- prepare_element_resolution(element_set, input_data_indices)#
Set up the resolution of details of elements (especially multiplicities and how iterations are nested) within an element set.
- provides_parameters()#
Get all provided parameter labelled types and whether they are inputs and outputs, considering all element sets.
- property schema: TaskSchema#
The single task schema, if only one, else raises.
- property schemas: List[TaskSchema]#
All the task schemas.
- set_sequence_parameters(element_set)#
Set up parameters parsed by value sequences.
- 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.
- to_persistent(workflow, insert_ID)#
Return a copy where any schema input defaults are saved to a persistent workflow. Element set data is not made persistent.
- property undefined_input_types#
The schema’s input types that this task doesn’t define.
- property undefined_inputs#
The task’s inputs that are undefined.
- property universal_input_types#
Get input types that are associated with all schemas
- workflow_template#
The template workflow that this task is within.