Skip to content

Commit

Permalink
[24.2] Fix cancellation of workflow scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Dec 3, 2024
1 parent f5e146d commit 68efe8d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
15 changes: 15 additions & 0 deletions client/src/api/invocations.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { rethrowSimple } from "@/utils/simple-error";

import { GalaxyApi } from "./client";
import { type components } from "./schema";

export type WorkflowInvocationElementView = components["schemas"]["WorkflowInvocationElementView"];
Expand All @@ -12,3 +15,15 @@ export type StepJobSummary =
| components["schemas"]["InvocationStepJobsResponseCollectionJobsModel"];

export type WorkflowInvocation = components["schemas"]["WorkflowInvocationResponse"];

export async function cancelWorkflowScheduling(invocationId: string) {
const { data, error } = await GalaxyApi().DELETE("/api/invocations/{invocation_id}", {
params: {
path: { invocation_id: invocationId },
},
});
if (error) {
rethrowSimple(error);
}
return data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { BAlert, BBadge, BButton, BTab, BTabs } from "bootstrap-vue";
import { computed, onUnmounted, ref, watch } from "vue";
import { type InvocationJobsSummary, type InvocationStep, type WorkflowInvocationElementView } from "@/api/invocations";
import { cancelWorkflowScheduling } from "@/api/invocations";
import { useAnimationFrameResizeObserver } from "@/composables/sensors/animationFrameResizeObserver";
import { useInvocationStore } from "@/stores/invocationStore";
import { useWorkflowStore } from "@/stores/workflowStore";
import { errorMessageAsString } from "@/utils/simple-error";
import { cancelWorkflowScheduling } from "./services";
import {
errorCount as jobStatesSummaryErrorCount,
isTerminal,
Expand Down Expand Up @@ -53,6 +53,7 @@ const stepStatesInterval = ref<any>(undefined);
const jobStatesInterval = ref<any>(undefined);
const invocationLoaded = ref(false);
const errorMessage = ref<string | null>(null);
const cancellingInvocation = ref(false);
// after the report tab is first activated, no longer lazy-render it from then on
const reportActive = ref(false);
Expand Down Expand Up @@ -219,11 +220,22 @@ async function pollJobStatesUntilTerminal() {
function onError(e: any) {
console.error(e);
}
function onCancel() {
emit("invocation-cancelled");
}
function cancelWorkflowSchedulingLocal() {
cancelWorkflowScheduling(props.invocationId).then(onCancel).catch(onError);
async function onCancel() {
try {
cancellingInvocation.value = true;
await cancelWorkflowScheduling(props.invocationId);
} catch (e) {
onError(e);
} finally {
emit("invocation-cancelled");
// Update the invocation state to reflect the cancellation
setTimeout(async () => {
await invocationStore.fetchInvocationForId({ id: props.invocationId });
await invocationStore.fetchInvocationJobsSummaryForId({ id: props.invocationId });
cancellingInvocation.value = false;
}, 3000);
}
}
</script>

Expand All @@ -243,6 +255,7 @@ function cancelWorkflowSchedulingLocal() {
size="sm"
class="text-decoration-none"
variant="link"
:disabled="cancellingInvocation"
@click="onCancel">
<FontAwesomeIcon :icon="faSquare" fixed-width />
Cancel
Expand Down Expand Up @@ -302,8 +315,7 @@ function cancelWorkflowSchedulingLocal() {
:is-full-page="props.isFullPage"
:invocation-and-job-terminal="invocationAndJobTerminal"
:invocation-scheduling-terminal="invocationSchedulingTerminal"
:is-subworkflow="isSubworkflow"
@invocation-cancelled="cancelWorkflowSchedulingLocal" />
:is-subworkflow="isSubworkflow" />
</BTab>
<BTab v-if="!isSubworkflow" title="Steps" lazy>
<WorkflowInvocationSteps
Expand Down
14 changes: 0 additions & 14 deletions client/src/components/WorkflowInvocationState/services.js

This file was deleted.

0 comments on commit 68efe8d

Please sign in to comment.