Skip to content

Setup/Teardown in nested Task Groups creating unwanted dependencies with downstream tasks #36345

@ardubev16

Description

@ardubev16

Apache Airflow version

2.8.0

If "Other Airflow 2 version" selected, which one?

No response

What happened?

The code below, in the "How to reproduce" section, produces the following DAG, I think there is an extra connection rendered between test_task and outer_end.
Screenshot from 2023-12-20 16-09-22

What you think should happen instead?

I would expect that middle_end is executed after test_group and, that outer_end is executed after test_group2. Since inner_end is a teardown task it is not considered a leaf of test_group, thus the only leaf of test_group is test_task. So, I would expect only the connection between test_task and middle_end, and not the connection between test_task and outer_end.

How to reproduce

Ddecorate the following function to become a DAG and call it to create the DAG:

def nesting_groups_test():
    @task
    def test_task():
        print("Hello world!")

    @task_group
    def test_group():
        inner_start = EmptyOperator(task_id="inner_start")
        inner_end = EmptyOperator(task_id="inner_end")

        test_task_r = test_task()
        inner_start >> test_task_r >> inner_end.as_teardown(setups=inner_start)

    @task_group
    def test_group2():
        middle_end = EmptyOperator(task_id="middle_end")
        test_group_r = test_group()
        test_group_r >> middle_end

    outer_start = EmptyOperator(task_id="outer_start")
    outer_end = EmptyOperator(task_id="outer_end")
    test_group2_r = test_group2()
    outer_start >> test_group2_r >> outer_end

Operating System

Ubuntu 22.04.3 LTS

Versions of Apache Airflow Providers

No response

Deployment

Docker-Compose

Deployment details

No response

Anything else?

This seems to be just a rendering issue since I've done some simple tests and the tasks have been executed in order, but I'm not 100% sure.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

area:corekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yet

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions