Skip to content

Commit

Permalink
Fix wrong update for nested group default args (#31776)
Browse files Browse the repository at this point in the history
Signed-off-by: Hussein Awala <[email protected]>
(cherry picked from commit 8891c69)
  • Loading branch information
hussein-awala authored and Elad Kalif committed Jun 8, 2023
1 parent aeb4ef3 commit 8f34397
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion airflow/utils/task_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _check_for_group_id_collisions(self, add_suffix_on_collision: bool):

def _update_default_args(self, parent_group: TaskGroup):
if parent_group.default_args:
self.default_args = {**self.default_args, **parent_group.default_args}
self.default_args = {**parent_group.default_args, **self.default_args}

@classmethod
def create_root(cls, dag: DAG) -> TaskGroup:
Expand Down
9 changes: 7 additions & 2 deletions tests/utils/test_task_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,11 +1368,16 @@ def test_override_dag_default_args_in_multi_level_nested_tg():
"execution_timeout": timedelta(seconds=10),
},
):
with TaskGroup(group_id="first_nested_task_group"):
with TaskGroup(
group_id="first_nested_task_group",
default_args={
"owner": "z",
},
):
with TaskGroup(group_id="second_nested_task_group"):
with TaskGroup(group_id="third_nested_task_group"):
task = EmptyOperator(task_id="task")

assert task.retries == 1
assert task.owner == "y"
assert task.owner == "z"
assert task.execution_timeout == timedelta(seconds=10)

0 comments on commit 8f34397

Please sign in to comment.