I am trying to accomplish the following based on Airflow 2.3 (referencing below pseudo code):
- I am reading a list of items using an Operator (operator_1)
- For every item of the list I want to schedule a task group of two Operators (operator_2_1 and operator_2_2) that are supposed to run one after another
- If there is more than one item in the list, then only one task group must be executed at a time (no parallel execution)
with DAG(
...
) as dag:
# Must be executed once
operator_1 = SomeOperator(...) # returns a list of items
# Must be executed "once per item" and only one at a time
task_group(items)
operator_2_1 = SomeOtherOperator(...)
operator_2_2 = SomeOtherOperator(...)
task_group.expand(operator_1)
What I tried so far:
- Iterate over the list of items and schedule a task group per item (without using dynamic tasks): Works, but the unwanted parallel execution is a problem
- Using dynamic tasks, which seems to work only for tasks (but not for task groups)
I would appreciate any input on this!
Thank you in advance!