hello everyone, how do i flatten/join a task of ta...
# ask-community
s
hello everyone, how do i flatten/join a task of tasks? let’s say i already have tasks a,b,c defined but i would like to group them as a task, perhaps because i want a conditional flow: for one branch i want to execute a,b,c in order, otherwise i want to execute d,e,f how do i go about this? without redefining a task which does what a,b,c/d,e,f already do?
e
The conditional task will skip
a
if the condition doesn't match. Skipping is propagated to downstream tasks, so skipping
a
skips
b
, which skips
c
. This means you can keep your tasks seperate, and still have a group of tasks execute conditionally.
Like this, maybe?
Copy code
with Flow("f") as f:
    true_tasks = f(e(d()))
    false_tasks = c(b(a()))
    ifelse(cond(), true_tasks, false_tasks)
    merge(true_tasks, false_tasks)
👍 1