matflow.TaskSchema#

class matflow.TaskSchema(objective, actions=None, method=None, implementation=None, inputs=None, outputs=None, version=None, parameter_class_modules=None, web_doc=True, environment_presets=None, doc='', parameter_dependencies=None, save_files=None, _hash_value=None, disable_array_outputs=None)#

Bases: TaskSchema

Class to represent the inputs, outputs and implementation mechanism of a given task.

Parameters:
  • objective (TaskObjective | str) – This is a string representing the objective of the task schema.

  • actions (list[Action] | None) – A list of Action objects whose commands are to be executed by the task.

  • method (str | None) – An optional string to label the task schema by its method.

  • implementation (str | None) – An optional string to label the task schema by its implementation.

  • inputs (list[Parameter | SchemaInput] | None) – A list of SchemaInput objects that define the inputs to the task.

  • outputs (list[Parameter | SchemaParameter] | None) – A list of SchemaOutput objects that define the outputs of the task.

  • version (str | None) – The version of this task schema.

  • parameter_class_modules (list[str] | None) – Where to find implementations of parameter value handlers.

  • web_doc (bool | None) – True if this object should be included in the Sphinx documentation (normally only relevant for built-in task schemas). True by default.

  • environment_presets (Mapping[str, Mapping[str, Mapping[str, Any]]] | None) – Information about default execution environments. Can be overridden in specific cases in the concrete tasks.

  • disable_array_outputs (list[str] | None) – A list of dot-delimited output parameter paths, relative to the outputs namespace, to store only in legacy Zarr groups. The outputs. prefix is optional. Containing parameter paths disable all nested arrays. By default EAR output ndarrays use Zstandard-compressed NPZ instead of legacy Zarr groups, with up to 500 archives per shard directory. This is a temporary storage workaround specific to the Zarr store.

  • save_files (bool | list[str] | None) – Files to retain as workflow artifacts. True retains all declared files, False or None (default) retains none, and a list retains the listed declared file labels plus any path:-prefixed working-directory paths (which may include glob patterns). Files required by downstream tasks are always retained. Tasks may override this policy.

  • doc (str) –

  • parameter_dependencies (Sequence[str] | None) –

  • _hash_value (str | None) –

Methods

add_parameter_dependency

Add a explicit parameter dependency to the schema and each of its actions.

from_json_like

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

get_action_parameter_flow

For each parameter that appears within the actions of this task schema, get the ordered source and sink action indices (where it is an output and input).

get_by_key

Get a config-loaded task schema from a key.

get_file_labels

Get the labels of files declared by this schema's actions.

get_info_html

Describe the task schema as an HTML document.

get_key

Get the hashable value that represents this schema.

get_output_indices

Get stable indices of schema outputs within their parent action; and those of action outputs, input files, and output files within their parent action.

get_parameter_dependence

Find if/where a given parameter is used by the schema's actions.

ignore_invalid_actions

A context manager within which invalid actions will be ignored.

make_persistent

Convert this task schema to persistent form within the context of the given workflow.

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

full_info

Show inputs, outputs, and actions, formatted in a table.

info

Show inputs and outputs, formatted in a table.

input_type_labels_map

A map between input types and their associated labelled types.

input_types

The input types to the schema.

multi_input_types

Get a list of input types that have multiple labels.

name

The name of this schema.

output_types

The output types from the schema.

provides_parameters

The parameters that this schema provides.

task_template

The template that this schema is contained in.

objective

This is a string representing the objective of the task schema.

actions

A list of Action objects whose commands are to be executed by the task.

method

An optional string to label the task schema by its method.

implementation

An optional string to label the task schema by its implementation.

inputs

A list of SchemaInput objects that define the inputs to the task.

outputs

A list of SchemaOutput objects that define the outputs of the task.

parameter_class_modules

Where to find implementations of parameter value handlers.

web_doc

Whether this object should be included in the Sphinx documentation (normally only relevant for built-in task schemas).

environment_presets

Information about default execution environments.

doc

Documentation information about the task schema.

disable_array_outputs

Output paths excluded from the temporary NPZ array storage workaround.

version

The version of this task schema.

actions#

A list of Action objects whose commands are to be executed by the task.

add_parameter_dependency(param, group_name=None)#

Add a explicit parameter dependency to the schema and each of its actions.

Parameters:
  • param (str) –

  • group_name (str | None) –

disable_array_outputs#

Output paths excluded from the temporary NPZ array storage workaround.

doc#

Documentation information about the task schema.

environment_presets#

Information about default execution environments.

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.

property full_info: None#

Show inputs, outputs, and actions, formatted in a table.

get_action_parameter_flow()#

For each parameter that appears within the actions of this task schema, get the ordered source and sink action indices (where it is an output and input).

An action index of -1 within the “sources” list indicates that parameter is an input from the schema (i.e. parametrised in the element set); an action index of -1 within the “sinks” list indicates that parameter is an output of the schema.

Return type:

dict[str, dict[str, list[int]]]

classmethod get_by_key(key)#

Get a config-loaded task schema from a key.

Parameters:

key (str) –

Return type:

TaskSchema

get_file_labels()#

Get the labels of files declared by this schema’s actions.

Return type:

set[str]

get_info_html()#

Describe the task schema as an HTML document.

Return type:

str

get_key()#

Get the hashable value that represents this schema.

Return type:

tuple

get_output_indices()#

Get stable indices of schema outputs within their parent action; and those of action outputs, input files, and output files within their parent action. These mappings can be used by the persistent store.

Note that for output file parser actions where we pass a schema output in, we will end up with a index slot for that output parameter even though it is not actually an output of the action, and so no slot is required.

Return type:

tuple[dict[str, int], dict[int, dict[str, int]]]

get_parameter_dependence(parameter)#

Find if/where a given parameter is used by the schema’s actions.

Parameters:

parameter (SchemaParameter) –

Return type:

ActParameterDependence

classmethod ignore_invalid_actions()#

A context manager within which invalid actions will be ignored.

Return type:

Iterator[None]

implementation#

An optional string to label the task schema by its implementation.

property info: None#

Show inputs and outputs, formatted in a table.

property input_type_labels_map: dict[str, tuple[str, ...]]#

A map between input types and their associated labelled types.

property input_types: list[str]#

The input types to the schema.

inputs#

A list of SchemaInput objects that define the inputs to the task.

make_persistent(workflow, source)#

Convert this task schema to persistent form within the context of the given workflow.

Parameters:
  • workflow (Workflow) –

  • source (ParamSource) –

Return type:

list[int | list[int]]

method#

An optional string to label the task schema by its method.

property multi_input_types: list[str]#

Get a list of input types that have multiple labels.

property name: str#

The name of this schema.

objective#

This is a string representing the objective of the task schema.

property output_types: list[str]#

The output types from the schema.

outputs#

A list of SchemaOutput objects that define the outputs of the task.

parameter_class_modules#

Where to find implementations of parameter value handlers.

property provides_parameters: Iterator[tuple[Literal['input', 'output'], str]]#

The parameters that this schema provides.

property task_template: TaskTemplate | None#

The template that this schema is contained in.

to_dict()#

Serialize this object as a dictionary.

Return type:

dict[str, Any]

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.

Parameters:
  • dct (dict[str, JSONable] | None) –

  • shared_data (_JSONDeserState) –

  • exclude (Container[str | None]) –

  • path (list | None) –

Return type:

tuple[JSONDocument, _JSONDeserState]

version#

The version of this task schema.

web_doc#

Whether this object should be included in the Sphinx documentation (normally only relevant for built-in task schemas).