I have a (maybe silly) question. Is it expected th...
# ask-community
m
I have a (maybe silly) question. Is it expected that when mapping tasks, the flow exists when the first element of the map succeeds (i.e. the first branch of the reference task)? That seems to be what’s happening to me, but perhaps I’ve missed an implementation detail. As a followup, if I want to wait for all mapped results, do I have to make the final reference task a reduction over upstream mapped results?
To clarify, I have something like this:
Copy code
my_task_1 = MyTask1()
my_task_1.set_upstream(previous_task)
my_task_1.set_upstream([True, False], key="param_1", mapped=True)
my_task_1.set_upstream([1, 2, 3], key="param_2", mapped=True)
my_task_1.set_upstream("hello", key="param_3")

my_task_2 = MyTask2()
my_task_2.set_upstream(my_task_1, key="prev_task_output", mapped=True)
and it seems like my flow exists once tasks 1 and 2 have completed for
param_1=True
and
param_2=1
. I never see MyTask1 run for the other param combinations
Hmm, ok so actually the problem is that I have two params I want to map over, but these two params can have differing numbers of values to map over. I was assuming that setting each param to map would result in a cartesian product over all param combinations. Is there a nice way to do this? E.g. in the example above there should be 6 difference task runs
k
Hey @Michael, no silly questions. 🙂. I think there are two things here. First is that you need to make the cartesian product yourself in other task. Having two mapped parameters [1,2,3] and [a,b,c] will just have three combinations of (1,a). (2,b), (3,c). You can maybe pass [a,b,c] as an
unmapped
and then loop over it in side the task. The second thing (less sure if you are facing this one) is that if you want breadth first execution, you can try doing
my_task_2.set_upstream(unmapped(my_task_1))
so that all of
my_task_1
completes before
my_task_2