diff --git a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml index cfda8d3f26e0b..a33004cdedfcb 100644 --- a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml +++ b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml @@ -3951,75 +3951,6 @@ paths: schema: type: string title: Task Id - - name: map_index - in: query - required: false - schema: - type: integer - default: -1 - title: Map Index - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/TaskInstanceHistoryCollectionResponse' - '401': - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPExceptionResponse' - description: Unauthorized - '403': - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPExceptionResponse' - description: Forbidden - '404': - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPExceptionResponse' - description: Not Found - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - /public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/tries: - get: - tags: - - Task Instance - summary: Get Mapped Task Instance Tries - operationId: get_mapped_task_instance_tries - parameters: - - name: dag_id - in: path - required: true - schema: - type: string - title: Dag Id - - name: dag_run_id - in: path - required: true - schema: - type: string - title: Dag Run Id - - name: task_id - in: path - required: true - schema: - type: string - title: Task Id - - name: map_index - in: path - required: true - schema: - type: integer - title: Map Index responses: '200': description: Successful Response diff --git a/airflow/api_fastapi/core_api/routes/public/task_instances.py b/airflow/api_fastapi/core_api/routes/public/task_instances.py index b6118a7d5348c..f2bab41d06117 100644 --- a/airflow/api_fastapi/core_api/routes/public/task_instances.py +++ b/airflow/api_fastapi/core_api/routes/public/task_instances.py @@ -17,7 +17,7 @@ from __future__ import annotations -from typing import Annotated, Literal +from typing import Annotated, Literal, cast from fastapi import Depends, HTTPException, Request, status from sqlalchemy.orm import Session, joinedload @@ -245,9 +245,9 @@ def get_task_instance_tries( dag_run_id: str, task_id: str, session: Annotated[Session, Depends(get_session)], - map_index: int = -1, ) -> TaskInstanceHistoryCollectionResponse: """Get list of task instances history.""" + map_index = -1 def _query(orm_object: Base) -> Select: query = select(orm_object).where( @@ -262,43 +262,20 @@ def _query(orm_object: Base) -> Select: tis = session.scalars( _query(TI).where(or_(TI.state != TaskInstanceState.UP_FOR_RETRY, TI.state.is_(None))) ).all() - task_instance_select = session.scalars(_query(TIH)).all() + tis + task_instances = session.scalars(_query(TIH)).all() + tis - if not task_instance_select: + if not task_instances: raise HTTPException( status.HTTP_404_NOT_FOUND, f"The Task Instance with dag_id: `{dag_id}`, run_id: `{dag_run_id}`, task_id: `{task_id}` and map_index: `{map_index}` was not found", ) - task_instances = [ - TaskInstanceHistoryResponse.model_validate(task_instance, from_attributes=True) - for task_instance in task_instance_select - ] + return TaskInstanceHistoryCollectionResponse( - task_instances=task_instances, + task_instances=cast(list[TaskInstanceHistoryResponse], task_instances), total_entries=len(task_instances), ) -@task_instances_router.get( - task_instances_prefix + "/{task_id}/{map_index}/tries", - responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]), -) -def get_mapped_task_instance_tries( - dag_id: str, - dag_run_id: str, - task_id: str, - session: Annotated[Session, Depends(get_session)], - map_index: int, -) -> TaskInstanceHistoryCollectionResponse: - return get_task_instance_tries( - dag_id=dag_id, - dag_run_id=dag_run_id, - task_id=task_id, - map_index=map_index, - session=session, - ) - - @task_instances_router.get( task_instances_prefix + "/{task_id}/{map_index}", responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]), diff --git a/airflow/ui/openapi-gen/queries/common.ts b/airflow/ui/openapi-gen/queries/common.ts index 894aa4966673c..25c7fb80b08ee 100644 --- a/airflow/ui/openapi-gen/queries/common.ts +++ b/airflow/ui/openapi-gen/queries/common.ts @@ -1102,43 +1102,16 @@ export const UseTaskInstanceServiceGetTaskInstanceTriesKeyFn = ( { dagId, dagRunId, - mapIndex, taskId, }: { dagId: string; dagRunId: string; - mapIndex?: number; taskId: string; }, queryKey?: Array, ) => [ useTaskInstanceServiceGetTaskInstanceTriesKey, - ...(queryKey ?? [{ dagId, dagRunId, mapIndex, taskId }]), -]; -export type TaskInstanceServiceGetMappedTaskInstanceTriesDefaultResponse = - Awaited>; -export type TaskInstanceServiceGetMappedTaskInstanceTriesQueryResult< - TData = TaskInstanceServiceGetMappedTaskInstanceTriesDefaultResponse, - TError = unknown, -> = UseQueryResult; -export const useTaskInstanceServiceGetMappedTaskInstanceTriesKey = - "TaskInstanceServiceGetMappedTaskInstanceTries"; -export const UseTaskInstanceServiceGetMappedTaskInstanceTriesKeyFn = ( - { - dagId, - dagRunId, - mapIndex, - taskId, - }: { - dagId: string; - dagRunId: string; - mapIndex: number; - taskId: string; - }, - queryKey?: Array, -) => [ - useTaskInstanceServiceGetMappedTaskInstanceTriesKey, - ...(queryKey ?? [{ dagId, dagRunId, mapIndex, taskId }]), + ...(queryKey ?? [{ dagId, dagRunId, taskId }]), ]; export type TaskInstanceServiceGetMappedTaskInstanceDefaultResponse = Awaited< ReturnType diff --git a/airflow/ui/openapi-gen/queries/prefetch.ts b/airflow/ui/openapi-gen/queries/prefetch.ts index a2d8b0c50d075..4de065894e022 100644 --- a/airflow/ui/openapi-gen/queries/prefetch.ts +++ b/airflow/ui/openapi-gen/queries/prefetch.ts @@ -1454,7 +1454,6 @@ export const prefetchUseTaskInstanceServiceGetTaskInstanceDependencies1 = ( * @param data.dagId * @param data.dagRunId * @param data.taskId - * @param data.mapIndex * @returns TaskInstanceHistoryCollectionResponse Successful Response * @throws ApiError */ @@ -1463,12 +1462,10 @@ export const prefetchUseTaskInstanceServiceGetTaskInstanceTries = ( { dagId, dagRunId, - mapIndex, taskId, }: { dagId: string; dagRunId: string; - mapIndex?: number; taskId: string; }, ) => @@ -1476,55 +1473,10 @@ export const prefetchUseTaskInstanceServiceGetTaskInstanceTries = ( queryKey: Common.UseTaskInstanceServiceGetTaskInstanceTriesKeyFn({ dagId, dagRunId, - mapIndex, - taskId, - }), - queryFn: () => - TaskInstanceService.getTaskInstanceTries({ - dagId, - dagRunId, - mapIndex, - taskId, - }), - }); -/** - * Get Mapped Task Instance Tries - * @param data The data for the request. - * @param data.dagId - * @param data.dagRunId - * @param data.taskId - * @param data.mapIndex - * @returns TaskInstanceHistoryCollectionResponse Successful Response - * @throws ApiError - */ -export const prefetchUseTaskInstanceServiceGetMappedTaskInstanceTries = ( - queryClient: QueryClient, - { - dagId, - dagRunId, - mapIndex, - taskId, - }: { - dagId: string; - dagRunId: string; - mapIndex: number; - taskId: string; - }, -) => - queryClient.prefetchQuery({ - queryKey: Common.UseTaskInstanceServiceGetMappedTaskInstanceTriesKeyFn({ - dagId, - dagRunId, - mapIndex, taskId, }), queryFn: () => - TaskInstanceService.getMappedTaskInstanceTries({ - dagId, - dagRunId, - mapIndex, - taskId, - }), + TaskInstanceService.getTaskInstanceTries({ dagId, dagRunId, taskId }), }); /** * Get Mapped Task Instance diff --git a/airflow/ui/openapi-gen/queries/queries.ts b/airflow/ui/openapi-gen/queries/queries.ts index a1a72afcdc511..addbe9c35b4fb 100644 --- a/airflow/ui/openapi-gen/queries/queries.ts +++ b/airflow/ui/openapi-gen/queries/queries.ts @@ -1757,7 +1757,6 @@ export const useTaskInstanceServiceGetTaskInstanceDependencies1 = < * @param data.dagId * @param data.dagRunId * @param data.taskId - * @param data.mapIndex * @returns TaskInstanceHistoryCollectionResponse Successful Response * @throws ApiError */ @@ -1769,12 +1768,10 @@ export const useTaskInstanceServiceGetTaskInstanceTries = < { dagId, dagRunId, - mapIndex, taskId, }: { dagId: string; dagRunId: string; - mapIndex?: number; taskId: string; }, queryKey?: TQueryKey, @@ -1782,57 +1779,13 @@ export const useTaskInstanceServiceGetTaskInstanceTries = < ) => useQuery({ queryKey: Common.UseTaskInstanceServiceGetTaskInstanceTriesKeyFn( - { dagId, dagRunId, mapIndex, taskId }, + { dagId, dagRunId, taskId }, queryKey, ), queryFn: () => TaskInstanceService.getTaskInstanceTries({ dagId, dagRunId, - mapIndex, - taskId, - }) as TData, - ...options, - }); -/** - * Get Mapped Task Instance Tries - * @param data The data for the request. - * @param data.dagId - * @param data.dagRunId - * @param data.taskId - * @param data.mapIndex - * @returns TaskInstanceHistoryCollectionResponse Successful Response - * @throws ApiError - */ -export const useTaskInstanceServiceGetMappedTaskInstanceTries = < - TData = Common.TaskInstanceServiceGetMappedTaskInstanceTriesDefaultResponse, - TError = unknown, - TQueryKey extends Array = unknown[], ->( - { - dagId, - dagRunId, - mapIndex, - taskId, - }: { - dagId: string; - dagRunId: string; - mapIndex: number; - taskId: string; - }, - queryKey?: TQueryKey, - options?: Omit, "queryKey" | "queryFn">, -) => - useQuery({ - queryKey: Common.UseTaskInstanceServiceGetMappedTaskInstanceTriesKeyFn( - { dagId, dagRunId, mapIndex, taskId }, - queryKey, - ), - queryFn: () => - TaskInstanceService.getMappedTaskInstanceTries({ - dagId, - dagRunId, - mapIndex, taskId, }) as TData, ...options, diff --git a/airflow/ui/openapi-gen/queries/suspense.ts b/airflow/ui/openapi-gen/queries/suspense.ts index d77391aaa1576..b81d25976ec16 100644 --- a/airflow/ui/openapi-gen/queries/suspense.ts +++ b/airflow/ui/openapi-gen/queries/suspense.ts @@ -1737,7 +1737,6 @@ export const useTaskInstanceServiceGetTaskInstanceDependencies1Suspense = < * @param data.dagId * @param data.dagRunId * @param data.taskId - * @param data.mapIndex * @returns TaskInstanceHistoryCollectionResponse Successful Response * @throws ApiError */ @@ -1749,12 +1748,10 @@ export const useTaskInstanceServiceGetTaskInstanceTriesSuspense = < { dagId, dagRunId, - mapIndex, taskId, }: { dagId: string; dagRunId: string; - mapIndex?: number; taskId: string; }, queryKey?: TQueryKey, @@ -1762,57 +1759,13 @@ export const useTaskInstanceServiceGetTaskInstanceTriesSuspense = < ) => useSuspenseQuery({ queryKey: Common.UseTaskInstanceServiceGetTaskInstanceTriesKeyFn( - { dagId, dagRunId, mapIndex, taskId }, + { dagId, dagRunId, taskId }, queryKey, ), queryFn: () => TaskInstanceService.getTaskInstanceTries({ dagId, dagRunId, - mapIndex, - taskId, - }) as TData, - ...options, - }); -/** - * Get Mapped Task Instance Tries - * @param data The data for the request. - * @param data.dagId - * @param data.dagRunId - * @param data.taskId - * @param data.mapIndex - * @returns TaskInstanceHistoryCollectionResponse Successful Response - * @throws ApiError - */ -export const useTaskInstanceServiceGetMappedTaskInstanceTriesSuspense = < - TData = Common.TaskInstanceServiceGetMappedTaskInstanceTriesDefaultResponse, - TError = unknown, - TQueryKey extends Array = unknown[], ->( - { - dagId, - dagRunId, - mapIndex, - taskId, - }: { - dagId: string; - dagRunId: string; - mapIndex: number; - taskId: string; - }, - queryKey?: TQueryKey, - options?: Omit, "queryKey" | "queryFn">, -) => - useSuspenseQuery({ - queryKey: Common.UseTaskInstanceServiceGetMappedTaskInstanceTriesKeyFn( - { dagId, dagRunId, mapIndex, taskId }, - queryKey, - ), - queryFn: () => - TaskInstanceService.getMappedTaskInstanceTries({ - dagId, - dagRunId, - mapIndex, taskId, }) as TData, ...options, diff --git a/airflow/ui/openapi-gen/requests/services.gen.ts b/airflow/ui/openapi-gen/requests/services.gen.ts index cf60da098a291..e9c6d76c536ea 100644 --- a/airflow/ui/openapi-gen/requests/services.gen.ts +++ b/airflow/ui/openapi-gen/requests/services.gen.ts @@ -126,8 +126,6 @@ import type { GetTaskInstanceDependencies1Response, GetTaskInstanceTriesData, GetTaskInstanceTriesResponse, - GetMappedTaskInstanceTriesData, - GetMappedTaskInstanceTriesResponse, GetMappedTaskInstanceData, GetMappedTaskInstanceResponse, GetTaskInstancesData, @@ -2100,7 +2098,6 @@ export class TaskInstanceService { * @param data.dagId * @param data.dagRunId * @param data.taskId - * @param data.mapIndex * @returns TaskInstanceHistoryCollectionResponse Successful Response * @throws ApiError */ @@ -2115,40 +2112,6 @@ export class TaskInstanceService { dag_run_id: data.dagRunId, task_id: data.taskId, }, - query: { - map_index: data.mapIndex, - }, - errors: { - 401: "Unauthorized", - 403: "Forbidden", - 404: "Not Found", - 422: "Validation Error", - }, - }); - } - - /** - * Get Mapped Task Instance Tries - * @param data The data for the request. - * @param data.dagId - * @param data.dagRunId - * @param data.taskId - * @param data.mapIndex - * @returns TaskInstanceHistoryCollectionResponse Successful Response - * @throws ApiError - */ - public static getMappedTaskInstanceTries( - data: GetMappedTaskInstanceTriesData, - ): CancelablePromise { - return __request(OpenAPI, { - method: "GET", - url: "/public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/tries", - path: { - dag_id: data.dagId, - dag_run_id: data.dagRunId, - task_id: data.taskId, - map_index: data.mapIndex, - }, errors: { 401: "Unauthorized", 403: "Forbidden", diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts b/airflow/ui/openapi-gen/requests/types.gen.ts index 2a275d336ccf6..40639fa42b51d 100644 --- a/airflow/ui/openapi-gen/requests/types.gen.ts +++ b/airflow/ui/openapi-gen/requests/types.gen.ts @@ -1692,23 +1692,12 @@ export type GetTaskInstanceDependencies1Response = export type GetTaskInstanceTriesData = { dagId: string; dagRunId: string; - mapIndex?: number; taskId: string; }; export type GetTaskInstanceTriesResponse = TaskInstanceHistoryCollectionResponse; -export type GetMappedTaskInstanceTriesData = { - dagId: string; - dagRunId: string; - mapIndex: number; - taskId: string; -}; - -export type GetMappedTaskInstanceTriesResponse = - TaskInstanceHistoryCollectionResponse; - export type GetMappedTaskInstanceData = { dagId: string; dagRunId: string; @@ -3504,33 +3493,6 @@ export type $OpenApiTs = { }; }; }; - "/public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/tries": { - get: { - req: GetMappedTaskInstanceTriesData; - res: { - /** - * Successful Response - */ - 200: TaskInstanceHistoryCollectionResponse; - /** - * Unauthorized - */ - 401: HTTPExceptionResponse; - /** - * Forbidden - */ - 403: HTTPExceptionResponse; - /** - * Not Found - */ - 404: HTTPExceptionResponse; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; - }; - }; "/public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}": { get: { req: GetMappedTaskInstanceData;