-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using TaskGroup without context manager (Graph view visual bug) #14864
Comments
Hi @ryanahamilton and @wolfier , I can explain why this is happening, but I'll need some suggestions from you and others on how to improve this.
The reproducing example is doing neither of these. Instead it's calling To fix this, you just need to use a contextmanager. Or do this: from airflow.models import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.dummy import DummyOperator
from airflow.utils.task_group import TaskGroup
from datetime import datetime
with DAG(dag_id="example_task_group", start_date=datetime(2021, 1, 1), tags=["example"], catchup=False) as dag:
start = BashOperator(task_id="start", bash_command='echo 1; sleep 10; echo 2;')
tg = TaskGroup("section_1", tooltip="Tasks for section_1")
task_1 = DummyOperator(task_id="task_1", task_group=tg)
task_2 = BashOperator(task_id="task_2", bash_command='echo 1', task_group=tg)
task_3 = DummyOperator(task_id="task_3", task_group=tg) Some ideas for improvement, not sure what's best:
|
We should definitely prevent adding task to more than 1 task group. |
Apache Airflow version: 2.0.0
Kubernetes version (if you are using kubernetes) (use
kubectl version
): n/aWhat happened:
![Screen Shot 2021-03-17 at 2 06 17 PM](https://user-images.githubusercontent.com/5952735/111544849-5939b200-8732-11eb-80dc-89c013aeb083.png)
When I do not use the context manager for the task group and instead call the add function to add the tasks, those tasks show up on the Graph view.
However, when I click on the task group item on the Graph UI, it will fix the issue. When I close the task group item, the tasks will not be displayed as expected.
![Screen Shot 2021-03-17 at 2 06 21 PM](https://user-images.githubusercontent.com/5952735/111544848-58a11b80-8732-11eb-928b-3c76207a0107.png)
What you expected to happen:
![Screen Shot 2021-03-17 at 3 17 34 PM](https://user-images.githubusercontent.com/5952735/111545824-eaf5ef00-8733-11eb-99c2-75b051bfefe1.png)
I expected the tasks inside the task group to not display on the Graph view.
How to reproduce it:
Render this DAG in Airflow
The text was updated successfully, but these errors were encountered: