tomyedwab opened a new issue #16764:
URL: https://github.com/apache/airflow/issues/16764


   **Apache Airflow version**: 2.0.1
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**: Various (GCP & local Python)
   - **OS** (e.g. from /etc/os-release): Various (linux, OSX)
   
   **What happened**:
   
   I read the following documentation about Task Groups:
   https://airflow.apache.org/docs/apache-airflow/stable/concepts/index.html
   https://www.astronomer.io/guides/task-groups
   
   From this documentation it seemed that dependencies between Task Groups are 
possible, which is a really nice feature for complex DAGs where adding a task 
to one group no longer involves updating the dependencies of tasks in 
downstream groups.
   
   I implemented a Task Group with dependency relationships to start and end 
dummy tasks. However when the DAG was run the start, end, and first task of the 
group all ran simultaneously. It took me a while to see what I was doing wrong, 
which was that I was adding the group dependencies *before* adding tasks to the 
group.
   
   One big source of confusion here is that the Graph View of the DAG does show 
connecting lines from the start/end tasks to the Task Group, so it __looks__ 
like there should be dependencies when there aren't any. The Tree View however 
shows no such dependencies.
   
   **What you expected to happen**:
   
   I would expect the Graph View to show the same dependencies as the Tree 
View, and not show dependencies that aren't actually there.
   
   My mental model from reading the documentation was that the dependencies 
were set on the group, whereas it seems as if the dependencies are actually set 
on whatever tasks happen to be in the group at the time the dependency is added.
   
   If this is indeed how Task Groups are intended to work it might be worth 
clarifying this somewhere in the documentation and not just rely on examples 
that do the right thing.
   
   **How to reproduce it**:
   
   Here is an example that shows what how my DAG was laid out:
   
   ```
   with DAG(
       'task_group_test',
       default_args=default_args,
       description='Task Group Test',
       start_date=datetime(2021, 7, 1),
       schedule_interval=None) as dag:
   
       start = DummyOperator(task_id='start')
       end = DummyOperator(task_id='end')
   
       with TaskGroup('tg') as taskgroup:
           start >> taskgroup >> end
   
           task1 = PythonOperator(task_id='hello1', 
python_callable=_print_hello)
           task2 = PythonOperator(task_id='hello2', 
python_callable=_print_hello)
           task1 >> task2
   ```
   
   Here is what I see in the Graph View:
   
![image](https://user-images.githubusercontent.com/1458589/124194614-bd804780-da7d-11eb-9568-dd3e69015288.png)
   
   Here is what I see in the Tree View:
   
![image](https://user-images.githubusercontent.com/1458589/124194659-d1c44480-da7d-11eb-8af1-70f18645e41d.png)
   
   If I move the `start >> taskgroup >> end` line below the `task1 >> task2` 
line the Graph View is exactly identical but the Tree View matches my 
expectation:
   
   
![image](https://user-images.githubusercontent.com/1458589/124194858-24056580-da7e-11eb-9ac2-0091165f3083.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to