Skip to content

[v3-3-test] Fix grid/graph view topological sort for group-level and cross-group dependencies (#69933) - #70591

Merged
pierrejeambrun merged 1 commit into
apache:v3-3-testfrom
jason810496:backport-d7aa929-v3-3-test
Jul 28, 2026
Merged

[v3-3-test] Fix grid/graph view topological sort for group-level and cross-group dependencies (#69933)#70591
pierrejeambrun merged 1 commit into
apache:v3-3-testfrom
jason810496:backport-d7aa929-v3-3-test

Conversation

@jason810496

Copy link
Copy Markdown
Member
  • Fix grid/graph view topological sort for group-level and cross-group deps

TaskGroup._project_child_deps only looked at a group's own upstream_task_ids, which stays empty for a direct group-to-group dependency (list or individual >>) and for a task-level dependency that crosses into another group's entry task. Both cases sorted the group as if it had no upstream at all.

Now also pulls in the group's upstream_group_ids and its root tasks' upstream task ids before projecting sibling dependencies. Applied to both the serialization-layer sort and the mirrored design-time sort in task-sdk.

closes: #65291

Related: #67964 (closed for inactivity, written against the topological_sort implementation before PR #67288/#67688 rewrote it) and #65639 (draft, same issue, also predates the rewrite).

  • Address review feedback: cache get_task_group_dict, describe test intent not issue numbers

viiccwen pointed out that fetching the group map inside topological_sort() rebuilds the whole DAG's group tree on every nested group's own call, turning a render with G groups into an O(G^2) cost. get_task_group_dict() is now memoized per DAG instance (kept behind a small private helper since methodtools.lru_cache has no type stubs and would otherwise widen the public method's return type to Any for every caller).

Also reworded test comments/docstrings that cited issue numbers to describe what's actually being verified instead.

  • Hoist common logic into shared lib

  • Remove caching on get_task_group_dict

  • Remove stale get_task_group_dict cache tests

The cache these tests asserted was removed in the previous commit, so the identity check and the _get_task_group_dict_cached.cache_info() assertions no longer apply.

  • Add call-level task group memo to reduce calc

  • Tidy Typy

  • Add test for task group memoing


Co-authored-by: TP uranusjr@apache.org
Co-authored-by: LIU ZHE YOU zhu424.dev@gmail.com
(cherry picked from commit d7aa929)

…dependencies (apache#69933)

* Fix grid/graph view topological sort for group-level and cross-group deps

TaskGroup._project_child_deps only looked at a group's own upstream_task_ids,
which stays empty for a direct group-to-group dependency (list or individual
`>>`) and for a task-level dependency that crosses into another group's entry
task. Both cases sorted the group as if it had no upstream at all.

Now also pulls in the group's upstream_group_ids and its root tasks' upstream
task ids before projecting sibling dependencies. Applied to both the
serialization-layer sort and the mirrored design-time sort in task-sdk.

closes: apache#65291

Related: apache#67964 (closed for inactivity, written against the
topological_sort implementation before PR apache#67288/apache#67688 rewrote it) and
apache#65639 (draft, same issue, also predates the rewrite).

* Address review feedback: cache get_task_group_dict, describe test intent not issue numbers

viiccwen pointed out that fetching the group map inside topological_sort() rebuilds
the whole DAG's group tree on every nested group's own call, turning a render with
G groups into an O(G^2) cost. get_task_group_dict() is now memoized per DAG instance
(kept behind a small private helper since methodtools.lru_cache has no type stubs and
would otherwise widen the public method's return type to Any for every caller).

Also reworded test comments/docstrings that cited issue numbers to describe what's
actually being verified instead.

* Hoist common logic into shared lib

* Remove caching on get_task_group_dict

* Remove stale get_task_group_dict cache tests

The cache these tests asserted was removed in the previous commit, so the
identity check and the _get_task_group_dict_cached.cache_info() assertions
no longer apply.

* Add call-level task group memo to reduce calc

* Tidy Typy

* Add test for task group memoing

---------

Co-authored-by: TP <uranusjr@apache.org>
Co-authored-by: LIU ZHE YOU <zhu424.dev@gmail.com>
(cherry picked from commit d7aa929)

# Conflicts:
#	airflow-core/src/airflow/api_fastapi/core_api/services/ui/task_group.py
@pierrejeambrun
pierrejeambrun merged commit ff75d24 into apache:v3-3-test Jul 28, 2026
115 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants