Skip to content

Commit

Permalink
load full workflow for the version that was run
Browse files Browse the repository at this point in the history
Without this, the latest version (with potential missing steps from the version that was run) is used to create the graph, and therefore, due to potential mismatch between versions, the graph is incorrect.
  • Loading branch information
ahmedhamidawan committed Apr 24, 2024
1 parent 10e94b5 commit 1f5c8f9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ const invocationRef = computed(() => props.invocation);
const { datatypesMapper } = useDatatypesMapper();
const workflowId = computed(() => props.workflow?.id);
const workflowVersion = computed(() => props.workflow?.version);
const { steps, storeId, loadInvocationGraph } = useInvocationGraph(invocationRef, workflowId.value);
const { steps, storeId, loadInvocationGraph } = useInvocationGraph(
invocationRef,
workflowId.value,
workflowVersion.value
);
// Equivalent to onMounted; this is where the graph is initialized, and the polling is started
watch(
Expand Down
8 changes: 6 additions & 2 deletions client/src/components/Workflow/workflows.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ export async function createWorkflow(workflowName: string, workflowAnnotation: s
return data;
}

export async function getWorkflowFull(workflowId: string) {
const { data } = await axios.get(withPrefix(`/workflow/load_workflow?_=true&id=${workflowId}`));
export async function getWorkflowFull(workflowId: string, version?: number) {
let url = `/workflow/load_workflow?_=true&id=${workflowId}`;
if (version !== undefined) {
url += `&version=${version}`;
}
const { data } = await axios.get(withPrefix(url));
return data;
}

Expand Down
8 changes: 6 additions & 2 deletions client/src/composables/useInvocationGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ const ALL_INSTANCES_STATES = ["deleted", "skipped", "new", "queued"];
*/
export function useInvocationGraph(
invocation: Ref<components["schemas"]["WorkflowInvocationElementView"]>,
workflowId: string | undefined
workflowId: string | undefined,
workflowVersion: number | undefined
) {
library.add(faCheckCircle, faClock, faExclamationTriangle, faForward, faPause, faSpinner, faTrash);

Expand All @@ -98,10 +99,13 @@ export function useInvocationGraph(
if (!workflowId) {
throw new Error("Workflow Id is not defined");
}
if (workflowVersion === undefined) {
throw new Error("Workflow Version is not defined");
}

// initialize the original full workflow and invocation graph refs (only on the first load)
if (!loadedWorkflow.value) {
loadedWorkflow.value = await getWorkflowFull(workflowId);
loadedWorkflow.value = await getWorkflowFull(workflowId, workflowVersion);
}
if (!invocationGraph.value) {
invocationGraph.value = {
Expand Down
1 change: 1 addition & 0 deletions client/src/stores/workflowStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Workflow {
steps: Steps;
step_count?: number;
latest_id?: string;
version: number;
}

export const useWorkflowStore = defineStore("workflowStore", () => {
Expand Down

0 comments on commit 1f5c8f9

Please sign in to comment.