hpcflow.sdk.core.task.TaskCondition#

class hpcflow.sdk.core.task.TaskCondition(source_task_ID, input_or_output, source_parameter, group_name=None, group_function=None)#

Bases: AppAware

An element-wise condition on the execution of a task.

Methods

from_string

Generate from a string.

test

Return True if the condition is met (meaning the task should execute), False if the condition is not met (meaning the task should not execute), and None if the condition is not valid for the provided run (i.e. the run does not belong to the source task referenced by source_task_ID).

test_group

Attributes

Parameters:
  • source_task_ID (int)

  • input_or_output (str)

  • source_parameter (str)

  • group_name (str | None)

  • group_function (str | None)

classmethod from_string(condition, workflow)#

Generate from a string.

Examples

The condition is met if the p1 output from task t1 is truthy: >>> TaskCondition.from_string(“tasks.t1.outputs.p1”, workflow) TaskCondition(…)

The condition is met if any values of the p1 output from task t1 in the group “my_group” are truthy:

>>> TaskCondition.from_string("tasks.t1.outputs.p1:any(my_group)", workflow)
TaskCondition(...)

The condition is met if all values of the p1 output from task t1 in the group “my_group” are truthy:

>>> TaskCondition.from_string("tasks.t1.outputs.p1:all(my_group)", workflow)
TaskCondition(...)
Parameters:
property get_path: str#
group_function: str | None = None#
group_name: str | None = None#
input_or_output: str#
source_parameter: str#
source_task_ID: int#
test(run, task_ID)#

Return True if the condition is met (meaning the task should execute), False if the condition is not met (meaning the task should not execute), and None if the condition is not valid for the provided run (i.e. the run does not belong to the source task referenced by source_task_ID).

Parameters:
  • run – The run whose source_parameter should be tested for truthiness.

  • task_ID (int) – The task ID of the task in which this condition is defined.

Return type:

bool | None

test_group(runs, task_ID)#
Parameters:

task_ID (int)

Return type:

bool | None