acoustic-parrot-22802
04/27/2025, 9:08 AMjolly-florist-66728
04/27/2025, 9:08 AMconditional
construct provided by Flytekit. This allows you to define branches in your workflow that execute different tasks based on the evaluation of conditions. Here's a basic example:
from flytekit import task, workflow, conditional
@task
def task_a() -> str:
return "Task A executed"
@task
def task_b() -> str:
return "Task B executed"
@workflow
def my_workflow(condition: bool) -> str:
return (
conditional("ExampleCondition")
.if_(condition)
.then(task_a())
.else_()
.then(task_b())
)
In this example, task_a
will be executed if the condition
is True
, otherwise task_b
will be executed. The conditional
construct ensures that only one branch is executed based on the condition provided.
Would you like more detail on how to implement this or explore more complex conditional logic?
Sources:
- Conditionals in Flyte 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.