pierrejeambrun commented on code in PR #67846:
URL: https://github.com/apache/airflow/pull/67846#discussion_r3372350892
##########
airflow-core/src/airflow/ui/src/queries/useBulkClearDagRuns.ts:
##########
@@ -99,64 +84,46 @@ export const useBulkClearDagRuns = ({ deselectKeys,
onSuccessConfirm }: Props) =
reset();
setIsPending(true);
- const settled = await Promise.allSettled(
- dagRuns.map((dagRun) =>
- DagRunService.clearDagRun({
- dagId: dagRun.dag_id,
- dagRunId: dagRun.dag_run_id,
- requestBody: {
- dry_run: false,
- note: options.note ?? undefined,
- only_failed: options.onlyFailed,
- only_new: options.onlyNew,
- },
- }).then(() => dagRun),
- ),
- );
-
- const succeeded: Array<DAGRunResponse> = [];
- const errors: Array<Record<string, unknown>> = [];
-
- settled.forEach((outcome, index) => {
- if (outcome.status === "fulfilled") {
- succeeded.push(outcome.value);
- } else {
- const dagRun = dagRuns[index];
-
- errors.push({
- error: dagRun
- ? `${getRowKey(dagRun)}: ${formatError(outcome.reason)}`
- : formatError(outcome.reason),
- });
- }
- });
+ try {
+ // ``~`` clears runs across Dags atomically in a single request; every
entry
+ // carries its own dag_id. The whole request succeeds or fails together.
+ await DagRunService.clearDagRuns({
+ dagId: "~",
+ requestBody: {
+ dag_runs: dagRuns.map((dagRun) => ({
+ dag_id: dagRun.dag_id,
Review Comment:
Done. Should look better. (We still wrap the dry run service to get query
sementics on a non 'GET' endpoint. (Dry run is actually a 'post' but we need
query hooks basically)
--
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]