hpcflow.app.Task#

class hpcflow.app.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: Task

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.

  • repeats (list[dict]) –

  • groups (list[ElementGroup]) –

  • resources (dict) –

  • inputs (list[InputValue]) – A list of InputValue objects.

  • input_files (list[InputFile]) –

  • sequences (list[ValueSequence]) –

  • input_sources (dict[str, InputSource]) –

  • nesting_order (list) –

  • env_preset (str) –

  • environments (dict[str, dict]) –

  • 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]) –

  • sourceable_elem_iters (list[int]) –

  • 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_group

Add an element group to this task.

all_schema_actions

Get all the schema actions and their indices.

from_json_like

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

get_available_task_input_sources

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_input_statuses

Get a dict whose keys are normalised input paths (without the "inputs" prefix), and whose values are InputStatus objects.

get_param_provided_element_sets

Get the element set indices of this task for which a specified parameter type is locally provided.

get_schema_action

Get the schema action at the given index.

get_task_unique_names

Get the unique name of each in a list of tasks.

is_input_type_required

Check if an given input type must be specified in the parametrisation of this element set.

prepare_element_resolution

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.

set_sequence_parameters

Set up parameters parsed by value sequences.

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.

to_persistent

Return a copy where any schema input defaults are saved to a persistent workflow.

Attributes

all_schema_input_normalised_paths

Normalised paths for all schema input types.

all_schema_input_types

The set of all schema input types (over all specified schemas).

all_schema_inputs

The inputs to this task's schemas.

all_schema_output_types

The set of all schema output types (over all specified schemas).

all_schema_outputs

The outputs from this task's schemas.

all_sourced_normalised_paths

All the sourced normalised paths, including of sub-values.

app

defined_input_types

The input types defined by this task.

dir_name

Artefact directory name.

element_sets

The element sets.

index

The index of this task within the workflow's tasks.

insert_ID

Insertion ID.

name

Task name.

non_universal_input_types

Get input types for each schema that are non-universal.

num_all_schema_actions

The total number of schema actions.

num_element_sets

The number of element sets.

objective

The goal of this task.

output_labels

The labels on the outputs of the task.

schema

The single task schema, if only one, else raises.

schemas

All the task schemas.

undefined_input_types

The schema's input types that this task doesn't define.

undefined_inputs

The task's inputs that are undefined.

universal_input_types

Get input types that are associated with all schemas

merge_envs

Whether to merge environments into resources using the "any" scope on first initialisation.

workflow_template

The template workflow that this task is within.

add_group(name, where, group_by_distinct)#

Add an element group to this task.

Parameters:
all_schema_actions()#

Get all the schema actions and their indices.

Return type:

Iterator[Tuple[int, Action]]

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.

app = BaseApp(name='hpcFlow', version='0.2.0a181')#
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:
Return type:

List[InputSource]

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:

Dict[str, InputStatus]

get_param_provided_element_sets(labelled_path)#

Get the element set indices of this task for which a specified parameter type is locally provided.

Parameters:

labelled_path (str) –

Return type:

List[int]

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.

Return type:

list of str

Parameters:

tasks (List[Task]) –

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:
Return type:

bool

merge_envs#

Whether to merge environments into resources 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_all_schema_actions: int#

The total number of schema actions.

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.

Return type:

Tuple[Tuple[str, str]]

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.