Bowrna commented on code in PR #23451:
URL: https://github.com/apache/airflow/pull/23451#discussion_r867524250
##########
airflow/api_connexion/endpoints/dag_run_endpoint.py:
##########
@@ -312,3 +317,54 @@ def update_dag_run_state(*, dag_id: str, dag_run_id: str,
session: Session = NEW
set_dag_run_state_to_failed(dag=dag, run_id=dag_run.run_id,
commit=True)
dag_run = session.query(DagRun).get(dag_run.id)
return dagrun_schema.dump(dag_run)
+
+
[email protected]_access(
+ [
+ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
+ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG_RUN),
+ ],
+)
+@provide_session
+def clear_dag_run(*, dag_id: str, dag_run_id: str, session: Session =
NEW_SESSION) -> APIResponse:
+ """Clear a dag run."""
+ dag_run: Optional[DagRun] = (
+ session.query(DagRun).filter(DagRun.dag_id == dag_id, DagRun.run_id ==
dag_run_id).one_or_none()
+ )
+ if dag_run is None:
+ error_message = f'Dag Run id {dag_run_id} not found in dag {dag_id}'
+ raise NotFound(error_message)
+ try:
+ post_body = clear_dagrun_form_schema.load(request.json)
+ except ValidationError as err:
+ raise BadRequest(detail=str(err))
+
+ dry_run = post_body.get('dry_run', False)
+ dag = current_app.dag_bag.get_dag(dag_id)
+ start_date = dag_run.logical_date
+ end_date = dag_run.logical_date
+
+ if dry_run:
+ task_instances = dag.clear(
Review Comment:
@tirkarthi I have some doubts about this part. How does this dag clear work
without passing the dag_run_id? I am curious to know as I am working on a
similar issue https://github.com/apache/airflow/issues/23227
Thank you
--
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]