This is an automated email from the ASF dual-hosted git repository.

pierrejeambrun pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-3-test by this push:
     new 19cf2f33a07 [v3-3-test] Tidy taskgroup topo-sort tests; note why grid 
group_dict is uncached (#70590) (#70686)
19cf2f33a07 is described below

commit 19cf2f33a07cd0f9a3cf99cd7ceeea717ab38f06
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Jul 30 12:26:44 2026 +0200

    [v3-3-test] Tidy taskgroup topo-sort tests; note why grid group_dict is 
uncached (#70590) (#70686)
    
    (cherry picked from commit 2d9593160121039725376b6ca69783f7640cb0bf)
    
    Co-authored-by: Jason(Zhe-You) Liu 
<[email protected]>
---
 .../src/airflow/api_fastapi/core_api/routes/ui/grid.py        |  5 +++++
 airflow-core/tests/unit/utils/test_task_group.py              | 11 ++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py 
b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py
index 9bbe7e1dc03..1ee66c5f429 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py
@@ -200,6 +200,11 @@ def get_dag_structure(
     run_ids = list(session.scalars(dag_runs_select_filter))
 
     task_group_sort = get_task_group_children_getter()
+    # Built once per render and passed down, intentionally not 
memoized/LRU-cached: it is a
+    # derived view of a mutable task-group tree, so a cache would go stale 
with no invalidation
+    # and would pin the whole map for the group's lifetime, fighting the 
streaming/expunge below.
+    # It is released when the request returns (explicitly del-eted after the 
latest serdag is
+    # merged on the main path).
     latest_group_dict = latest_dag.task_group.get_task_group_dict()
     if not run_ids:
         nodes = [
diff --git a/airflow-core/tests/unit/utils/test_task_group.py 
b/airflow-core/tests/unit/utils/test_task_group.py
index e328c42ce01..452c302348a 100644
--- a/airflow-core/tests/unit/utils/test_task_group.py
+++ b/airflow-core/tests/unit/utils/test_task_group.py
@@ -1231,8 +1231,8 @@ def test_topological_group_dep_list_syntax():
         groups >> tg_a  # list-based dep — previously produced the wrong order
 
     order = [node.node_id for node in dag.task_group.topological_sort()]
-    a_idx = order.index("a")
-    assert all(order.index(f"b_{x}") < a_idx for x in range(3)), (
+    pos = {node_id: i for i, node_id in enumerate(order)}
+    assert all(pos[f"b_{x}"] < pos["a"] for x in range(3)), (
         f"Expected all b_x before a in topological order, got: {order!r}"
     )
 
@@ -1253,8 +1253,8 @@ def 
test_topological_sort_serialized_list_dep_between_groups():
 
     serialized = create_scheduler_dag(dag)
     order = [node.node_id for node in serialized.task_group.topological_sort()]
-    a_idx = order.index("a")
-    assert all(order.index(f"b_{x}") < a_idx for x in range(3)), (
+    pos = {node_id: i for i, node_id in enumerate(order)}
+    assert all(pos[f"b_{x}"] < pos["a"] for x in range(3)), (
         f"Expected all b_x before a in topological order, got: {order!r}"
     )
 
@@ -1280,8 +1280,9 @@ def 
test_topological_sort_serialized_task_level_cross_group_dep():
 
     serialized = create_scheduler_dag(dag)
     order = [node.node_id for node in serialized.task_group.topological_sort()]
+    pos = {node_id: i for i, node_id in enumerate(order)}
 
-    assert order.index("stage_b") < order.index("stage_a")
+    assert pos["stage_b"] < pos["stage_a"]
 
 
 def 
test_topological_sort_serialized_padded_reverse_chain_uses_pass_numbering(monkeypatch):

Reply via email to