Cornelis Boon
03/11/2024, 2:17 PM@workflow
def conditional_dependency_wf(condition1: bool, condition2: bool):
init_data = get_initial_task()
conditional_promise1 = (
conditional("if-cond1")
.if_(condition1.is_true())
.then( task1(data=init_data))
)
conditional_promise2 = (
conditional("if-cond2")
.if_(condition2.is_true())
.then( task2(data=init_data))
)
conditional_promise1 >> conditional_promise2
Without having to nest them 🙂 I feel this should be possible given these examples:
https://docs.flyte.org/en/latest/user_guide/advanced_composition/conditionals.html#using-the-output-of-a-previous-task-in-a-conditionalCornelis Boon
03/11/2024, 2:20 PMunsupported operand type(s) for >>: 'Condition' and 'Condition'
errorCornelis Boon
03/11/2024, 2:36 PMif_
cases and an else_
. To get around it, I specify a task that just does nothing for the else_ part. something like
@task
def _else():
...
and the workflow then becomes:
@workflow
def conditional_dependency_wf(condition1: bool, condition2: bool):
init_data = get_initial_task()
conditional_promise1 = (
conditional("if-cond1")
.if_(condition1.is_true())
.then( task1(data=init_data)).else_().then(_else())
)
conditional_promise2 = (
conditional("if-cond2")
.if_(condition2.is_true())
.then( task2(data=init_data)).else_().then(_else())
)
conditional_promise1 >> conditional_promise2
Kevin Su
03/11/2024, 6:12 PMSlackbot
03/11/2024, 6:12 PMCornelis Boon
03/11/2024, 6:18 PMget_initial_task()
is drawn on a parallel path from the condition, even though the "if" branch of the conditional is dependent on the output of the first task.
Don't have a screenshot as I'm setting up the cluster again, but it looked like this:
start -> init_task -> end
\-> [startcond] -> if_cond1 [endcond] ->/
\-> else ->/
Cornelis Boon
03/11/2024, 6:19 PMget_initial_task
and is drawn on a separate path from start to end than the conditional. I would expect the get_initial_task
to be drawn before the conditional, with two branches in the conditional both pointing to the end.Cornelis Boon
03/11/2024, 10:05 PMdownload_jpeg
to be in front of or at least have an edge going out to if_lpr
which is the conditionalCornelis Boon
03/12/2024, 11:43 AM