I have a list of operators that were appended to a list in a for loop. I would like to set a relationship for my DAG where each task is set downstream in the order of the list. For example
JavaScript
x
10
10
1
task_list = []
2
for operator in operator_array:
3
task = operator
4
task_list.append(task)
5
6
# theoretically I would want something like this:
7
8
some_other_operator >> task_list[0] >> task_list[1] >> task_list[2] and so on and so forth for however long the length of the list is
9
10
Thank you
Advertisement
Answer
There’s a helper function created for that, will be much more performant than the accepted answer
See airflow.utils.helpers module
JavaScript
1
4
1
from airflow.utils.helpers import chain
2
3
chain(*task_list)
4