Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sneha Prabhu authored and Sneha Prabhu committed Nov 28, 2024
1 parent d5500c6 commit 094966a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 98 deletions.
6 changes: 6 additions & 0 deletions airflow/api_fastapi/core_api/openapi/v1-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5589,6 +5589,12 @@ paths:
schema:
$ref: '#/components/schemas/HTTPExceptionResponse'
description: Forbidden
'201':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPExceptionResponse'
description: Created
'404':
content:
application/json:
Expand Down
11 changes: 3 additions & 8 deletions airflow/api_fastapi/core_api/routes/public/dag_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from fastapi import Depends, HTTPException, Request, status
from fastapi.responses import Response
from itsdangerous import BadSignature, URLSafeSerializer
from sqlalchemy import exc, select
from sqlalchemy import select
from sqlalchemy.orm import Session

from airflow.api_fastapi.common.db.common import get_session
Expand All @@ -40,13 +40,13 @@

@dag_parsing_router.put(
"",
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]),
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND, status.HTTP_201_CREATED]),
)
def reparse_dag_file(
file_token: str,
session: Annotated[Session, Depends(get_session)],
request: Request,
) -> Response:
):
"""Request re-parsing a DAG file."""
secret_key = request.app.state.secret_key
auth_s = URLSafeSerializer(secret_key)
Expand All @@ -64,9 +64,4 @@ def reparse_dag_file(

parsing_request = DagPriorityParsingRequest(fileloc=path)
session.add(parsing_request)
try:
session.commit()
except exc.IntegrityError:
session.rollback()
return Response("Duplicate request", status_code=status.HTTP_201_CREATED)
return Response(status_code=status.HTTP_201_CREATED)
1 change: 1 addition & 0 deletions airflow/ui/openapi-gen/queries/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3137,6 +3137,7 @@ export const useBackfillServiceCancelBackfill = <
* @param data The data for the request.
* @param data.fileToken
* @returns unknown Successful Response
* @returns HTTPExceptionResponse Created
* @throws ApiError
*/
export const useDagParsingServiceReparseDagFile = <
Expand Down
46 changes: 1 addition & 45 deletions airflow/ui/openapi-gen/requests/services.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ import type {
GetVariablesResponse,
PostVariableData,
PostVariableResponse,
GetXcomEntryData,
GetXcomEntryResponse,
ReparseDagFileData,
ReparseDagFileResponse,
GetHealthResponse,
Expand Down Expand Up @@ -2934,56 +2932,14 @@ export class VariableService {
}
}

export class XcomService {
/**
* Get Xcom Entry
* Get an XCom entry.
* @param data The data for the request.
* @param data.dagId
* @param data.taskId
* @param data.dagRunId
* @param data.xcomKey
* @param data.mapIndex
* @param data.deserialize
* @param data.stringify
* @returns unknown Successful Response
* @throws ApiError
*/
public static getXcomEntry(
data: GetXcomEntryData,
): CancelablePromise<GetXcomEntryResponse> {
return __request(OpenAPI, {
method: "GET",
url: "/public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries/{xcom_key}",
path: {
dag_id: data.dagId,
task_id: data.taskId,
dag_run_id: data.dagRunId,
xcom_key: data.xcomKey,
},
query: {
map_index: data.mapIndex,
deserialize: data.deserialize,
stringify: data.stringify,
},
errors: {
400: "Bad Request",
401: "Unauthorized",
403: "Forbidden",
404: "Not Found",
422: "Validation Error",
},
});
}
}

export class DagParsingService {
/**
* Reparse Dag File
* Request re-parsing a DAG file.
* @param data The data for the request.
* @param data.fileToken
* @returns unknown Successful Response
* @returns HTTPExceptionResponse Created
* @throws ApiError
*/
public static reparseDagFile(
Expand Down
49 changes: 5 additions & 44 deletions airflow/ui/openapi-gen/requests/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1980,23 +1980,11 @@ export type PostVariableData = {

export type PostVariableResponse = VariableResponse;

export type GetXcomEntryData = {
dagId: string;
dagRunId: string;
deserialize?: boolean;
mapIndex?: number;
stringify?: boolean;
taskId: string;
xcomKey: string;
};

export type GetXcomEntryResponse = XComResponseNative | XComResponseString;

export type ReparseDagFileData = {
fileToken: string;
};

export type ReparseDagFileResponse = unknown;
export type ReparseDagFileResponse = unknown | HTTPExceptionResponse;

export type GetHealthResponse = HealthInfoSchema;

Expand Down Expand Up @@ -4260,37 +4248,6 @@ export type $OpenApiTs = {
};
};
};
"/public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries/{xcom_key}": {
get: {
req: GetXcomEntryData;
res: {
/**
* Successful Response
*/
200: XComResponseNative | XComResponseString;
/**
* Bad Request
*/
400: HTTPExceptionResponse;
/**
* Unauthorized
*/
401: HTTPExceptionResponse;
/**
* Forbidden
*/
403: HTTPExceptionResponse;
/**
* Not Found
*/
404: HTTPExceptionResponse;
/**
* Validation Error
*/
422: HTTPValidationError;
};
};
};
"/public/parseDagFile/{file_token}": {
put: {
req: ReparseDagFileData;
Expand All @@ -4299,6 +4256,10 @@ export type $OpenApiTs = {
* Successful Response
*/
200: unknown;
/**
* Created
*/
201: HTTPExceptionResponse;
/**
* Unauthorized
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/api_connexion/endpoints/test_dag_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def configured_app(minimal_app_for_api):
delete_user(app, username="test_no_permissions")


class TestDagParsingRequest:
class TestDagParsingEndpoint:
@pytest.fixture(autouse=True)
def setup_attrs(self, configured_app) -> None:
self.app = configured_app
Expand Down

0 comments on commit 094966a

Please sign in to comment.