A run can be stopped

This commit is contained in:
Roberto Treviño
2026-11-29 12:39:00 -06:00
parent c9b60b190b
commit d7624c7e0f
+10
View File
@@ -21,3 +21,13 @@ def run_status(run_id: str, client: DagsterGraphQLClient = Depends(dagster)) ->
return {"id": run_id, "status": client.get_run_status(run_id).value}
except DagsterGraphQLClientError as e:
raise HTTPException(404 if "RunNotFound" in str(e) else 502, detail=str(e)) from e
@router.post("/{run_id}/terminate")
def terminate_run(run_id: str, client: DagsterGraphQLClient = Depends(dagster)) -> dict[str, str]:
"""Stop a run (one started by mistake): Dagster cancels it."""
try:
client.terminate_run(run_id)
return {"id": run_id, "status": client.get_run_status(run_id).value}
except DagsterGraphQLClientError as e:
raise HTTPException(404 if "RunNotFound" in str(e) else 409, detail=str(e)) from e