sjyangkevin commented on code in PR #74548:
URL: https://github.com/apache/airflow/pull/74548#discussion_r4241516911


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -1119,10 +1119,15 @@ def _collect_relatives(run_id: str, direction: 
Literal["upstream", "downstream"]
                 )
                 normal_task_ids.update(partial_dag.task_dict)
         else:
+            # Both directions must start from the requested tasks only. 
Merging upstream results
+            # before the downstream pass would also select every descendant of 
those upstream tasks.
+            relatives: set[str | tuple[str, int]] = set()
             if upstream:
-                _collect_relatives(dag_run_id, "upstream")
+                relatives.update(_find_relatives(dag_run_id, "upstream"))
             if downstream:
-                _collect_relatives(dag_run_id, "downstream")
+                relatives.update(_find_relatives(dag_run_id, "downstream"))
+            normal_task_ids.update(t for t in relatives if not isinstance(t, 
tuple))
+            mapped_tasks_tuples.update(t for t in relatives if isinstance(t, 
tuple))

Review Comment:
   Thanks for the review. Yes. Dags that contain a loop now take the new 
loop-aware clear path (select_loop_clear_scope), which also adds upstream 
relatives to the selection before collecting downstream ones, so it has the 
same issue. If I understand correctly, loop-aware seems to be a new feature, 
but correct me if me if I’m wrong. If the same behavior is expected,I can add 
that to this PR with compatibility handle.



-- 
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]

Reply via email to