Skip to content

Commit 406c835

Browse files
jschefflGitOps Bot
authored andcommitted
Use Task Display Name in Graph if existing (apache#56455)
1 parent 1afac1e commit 406c835

File tree

1 file changed

+5
-3
lines changed
  • airflow-core/src/airflow/api_fastapi/core_api/services/ui

1 file changed

+5
-3
lines changed

airflow-core/src/airflow/api_fastapi/core_api/services/ui/task_group.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ def get_task_group_children_getter() -> Callable:
4141
def task_group_to_dict(task_item_or_group, parent_group_is_mapped=False):
4242
"""Create a nested dict representation of this TaskGroup and its children used to construct the Graph."""
4343
if isinstance(task := task_item_or_group, (SerializedBaseOperator, MappedOperator)):
44+
# we explicitly want the short task ID here, not the full doted notation if in a group
45+
task_display_name = task.task_display_name if task.task_display_name != task.task_id else task.label
4446
node_operator = {
4547
"id": task.task_id,
46-
"label": task.label,
48+
"label": task_display_name,
4749
"operator": task.operator_name,
4850
"type": "task",
4951
}
@@ -55,7 +57,7 @@ def task_group_to_dict(task_item_or_group, parent_group_is_mapped=False):
5557
node_operator["is_mapped"] = True
5658
return node_operator
5759

58-
task_group = task_item_or_group
60+
task_group: TaskGroup = task_item_or_group
5961
mapped = is_mapped(task_group)
6062
children = [
6163
task_group_to_dict(child, parent_group_is_mapped=parent_group_is_mapped or mapped)
@@ -72,7 +74,7 @@ def task_group_to_dict(task_item_or_group, parent_group_is_mapped=False):
7274

7375
return {
7476
"id": task_group.group_id,
75-
"label": task_group.label,
77+
"label": task_group.group_display_name or task_group.label,
7678
"tooltip": task_group.tooltip,
7779
"is_mapped": mapped,
7880
"children": children,

0 commit comments

Comments
 (0)