jolly-florist-66728
10/17/2024, 12:08 PMconditional
construct from Flytekit. This allows you to define branches in your workflow based on conditions. Each branch must return a Promise
, and you need to specify both if
and else
branches to ensure the workflow has a defined execution path. 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_input: bool) -> str:
return (
conditional("ExampleCondition")
.if_(condition_input)
.then(task_a())
.else_()
.then(task_b())
)
This example demonstrates a simple conditional workflow where task_a
is executed if condition_input
is True
, otherwise task_b
is executed. Would you like more details?
Sources:
- Flyte Conditional Example
- Flyte Conditional Documentation
Slack Link
https://.slack.com/archives/CP2HDHKE1/p1729166900.136339 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.