pierrejeambrun commented on code in PR #56346:
URL: https://github.com/apache/airflow/pull/56346#discussion_r2445043927


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -745,16 +745,23 @@ def post_clear_task_instances(
 
     task_ids = body.task_ids
     if task_ids is not None:
-        task_id = [task[0] if isinstance(task, tuple) else task for task in 
task_ids]
-        dag = dag.partial_subset(
-            task_ids=task_id,
-            include_downstream=downstream,
-            include_upstream=upstream,
-        )
+        tasks = set(task_ids)
+        mapped_tasks = set([t for t in tasks if isinstance(t, tuple)])
+        # Unmapped tasks are expressed in their task_ids (without map_indexes)
+        unmapped_tid: set[str] = tasks - mapped_tasks  # type: 
ignore[assignment]
+
+        if upstream or downstream:
+            mapped_tid: set[str] = set([tid for tid, _ in mapped_tasks])

Review Comment:
   same here.



##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -745,16 +745,23 @@ def post_clear_task_instances(
 
     task_ids = body.task_ids
     if task_ids is not None:
-        task_id = [task[0] if isinstance(task, tuple) else task for task in 
task_ids]
-        dag = dag.partial_subset(
-            task_ids=task_id,
-            include_downstream=downstream,
-            include_upstream=upstream,
-        )
+        tasks = set(task_ids)
+        mapped_tasks = set([t for t in tasks if isinstance(t, tuple)])
+        # Unmapped tasks are expressed in their task_ids (without map_indexes)
+        unmapped_tid: set[str] = tasks - mapped_tasks  # type: 
ignore[assignment]

Review Comment:
   we should have an `s` there for plural.



##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -745,16 +745,23 @@ def post_clear_task_instances(
 
     task_ids = body.task_ids
     if task_ids is not None:
-        task_id = [task[0] if isinstance(task, tuple) else task for task in 
task_ids]
-        dag = dag.partial_subset(
-            task_ids=task_id,
-            include_downstream=downstream,
-            include_upstream=upstream,
-        )
+        tasks = set(task_ids)
+        mapped_tasks = set([t for t in tasks if isinstance(t, tuple)])
+        # Unmapped tasks are expressed in their task_ids (without map_indexes)
+        unmapped_tid: set[str] = tasks - mapped_tasks  # type: 
ignore[assignment]

Review Comment:
   This `type ignore` could be avoided.



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