From 8e3efc538884f66e72a8a84cde524a3b073de5cf Mon Sep 17 00:00:00 2001 From: kandharvishnuu <148410552+kandharvishnuu@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:46:16 +0530 Subject: [PATCH 1/7] adding get_task_instance_tries code --- .../endpoints/task_instance_endpoint.py | 1 + .../core_api/openapi/v1-generated.yaml | 80 +++++++++++++++++++ .../core_api/routes/public/task_instances.py | 48 ++++++++++- airflow/ui/openapi-gen/queries/common.ts | 26 ++++++ airflow/ui/openapi-gen/queries/prefetch.ts | 40 ++++++++++ airflow/ui/openapi-gen/queries/queries.ts | 44 ++++++++++ airflow/ui/openapi-gen/queries/suspense.ts | 44 ++++++++++ .../ui/openapi-gen/requests/schemas.gen.ts | 20 +++++ .../ui/openapi-gen/requests/services.gen.ts | 36 +++++++++ airflow/ui/openapi-gen/requests/types.gen.ts | 45 +++++++++++ .../routes/public/test_task_instances.py | 41 ++++++++++ 11 files changed, 424 insertions(+), 1 deletion(-) diff --git a/airflow/api_connexion/endpoints/task_instance_endpoint.py b/airflow/api_connexion/endpoints/task_instance_endpoint.py index 3256f6998b080..e37b2ee864644 100644 --- a/airflow/api_connexion/endpoints/task_instance_endpoint.py +++ b/airflow/api_connexion/endpoints/task_instance_endpoint.py @@ -780,6 +780,7 @@ def get_mapped_task_instance_try_details( ) +@mark_fastapi_migration_done @security.requires_access_dag("GET", DagAccessEntity.TASK_INSTANCE) @provide_session def get_task_instance_tries( diff --git a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml index 4bfd0e6568cdf..97f2fd75ca2a7 100644 --- a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml +++ b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml @@ -3925,6 +3925,70 @@ paths: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' + /public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/tries: + get: + tags: + - Task Instance + summary: Get Task Instance Tries + description: Get list of task instances history. + operationId: get_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: 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}: get: tags: @@ -7301,6 +7365,22 @@ components: - total_entries title: TaskInstanceCollectionResponse description: Task Instance Collection serializer for responses. + TaskInstanceHistoryCollectionResponse: + properties: + task_instances: + items: + $ref: '#/components/schemas/TaskInstanceHistoryResponse' + type: array + title: Task Instances + total_entries: + type: integer + title: Total Entries + type: object + required: + - task_instances + - total_entries + title: TaskInstanceHistoryCollectionResponse + description: TaskInstanceHistory Collection serializer for responses. TaskInstanceHistoryResponse: properties: task_id: 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 857b03ab00e6e..d907345274c84 100644 --- a/airflow/api_fastapi/core_api/routes/public/task_instances.py +++ b/airflow/api_fastapi/core_api/routes/public/task_instances.py @@ -21,7 +21,8 @@ from fastapi import Depends, HTTPException, Request, status from sqlalchemy.orm import Session, joinedload -from sqlalchemy.sql import select +from sqlalchemy.sql import or_, select +from sqlalchemy.sql.selectable import Select from airflow.api_fastapi.common.db.common import get_session, paginated_select from airflow.api_fastapi.common.parameters import ( @@ -51,6 +52,7 @@ ClearTaskInstancesBody, TaskDependencyCollectionResponse, TaskInstanceCollectionResponse, + TaskInstanceHistoryCollectionResponse, TaskInstanceHistoryResponse, TaskInstanceReferenceCollectionResponse, TaskInstanceReferenceResponse, @@ -234,6 +236,50 @@ def get_task_instance_dependencies( return TaskDependencyCollectionResponse.model_validate({"dependencies": deps}) +@task_instances_router.get( + task_instances_prefix + "/{task_id}/tries", + responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]), +) +def get_task_instance_tries( + dag_id: str, + dag_run_id: str, + task_id: str, + session: Annotated[Session, Depends(get_session)], + map_index: int = -1, +) -> TaskInstanceHistoryCollectionResponse: + """Get list of task instances history.""" + + def _query(orm_object: Base) -> Select: + query = select(orm_object).where( + orm_object.dag_id == dag_id, + orm_object.run_id == dag_run_id, + orm_object.task_id == task_id, + orm_object.map_index == map_index, + ) + print(type(query)) + return query + + # Exclude TaskInstance with state UP_FOR_RETRY since they have been recorded in TaskInstanceHistory + tis = session.scalars( + _query(TI).where(or_(TI.state != TaskInstanceState.UP_FOR_RETRY, TI.state.is_(None))) + ).all() + task_instances = session.scalars(_query(TIH)).all() + tis + + 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_data = [ + TaskInstanceHistoryResponse.model_validate(instance, from_attributes=True) + for instance in task_instances + ] + return TaskInstanceHistoryCollectionResponse( + task_instances=task_instances_data, + total_entries=len(task_instances_data), + ) + + @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 7dd66d90793be..766f97fa589ca 100644 --- a/airflow/ui/openapi-gen/queries/common.ts +++ b/airflow/ui/openapi-gen/queries/common.ts @@ -1089,6 +1089,32 @@ export const UseTaskInstanceServiceGetTaskInstanceDependencies1KeyFn = ( useTaskInstanceServiceGetTaskInstanceDependencies1Key, ...(queryKey ?? [{ dagId, dagRunId, mapIndex, taskId }]), ]; +export type TaskInstanceServiceGetTaskInstanceTriesDefaultResponse = Awaited< + ReturnType +>; +export type TaskInstanceServiceGetTaskInstanceTriesQueryResult< + TData = TaskInstanceServiceGetTaskInstanceTriesDefaultResponse, + TError = unknown, +> = UseQueryResult; +export const useTaskInstanceServiceGetTaskInstanceTriesKey = + "TaskInstanceServiceGetTaskInstanceTries"; +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 TaskInstanceServiceGetMappedTaskInstanceDefaultResponse = Awaited< ReturnType >; diff --git a/airflow/ui/openapi-gen/queries/prefetch.ts b/airflow/ui/openapi-gen/queries/prefetch.ts index ae0d960d0764a..d06447aea57f5 100644 --- a/airflow/ui/openapi-gen/queries/prefetch.ts +++ b/airflow/ui/openapi-gen/queries/prefetch.ts @@ -1447,6 +1447,46 @@ export const prefetchUseTaskInstanceServiceGetTaskInstanceDependencies1 = ( taskId, }), }); +/** + * Get Task Instance Tries + * Get list of task instances history. + * @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 prefetchUseTaskInstanceServiceGetTaskInstanceTries = ( + queryClient: QueryClient, + { + dagId, + dagRunId, + mapIndex, + taskId, + }: { + dagId: string; + dagRunId: string; + mapIndex?: number; + taskId: string; + }, +) => + queryClient.prefetchQuery({ + queryKey: Common.UseTaskInstanceServiceGetTaskInstanceTriesKeyFn({ + dagId, + dagRunId, + mapIndex, + taskId, + }), + queryFn: () => + TaskInstanceService.getTaskInstanceTries({ + dagId, + dagRunId, + mapIndex, + taskId, + }), + }); /** * Get Mapped Task Instance * Get task instance. diff --git a/airflow/ui/openapi-gen/queries/queries.ts b/airflow/ui/openapi-gen/queries/queries.ts index 8bd4db19c61fe..704b71aa37843 100644 --- a/airflow/ui/openapi-gen/queries/queries.ts +++ b/airflow/ui/openapi-gen/queries/queries.ts @@ -1750,6 +1750,50 @@ export const useTaskInstanceServiceGetTaskInstanceDependencies1 = < }) as TData, ...options, }); +/** + * Get Task Instance Tries + * Get list of task instances history. + * @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 useTaskInstanceServiceGetTaskInstanceTries = < + TData = Common.TaskInstanceServiceGetTaskInstanceTriesDefaultResponse, + 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.UseTaskInstanceServiceGetTaskInstanceTriesKeyFn( + { dagId, dagRunId, mapIndex, taskId }, + queryKey, + ), + queryFn: () => + TaskInstanceService.getTaskInstanceTries({ + dagId, + dagRunId, + mapIndex, + taskId, + }) as TData, + ...options, + }); /** * Get Mapped Task Instance * Get task instance. diff --git a/airflow/ui/openapi-gen/queries/suspense.ts b/airflow/ui/openapi-gen/queries/suspense.ts index d8175414ac3d8..869c7b85dc334 100644 --- a/airflow/ui/openapi-gen/queries/suspense.ts +++ b/airflow/ui/openapi-gen/queries/suspense.ts @@ -1730,6 +1730,50 @@ export const useTaskInstanceServiceGetTaskInstanceDependencies1Suspense = < }) as TData, ...options, }); +/** + * Get Task Instance Tries + * Get list of task instances history. + * @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 useTaskInstanceServiceGetTaskInstanceTriesSuspense = < + TData = Common.TaskInstanceServiceGetTaskInstanceTriesDefaultResponse, + 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.UseTaskInstanceServiceGetTaskInstanceTriesKeyFn( + { dagId, dagRunId, mapIndex, taskId }, + queryKey, + ), + queryFn: () => + TaskInstanceService.getTaskInstanceTries({ + dagId, + dagRunId, + mapIndex, + taskId, + }) as TData, + ...options, + }); /** * Get Mapped Task Instance * Get task instance. diff --git a/airflow/ui/openapi-gen/requests/schemas.gen.ts b/airflow/ui/openapi-gen/requests/schemas.gen.ts index 5cd3e9e6b5264..4d5ff615979f6 100644 --- a/airflow/ui/openapi-gen/requests/schemas.gen.ts +++ b/airflow/ui/openapi-gen/requests/schemas.gen.ts @@ -3385,6 +3385,26 @@ export const $TaskInstanceCollectionResponse = { description: "Task Instance Collection serializer for responses.", } as const; +export const $TaskInstanceHistoryCollectionResponse = { + properties: { + task_instances: { + items: { + $ref: "#/components/schemas/TaskInstanceHistoryResponse", + }, + type: "array", + title: "Task Instances", + }, + total_entries: { + type: "integer", + title: "Total Entries", + }, + }, + type: "object", + required: ["task_instances", "total_entries"], + title: "TaskInstanceHistoryCollectionResponse", + description: "TaskInstanceHistory Collection serializer for responses.", +} as const; + export const $TaskInstanceHistoryResponse = { properties: { task_id: { diff --git a/airflow/ui/openapi-gen/requests/services.gen.ts b/airflow/ui/openapi-gen/requests/services.gen.ts index e2bbc48437a1e..82927606f8038 100644 --- a/airflow/ui/openapi-gen/requests/services.gen.ts +++ b/airflow/ui/openapi-gen/requests/services.gen.ts @@ -124,6 +124,8 @@ import type { GetTaskInstanceDependenciesResponse, GetTaskInstanceDependencies1Data, GetTaskInstanceDependencies1Response, + GetTaskInstanceTriesData, + GetTaskInstanceTriesResponse, GetMappedTaskInstanceData, GetMappedTaskInstanceResponse, GetTaskInstancesData, @@ -2089,6 +2091,40 @@ export class TaskInstanceService { }); } + /** + * Get Task Instance Tries + * Get list of task instances history. + * @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 getTaskInstanceTries( + data: GetTaskInstanceTriesData, + ): CancelablePromise { + return __request(OpenAPI, { + method: "GET", + url: "/public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/tries", + path: { + dag_id: data.dagId, + 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 * Get task instance. diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts b/airflow/ui/openapi-gen/requests/types.gen.ts index c2b8d2c048f32..4cde367d929ab 100644 --- a/airflow/ui/openapi-gen/requests/types.gen.ts +++ b/airflow/ui/openapi-gen/requests/types.gen.ts @@ -869,6 +869,14 @@ export type TaskInstanceCollectionResponse = { total_entries: number; }; +/** + * TaskInstanceHistory Collection serializer for responses. + */ +export type TaskInstanceHistoryCollectionResponse = { + task_instances: Array; + total_entries: number; +}; + /** * TaskInstanceHistory serializer for responses. */ @@ -1681,6 +1689,16 @@ export type GetTaskInstanceDependencies1Data = { export type GetTaskInstanceDependencies1Response = TaskDependencyCollectionResponse; +export type GetTaskInstanceTriesData = { + dagId: string; + dagRunId: string; + mapIndex?: number; + taskId: string; +}; + +export type GetTaskInstanceTriesResponse = + TaskInstanceHistoryCollectionResponse; + export type GetMappedTaskInstanceData = { dagId: string; dagRunId: string; @@ -3449,6 +3467,33 @@ export type $OpenApiTs = { }; }; }; + "/public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/tries": { + get: { + req: GetTaskInstanceTriesData; + 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; diff --git a/tests/api_fastapi/core_api/routes/public/test_task_instances.py b/tests/api_fastapi/core_api/routes/public/test_task_instances.py index 367c200fa52c1..35b494fa01ce1 100644 --- a/tests/api_fastapi/core_api/routes/public/test_task_instances.py +++ b/tests/api_fastapi/core_api/routes/public/test_task_instances.py @@ -2318,3 +2318,44 @@ def test_raises_404_for_non_existent_dag(self, test_client): ) assert response.status_code == 404 assert "DAG non-existent-dag not found" in response.text + + +class TestGetTaskInstanceTries(TestTaskInstanceEndpoint): + def test_should_respond_200(self, test_client, session): + self.create_task_instances( + session=session, task_instances=[{"state": State.SUCCESS}], with_ti_history=True + ) + print("here") + response = test_client.get( + "/public/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances/print_the_context/tries" + ) + assert response.status_code == 200 + assert response.json()["total_entries"] == 2 # The task instance and its history + assert len(response.json()["task_instances"]) == 2 + + def test_ti_in_retry_state_not_returned(self, test_client, session): + self.create_task_instances( + session=session, task_instances=[{"state": State.SUCCESS}], with_ti_history=True + ) + ti = session.query(TaskInstance).one() + ti.state = State.UP_FOR_RETRY + session.merge(ti) + session.commit() + + response = test_client.get( + "/public/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances/print_the_context/tries" + ) + assert response.status_code == 200 + assert response.json()["total_entries"] == 1 + assert len(response.json()["task_instances"]) == 1 + + def test_raises_404_for_nonexistent_task_instance(self, test_client, session): + self.create_task_instances(session) + response = test_client.get( + "/public/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances/nonexistent_task/tries" + ) + assert response.status_code == 404 + + assert response.json() == { + "detail": "The Task Instance with dag_id: `example_python_operator`, run_id: `TEST_DAG_RUN_ID`, task_id: `nonexistent_task` and map_index: `-1` was not found" + } From f7475f4fe0522d0a2ead15b412dba3e0942b286f Mon Sep 17 00:00:00 2001 From: kandharvishnuu <148410552+kandharvishnuu@users.noreply.github.com> Date: Sat, 23 Nov 2024 15:10:47 +0530 Subject: [PATCH 2/7] renaming variables --- .../core_api/routes/public/task_instances.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 d907345274c84..d97e7db9c7f2c 100644 --- a/airflow/api_fastapi/core_api/routes/public/task_instances.py +++ b/airflow/api_fastapi/core_api/routes/public/task_instances.py @@ -263,20 +263,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_instances = session.scalars(_query(TIH)).all() + tis + task_instance_select = session.scalars(_query(TIH)).all() + tis - if not task_instances: + if not task_instance_select: 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_data = [ - TaskInstanceHistoryResponse.model_validate(instance, from_attributes=True) - for instance in task_instances + task_instances = [ + TaskInstanceHistoryResponse.model_validate(task_instance, from_attributes=True) + for task_instance in task_instance_select ] return TaskInstanceHistoryCollectionResponse( - task_instances=task_instances_data, - total_entries=len(task_instances_data), + task_instances=task_instances, + total_entries=len(task_instances), ) From 8d2ba150faf75d6a3c7aa24b68057e3faa874d7c Mon Sep 17 00:00:00 2001 From: kandharvishnuu <148410552+kandharvishnuu@users.noreply.github.com> Date: Sat, 23 Nov 2024 17:25:27 +0530 Subject: [PATCH 3/7] dummy change --- tests/api_fastapi/core_api/routes/public/test_task_instances.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/api_fastapi/core_api/routes/public/test_task_instances.py b/tests/api_fastapi/core_api/routes/public/test_task_instances.py index 35b494fa01ce1..4207d074bc809 100644 --- a/tests/api_fastapi/core_api/routes/public/test_task_instances.py +++ b/tests/api_fastapi/core_api/routes/public/test_task_instances.py @@ -2352,7 +2352,7 @@ def test_ti_in_retry_state_not_returned(self, test_client, session): def test_raises_404_for_nonexistent_task_instance(self, test_client, session): self.create_task_instances(session) response = test_client.get( - "/public/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances/nonexistent_task/tries" + "/public/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances/non_existent_task/tries" ) assert response.status_code == 404 From 3bc886656484c22da1f68d808ed9a5e338681ec2 Mon Sep 17 00:00:00 2001 From: kandharvishnuu <148410552+kandharvishnuu@users.noreply.github.com> Date: Sat, 23 Nov 2024 18:01:53 +0530 Subject: [PATCH 4/7] changing test case --- tests/api_fastapi/core_api/routes/public/test_task_instances.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/api_fastapi/core_api/routes/public/test_task_instances.py b/tests/api_fastapi/core_api/routes/public/test_task_instances.py index 4207d074bc809..95a262c2cd8ba 100644 --- a/tests/api_fastapi/core_api/routes/public/test_task_instances.py +++ b/tests/api_fastapi/core_api/routes/public/test_task_instances.py @@ -2357,5 +2357,5 @@ def test_raises_404_for_nonexistent_task_instance(self, test_client, session): assert response.status_code == 404 assert response.json() == { - "detail": "The Task Instance with dag_id: `example_python_operator`, run_id: `TEST_DAG_RUN_ID`, task_id: `nonexistent_task` and map_index: `-1` was not found" + "detail": "The Task Instance with dag_id: `example_python_operator`, run_id: `TEST_DAG_RUN_ID`, task_id: `non_existent_task` and map_index: `-1` was not found" } From 29a9f9944267cd1a17d2982b36022aa90199adb1 Mon Sep 17 00:00:00 2001 From: kandharvishnuu <148410552+kandharvishnuu@users.noreply.github.com> Date: Sat, 23 Nov 2024 19:26:07 +0530 Subject: [PATCH 5/7] remove print statement --- .../core_api/openapi/v1-generated.yaml | 62 +++++++++++++++++++ .../core_api/routes/public/task_instances.py | 21 ++++++- airflow/ui/openapi-gen/queries/common.ts | 25 ++++++++ airflow/ui/openapi-gen/queries/prefetch.ts | 39 ++++++++++++ airflow/ui/openapi-gen/queries/queries.ts | 43 +++++++++++++ airflow/ui/openapi-gen/queries/suspense.ts | 43 +++++++++++++ .../ui/openapi-gen/requests/services.gen.ts | 33 ++++++++++ airflow/ui/openapi-gen/requests/types.gen.ts | 37 +++++++++++ 8 files changed, 302 insertions(+), 1 deletion(-) diff --git a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml index 97f2fd75ca2a7..cfda8d3f26e0b 100644 --- a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml +++ b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml @@ -3989,6 +3989,68 @@ paths: 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 + 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}: get: tags: 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 d97e7db9c7f2c..b6118a7d5348c 100644 --- a/airflow/api_fastapi/core_api/routes/public/task_instances.py +++ b/airflow/api_fastapi/core_api/routes/public/task_instances.py @@ -256,7 +256,6 @@ def _query(orm_object: Base) -> Select: orm_object.task_id == task_id, orm_object.map_index == map_index, ) - print(type(query)) return query # Exclude TaskInstance with state UP_FOR_RETRY since they have been recorded in TaskInstanceHistory @@ -280,6 +279,26 @@ def _query(orm_object: Base) -> Select: ) +@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 766f97fa589ca..894aa4966673c 100644 --- a/airflow/ui/openapi-gen/queries/common.ts +++ b/airflow/ui/openapi-gen/queries/common.ts @@ -1115,6 +1115,31 @@ export const UseTaskInstanceServiceGetTaskInstanceTriesKeyFn = ( 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 }]), +]; export type TaskInstanceServiceGetMappedTaskInstanceDefaultResponse = Awaited< ReturnType >; diff --git a/airflow/ui/openapi-gen/queries/prefetch.ts b/airflow/ui/openapi-gen/queries/prefetch.ts index d06447aea57f5..a2d8b0c50d075 100644 --- a/airflow/ui/openapi-gen/queries/prefetch.ts +++ b/airflow/ui/openapi-gen/queries/prefetch.ts @@ -1487,6 +1487,45 @@ export const prefetchUseTaskInstanceServiceGetTaskInstanceTries = ( 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, + }), + }); /** * Get Mapped Task Instance * Get task instance. diff --git a/airflow/ui/openapi-gen/queries/queries.ts b/airflow/ui/openapi-gen/queries/queries.ts index 704b71aa37843..a1a72afcdc511 100644 --- a/airflow/ui/openapi-gen/queries/queries.ts +++ b/airflow/ui/openapi-gen/queries/queries.ts @@ -1794,6 +1794,49 @@ export const useTaskInstanceServiceGetTaskInstanceTries = < }) 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, + }); /** * Get Mapped Task Instance * Get task instance. diff --git a/airflow/ui/openapi-gen/queries/suspense.ts b/airflow/ui/openapi-gen/queries/suspense.ts index 869c7b85dc334..d77391aaa1576 100644 --- a/airflow/ui/openapi-gen/queries/suspense.ts +++ b/airflow/ui/openapi-gen/queries/suspense.ts @@ -1774,6 +1774,49 @@ export const useTaskInstanceServiceGetTaskInstanceTriesSuspense = < }) 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, + }); /** * Get Mapped Task Instance * Get task instance. diff --git a/airflow/ui/openapi-gen/requests/services.gen.ts b/airflow/ui/openapi-gen/requests/services.gen.ts index 82927606f8038..cf60da098a291 100644 --- a/airflow/ui/openapi-gen/requests/services.gen.ts +++ b/airflow/ui/openapi-gen/requests/services.gen.ts @@ -126,6 +126,8 @@ import type { GetTaskInstanceDependencies1Response, GetTaskInstanceTriesData, GetTaskInstanceTriesResponse, + GetMappedTaskInstanceTriesData, + GetMappedTaskInstanceTriesResponse, GetMappedTaskInstanceData, GetMappedTaskInstanceResponse, GetTaskInstancesData, @@ -2125,6 +2127,37 @@ export class TaskInstanceService { }); } + /** + * 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", + 404: "Not Found", + 422: "Validation Error", + }, + }); + } + /** * Get Mapped Task Instance * Get task instance. diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts b/airflow/ui/openapi-gen/requests/types.gen.ts index 4cde367d929ab..2a275d336ccf6 100644 --- a/airflow/ui/openapi-gen/requests/types.gen.ts +++ b/airflow/ui/openapi-gen/requests/types.gen.ts @@ -1699,6 +1699,16 @@ export type GetTaskInstanceTriesData = { 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; @@ -3494,6 +3504,33 @@ 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; From c8efa51382d4ee4da922e3a3b3efd3add8dc6932 Mon Sep 17 00:00:00 2001 From: kandharvishnuu <148410552+kandharvishnuu@users.noreply.github.com> Date: Mon, 25 Nov 2024 13:51:38 +0530 Subject: [PATCH 6/7] checking response in test cases --- .../routes/public/test_task_instances.py | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/tests/api_fastapi/core_api/routes/public/test_task_instances.py b/tests/api_fastapi/core_api/routes/public/test_task_instances.py index 95a262c2cd8ba..50409fa2783bf 100644 --- a/tests/api_fastapi/core_api/routes/public/test_task_instances.py +++ b/tests/api_fastapi/core_api/routes/public/test_task_instances.py @@ -2332,6 +2332,59 @@ def test_should_respond_200(self, test_client, session): assert response.status_code == 200 assert response.json()["total_entries"] == 2 # The task instance and its history assert len(response.json()["task_instances"]) == 2 + assert response.json() == { + "task_instances": [ + { + "dag_id": "example_python_operator", + "duration": 10000.0, + "end_date": "2020-01-03T00:00:00Z", + "executor": None, + "executor_config": "{}", + "hostname": "", + "map_index": -1, + "max_tries": 0, + "operator": "PythonOperator", + "pid": 100, + "pool": "default_pool", + "pool_slots": 1, + "priority_weight": 9, + "queue": "default_queue", + "queued_when": None, + "start_date": "2020-01-02T00:00:00Z", + "state": "success", + "task_id": "print_the_context", + "task_display_name": "print_the_context", + "try_number": 1, + "unixname": getuser(), + "dag_run_id": "TEST_DAG_RUN_ID", + }, + { + "dag_id": "example_python_operator", + "duration": 10000.0, + "end_date": "2020-01-03T00:00:00Z", + "executor": None, + "executor_config": "{}", + "hostname": "", + "map_index": -1, + "max_tries": 1, + "operator": "PythonOperator", + "pid": 100, + "pool": "default_pool", + "pool_slots": 1, + "priority_weight": 9, + "queue": "default_queue", + "queued_when": None, + "start_date": "2020-01-02T00:00:00Z", + "state": None, + "task_id": "print_the_context", + "task_display_name": "print_the_context", + "try_number": 2, + "unixname": getuser(), + "dag_run_id": "TEST_DAG_RUN_ID", + }, + ], + "total_entries": 2, + } def test_ti_in_retry_state_not_returned(self, test_client, session): self.create_task_instances( @@ -2348,6 +2401,35 @@ def test_ti_in_retry_state_not_returned(self, test_client, session): assert response.status_code == 200 assert response.json()["total_entries"] == 1 assert len(response.json()["task_instances"]) == 1 + assert response.json() == { + "task_instances": [ + { + "dag_id": "example_python_operator", + "duration": 10000.0, + "end_date": "2020-01-03T00:00:00Z", + "executor": None, + "executor_config": "{}", + "hostname": "", + "map_index": -1, + "max_tries": 0, + "operator": "PythonOperator", + "pid": 100, + "pool": "default_pool", + "pool_slots": 1, + "priority_weight": 9, + "queue": "default_queue", + "queued_when": None, + "start_date": "2020-01-02T00:00:00Z", + "state": "success", + "task_id": "print_the_context", + "task_display_name": "print_the_context", + "try_number": 1, + "unixname": getuser(), + "dag_run_id": "TEST_DAG_RUN_ID", + }, + ], + "total_entries": 1, + } def test_raises_404_for_nonexistent_task_instance(self, test_client, session): self.create_task_instances(session) From 66cf9e164748340ac3b247704b8dc667ccee6783 Mon Sep 17 00:00:00 2001 From: kandharvishnuu <148410552+kandharvishnuu@users.noreply.github.com> Date: Mon, 25 Nov 2024 21:16:04 +0530 Subject: [PATCH 7/7] rename variables --- .../core_api/openapi/v1-generated.yaml | 69 ------------------- .../core_api/routes/public/task_instances.py | 35 ++-------- airflow/ui/openapi-gen/queries/common.ts | 29 +------- airflow/ui/openapi-gen/queries/prefetch.ts | 50 +------------- airflow/ui/openapi-gen/queries/queries.ts | 49 +------------ airflow/ui/openapi-gen/queries/suspense.ts | 49 +------------ .../ui/openapi-gen/requests/services.gen.ts | 37 ---------- airflow/ui/openapi-gen/requests/types.gen.ts | 38 ---------- 8 files changed, 10 insertions(+), 346 deletions(-) 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;