hpcflow.sdk.core.loop.Loop#

class hpcflow.sdk.core.loop.Loop(tasks, num_iterations, name=None, non_iterable_parameters=None, termination=None)#

Bases: JSONLike

A loop in a workflow template.

Parameters:
  • tasks (list[int | WorkflowTask]) – List of task insert IDs or workflow tasks.

  • num_iterations (int) – Number of iterations to perform.

  • name (str) – Loop name.

  • non_iterable_parameters (list[str]) – Specify input parameters that should not iterate.

  • termination (v~hpcflow.app.Rule) – Stopping criterion, expressed as a rule.

Methods

from_json_like

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

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

name

The name of the loop, if one was provided.

non_iterable_parameters

Which parameters are not iterable.

num_iterations

The number of loop iterations to do.

task_insert_IDs

Get the list of task insert_IDs that define the extent of the loop.

task_objects

The tasks in the loop.

termination

A termination rule for the loop, if one is provided.

workflow_template

The workflow template that contains this loop.

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 name: str | None#

The name of the loop, if one was provided.

property non_iterable_parameters: Sequence[str]#

Which parameters are not iterable.

property num_iterations: int#

The number of loop iterations to do.

property task_insert_IDs: tuple[int, ...]#

Get the list of task insert_IDs that define the extent of the loop.

property task_objects: tuple[WorkflowTask, ...]#

The tasks in the loop.

property termination: Rule | None#

A termination rule for the loop, if one is provided.

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]

property workflow_template: WorkflowTemplate | None#

The workflow template that contains this loop.