kremogen commented on code in PR #65839:
URL: https://github.com/apache/airflow/pull/65839#discussion_r3143126412
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_parsing.py:
##########
@@ -73,3 +74,29 @@ def reparse_dag_file(
parsing_request = DagPriorityParsingRequest(bundle_name=bundle_name,
relative_fileloc=relative_fileloc)
session.add(parsing_request)
+
+
+@dag_reparse_router.put(
+ "/reparse",
+ responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND,
status.HTTP_409_CONFLICT]),
+ status_code=status.HTTP_201_CREATED,
+ dependencies=[Depends(requires_access_dag(method="PUT")),
Depends(action_logging())],
+)
+def reparse_dag(
+ dag_id: str,
+ session: SessionDep,
+) -> None:
+ """Request re-parsing of the file that contains the given DAG."""
+ dag = session.get(DagModel, dag_id)
+ if dag is None:
+ raise HTTPException(status.HTTP_404_NOT_FOUND, f"DAG with id
'{dag_id}' not found")
+ if dag.relative_fileloc is None:
+ raise HTTPException(
+ status.HTTP_404_NOT_FOUND,
+ f"DAG with id '{dag_id}' has no file location and cannot be
re-parsed",
Review Comment:
Good call, applied - switched to 422 Unprocessable Content for the "DAG
exists but has no relative_fileloc" case and added a regression test
--
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]