gentle-tomato-480
02/27/2025, 10:43 AMresults = (
conditional("if-flag")
.if_(flag.is_true())
.then((
out1 = task1(input1),
task2(out1)
))
.else_().then(noop())
)
Currently I pass a workflow that looks like this into my conditional and it works fine:
@workflow
def my_sub_workflow(input1, input2):
out1 = task1(input1)
out2 = task2(input2)
out3 = task3(out1, out2)
@workflow
def main_workflow(input1, flag):
input2 = another_task(input1)
(
conditional("if-flag")
.if_(flag.is_true())
.then(my_sub_workflow(input1, input2, flag))
.else_().then(noop())
)
However as you can see task1
which I do want to execute conditionally with the rest of the tasks in the subworkflow depends only on input1
(which is available at the start of the execution). But task1
has to wait until the input2
is available after another_task
has run and the subworkflow has kicked off. task1
is also generally a longer running task than task2
so it would be beneficial to start it as soon as possible so that it completes by the time task2
is done.
So A) is the former possible, and more importantly, B) Is there a better way to organize the tasks so that task1
can start earlier without having to wait for the subworkflow to start?gentle-tomato-480
02/27/2025, 10:54 AMCannot pass output from task n2 that produces no outputs to a downstream task
):
noop = Echo(name="noop")
@workflow
def main_workflow(input1, flag):
input2 = another_task(input1)
out1 = (
conditional("if-flag1")
.if_(flag.is_true())
.then(task1(input1))
.else_().then(noop())
)
out2 = (
conditional("if-flag2")
.if_(flag.is_true())
.then(task2(input2))
.else_().then(noop())
)
out3 = (
conditional("if-flag3")
.if_(flag.is_true())
.then(task3(out1, out2))
.else_().then(noop())
)
I understnd that that is due to that there is a chance (even if the flags for each conditional are the same...) 🤔 Perhaps if I update my noop
to return some value it would workgentle-tomato-480
02/27/2025, 11:09 AMFlyteDirectory
and I'm not sure you can mock/Echo a FlyteDirectory
output, can you?
EDIT: You can. Seems like I might have a way forward then, albeit ugly a bit ugly with more conditionals when really it is one conditionalgentle-tomato-480
02/27/2025, 11:11 AM_else
branch. Then flyte will compile and run it.gentle-tomato-480
02/27/2025, 11:34 AMcareful-australia-19356
03/13/2025, 6:07 PMgentle-tomato-480
03/13/2025, 8:50 PM