rolfschleiss opened a new issue, #55305:
URL: https://github.com/apache/airflow/issues/55305
### Description
In the current Airflow Graph View, all TaskGroups are expanded by default
when a DAG is opened.
For very large DAGs, this makes the view cluttered and difficult to
navigate.
For smaller DAGs or selected TaskGroups, it is convenient to see the details
immediately.
It would be very helpful to have:
1. A DAG-level parameter to set the default collapse state for all
TaskGroups in that DAG.
2. A TaskGroup-level parameter to override the default for specific groups.
### Use case/motivation
- **Large DAGs**: collapsing TaskGroups by default improves readability and
reduces visual clutter.
- **Mixed DAGs**: some TaskGroups should start collapsed (big ones), while
others should stay expanded (small utility groups).
- This dual control (global default + per-group override) gives DAG authors
maximum flexibility.
### Proposed solution
Introduce:
- `taskgroup_collapsed` as an optional argument in the DAG constructor
(default = False).
- `collapsed` as an optional argument in `TaskGroup(...)` (default = None →
inherit from DAG setting).
#### Example
```python
from airflow import DAG
from airflow.utils.task_group import TaskGroup
from airflow.operators.empty import EmptyOperator
from datetime import datetime
with DAG(
dag_id="my_dag",
default_args={"owner": "airflow"},
start_date=datetime(2025, 1, 1),
schedule_interval="@daily",
taskgroup_collapsed=True, # NEW DAG-level default
) as dag:
# This group will be collapsed by default (inherits from DAG)
with TaskGroup(group_id="processing", tooltip="Data processing") as
processing:
t1 = EmptyOperator(task_id="start")
t2 = EmptyOperator(task_id="end")
t1 >> t2
# This group explicitly overrides the default
with TaskGroup(group_id="small", tooltip="Tiny group", collapsed=False)
as small_group:
EmptyOperator(task_id="only_task")
### Related issues
[AIP-38: Add Expand/Collapse all task groups
button](https://github.com/apache/airflow/issues/47429?utm_source=chatgpt.com)
– request for a global toggle in the UI.
[Task expand/collapse is intermittently available in grid
view](https://github.com/apache/airflow/issues/53919?utm_source=chatgpt.com)
– describes inconsistent collapse/expand behavior.
[Add UI collapse property to
TaskGroups](https://github.com/apache/airflow/issues/19773?utm_source=chatgpt.com)
– earlier proposal for a collapse initial state (closed but highly
relevant).
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]