dheerajturaga commented on code in PR #56837:
URL: https://github.com/apache/airflow/pull/56837#discussion_r2443539718
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py:
##########
@@ -425,3 +427,52 @@ def get_node_sumaries():
"dag_id": dag_id,
"task_instances": filtered,
}
+
+
+@grid_router.post(
+ "/ti_summaries_batch/{dag_id}",
+ responses=create_openapi_http_exception_doc(
+ [
+ status.HTTP_400_BAD_REQUEST,
+ status.HTTP_404_NOT_FOUND,
+ ]
+ ),
+ dependencies=[
+ Depends(
+ requires_access_dag(
+ method="GET",
+ access_entity=DagAccessEntity.TASK_INSTANCE,
+ )
+ ),
+ Depends(
+ requires_access_dag(
+ method="GET",
+ access_entity=DagAccessEntity.RUN,
+ )
+ ),
+ ],
+)
+def get_grid_ti_summaries_batch(
+ dag_id: str,
+ run_ids: list[str],
Review Comment:
I updated my implementation to use pydantic
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py:
##########
@@ -425,3 +427,52 @@ def get_node_sumaries():
"dag_id": dag_id,
"task_instances": filtered,
}
+
+
+@grid_router.post(
+ "/ti_summaries_batch/{dag_id}",
+ responses=create_openapi_http_exception_doc(
+ [
+ status.HTTP_400_BAD_REQUEST,
+ status.HTTP_404_NOT_FOUND,
+ ]
+ ),
+ dependencies=[
+ Depends(
+ requires_access_dag(
+ method="GET",
+ access_entity=DagAccessEntity.TASK_INSTANCE,
+ )
+ ),
+ Depends(
+ requires_access_dag(
+ method="GET",
+ access_entity=DagAccessEntity.RUN,
+ )
+ ),
+ ],
+)
+def get_grid_ti_summaries_batch(
+ dag_id: str,
+ run_ids: list[str],
+ session: SessionDep,
+) -> GridTISummariesBatch:
+ """
+ Get task instance summaries for multiple DAG runs in a single request.
+
+ This endpoint is much more efficient than calling
/ti_summaries/{dag_id}/{run_id}
+ multiple times, as it fetches all task instances in a single database
query.
+ """
+ if not run_ids:
+ raise HTTPException(
+ status.HTTP_400_BAD_REQUEST,
+ "run_ids must not be empty",
+ )
+
+ if len(run_ids) > 100:
+ raise HTTPException(
+ status.HTTP_400_BAD_REQUEST,
+ "Cannot fetch more than 100 runs at once",
+ )
Review Comment:
Done!
--
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]