rawwar commented on code in PR #42973:
URL: https://github.com/apache/airflow/pull/42973#discussion_r1807190940
##########
airflow/api_fastapi/routes/public/dag_run.py:
##########
@@ -57,3 +57,19 @@ async def delete_dag_run(dag_id: str, dag_run_id: str,
session: Annotated[Sessio
)
session.delete(dag_run)
+
+
+@dag_run_router.patch("/{dag_run_id}",
responses=create_openapi_http_exception_doc([400, 401, 403, 404]))
+async def modify_dag_run(
+ dag_id: str, dag_run_id: str, state: DAGRunPatchBody, session:
Annotated[Session, Depends(get_session)]
+) -> DAGRunResponse:
+ """Modify a DAG Run."""
+ dag_run = session.scalar(select(DagRun).filter_by(dag_id=dag_id,
run_id=dag_run_id))
+ if dag_run is None:
+ raise HTTPException(
+ 404, f"The DagRun with dag_id: `{dag_id}` and run_id:
`{dag_run_id}` was not found"
+ )
+
+ setattr(dag_run, "state", state.state)
+
Review Comment:
@pierrejeambrun ,
> Also we should also use the DagBag for consistency
I'm using dagbag to get the dag now. But, I'm trying to understand why we do
this. Is this because, the data in DB could be stale and the DagBag always will
have the latest data, from the most recent parse?
##########
airflow/api_fastapi/routes/public/dag_run.py:
##########
@@ -57,3 +57,19 @@ async def delete_dag_run(dag_id: str, dag_run_id: str,
session: Annotated[Sessio
)
session.delete(dag_run)
+
+
+@dag_run_router.patch("/{dag_run_id}",
responses=create_openapi_http_exception_doc([400, 401, 403, 404]))
+async def modify_dag_run(
+ dag_id: str, dag_run_id: str, state: DAGRunPatchBody, session:
Annotated[Session, Depends(get_session)]
+) -> DAGRunResponse:
+ """Modify a DAG Run."""
+ dag_run = session.scalar(select(DagRun).filter_by(dag_id=dag_id,
run_id=dag_run_id))
+ if dag_run is None:
+ raise HTTPException(
+ 404, f"The DagRun with dag_id: `{dag_id}` and run_id:
`{dag_run_id}` was not found"
+ )
+
+ setattr(dag_run, "state", state.state)
+
Review Comment:
@pierrejeambrun ,
> Also we should also use the DagBag for consistency
I'm using dagbag to get the dag now. But, I'm trying to understand why we do
this. Is this because, the data in DB could be stale and the DagBag always will
have the latest data, from the most recent parse?
--
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]