Conditional Sections
In order to support the functionality of an if-elif-else
clause within the body of a workflow, we introduce the method create_conditional_section
. This method creates a new conditional section in a workflow, allowing a user to conditionally execute a task based on the value of a task result.
Conditional sections are akin to ternary operators — they return the output of the branch result. However, they can be n-ary with as many elif clauses as desired.
It is possible to consume the outputs from conditional nodes. And to pass in outputs from other tasks to conditional nodes.
The boolean expressions in the condition use &
and |
as and / or operators. Additionally, binary expressions are not allowed. Thus if a task returns a boolean and we wish to use it in a condition of a conditional block, we must use built in truth checks: result.is_true()
or result.is_false()