guan404ming commented on code in PR #51850:
URL: https://github.com/apache/airflow/pull/51850#discussion_r2267525139
##########
airflow-core/src/airflow/api_fastapi/core_api/services/public/task_instances.py:
##########
@@ -262,21 +262,74 @@ def handle_bulk_delete(
self, action: BulkDeleteAction[BulkTaskInstanceBody], results:
BulkActionResponse
) -> None:
"""Bulk delete task instances."""
- to_delete_task_keys = set((task_id, -1) for task_id in action.entities)
- _, matched_task_keys, not_found_task_keys =
self.categorize_task_instances(to_delete_task_keys)
- not_found_task_ids = [task_id for task_id, _ in not_found_task_keys]
+ delete_all_map_indexes: set[str] = set()
+ delete_specific_task_keys: set[tuple[str, int]] = set()
+
+ for entity in action.entities:
+ if isinstance(entity, str):
+ # String task ID - targets the non-mapped task instance
(map_index = -1 in DB)
+ delete_specific_task_keys.add((entity, -1))
+ else:
+ # BulkTaskInstanceBody object
+ task_id = entity.task_id
+ if entity.map_index == -1:
+ delete_all_map_indexes.add(task_id)
+ else:
+ db_map_index = -1 if entity.map_index is None else
entity.map_index
+ delete_specific_task_keys.add((task_id, db_map_index))
Review Comment:
It makes sense to me to remain the backward compatibility and also thanks
for the clear hint. I've updated related implementation and tests.
--
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]