Skip to content

Commit

Permalink
Address PR comments and fix tests
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 0047e5b commit b3b783d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
12 changes: 4 additions & 8 deletions airflow/api_fastapi/core_api/openapi/v1-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5572,11 +5572,13 @@ paths:
type: string
title: File Token
responses:
'200':
'201':
description: Successful Response
content:
application/json:
schema: {}
schema:
type: 'null'
title: Response Reparse Dag File
'401':
content:
application/json:
Expand All @@ -5589,12 +5591,6 @@ 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
8 changes: 4 additions & 4 deletions airflow/api_fastapi/core_api/routes/public/dag_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from typing import TYPE_CHECKING, Annotated

from fastapi import Depends, HTTPException, Request, status
from fastapi.responses import Response
from itsdangerous import BadSignature, URLSafeSerializer
from sqlalchemy import select
from sqlalchemy.orm import Session
Expand All @@ -40,13 +39,14 @@

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

parsing_request = DagPriorityParsingRequest(fileloc=path)
session.add(parsing_request)
return Response(status_code=status.HTTP_201_CREATED)
session.commit()
3 changes: 1 addition & 2 deletions airflow/ui/openapi-gen/queries/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3136,8 +3136,7 @@ export const useBackfillServiceCancelBackfill = <
* Request re-parsing a DAG file.
* @param data The data for the request.
* @param data.fileToken
* @returns unknown Successful Response
* @returns HTTPExceptionResponse Created
* @returns null Successful Response
* @throws ApiError
*/
export const useDagParsingServiceReparseDagFile = <
Expand Down
3 changes: 1 addition & 2 deletions airflow/ui/openapi-gen/requests/services.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2938,8 +2938,7 @@ export class DagParsingService {
* Request re-parsing a DAG file.
* @param data The data for the request.
* @param data.fileToken
* @returns unknown Successful Response
* @returns HTTPExceptionResponse Created
* @returns null Successful Response
* @throws ApiError
*/
public static reparseDagFile(
Expand Down
8 changes: 2 additions & 6 deletions airflow/ui/openapi-gen/requests/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,7 @@ export type ReparseDagFileData = {
fileToken: string;
};

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

export type GetHealthResponse = HealthInfoSchema;

Expand Down Expand Up @@ -4255,11 +4255,7 @@ export type $OpenApiTs = {
/**
* Successful Response
*/
200: unknown;
/**
* Created
*/
201: HTTPExceptionResponse;
201: null;
/**
* Unauthorized
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_201_and_400_requests(self, url_safe_serializer, session, test_client):

# Duplicate file parsing request
response = test_client.put(url, headers={"Accept": "application/json"})
assert 201 == response.status_code
assert 409 == response.status_code
parsing_requests = session.scalars(select(DagPriorityParsingRequest)).all()
assert parsing_requests[0].fileloc == test_dag.fileloc

Expand Down

0 comments on commit b3b783d

Please sign in to comment.