Skip to content

Commit

Permalink
fix API model imports, remove unused function from useInvocationGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Apr 27, 2024
1 parent 8fa85d6 commit e1d35aa
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 36 deletions.
10 changes: 10 additions & 0 deletions client/src/api/invocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ export type WorkflowInvocationCollectionView = components["schemas"]["WorkflowIn
export type InvocationJobsSummary = components["schemas"]["InvocationJobsResponse"];
export type InvocationStep = components["schemas"]["InvocationStep"];

export type StepJobSummary =
| components["schemas"]["InvocationStepJobsResponseStepModel"]
| components["schemas"]["InvocationStepJobsResponseJobModel"]
| components["schemas"]["InvocationStepJobsResponseCollectionJobsModel"];

export const invocationsFetcher = fetcher.path("/api/invocations").method("get").create();

export const stepJobsSummaryFetcher = fetcher
.path("/api/invocations/{invocation_id}/step_jobs_summary")
.method("get")
.create();

export type WorkflowInvocation = WorkflowInvocationElementView | WorkflowInvocationCollectionView;

export interface WorkflowInvocationJobsSummary {
Expand Down
4 changes: 3 additions & 1 deletion client/src/api/workflows.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { fetcher } from "@/api/schema";
import { components, fetcher } from "@/api/schema";

export type StoredWorkflowDetailed = components["schemas"]["StoredWorkflowDetailed"];

export const workflowsFetcher = fetcher.path("/api/workflows").method("get").create();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { BAlert, BButton, BCard, BCardBody, BCardHeader } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { computed, onUnmounted, ref, watch } from "vue";
import { components } from "@/api/schema";
import type { WorkflowInvocationElementView } from "@/api/invocations";
import { JobProvider } from "@/components/providers";
import { useDatatypesMapper } from "@/composables/datatypesMapper";
import { useInvocationGraph } from "@/composables/useInvocationGraph";
Expand All @@ -35,7 +35,7 @@ library.add(faArrowDown, faChevronDown, faChevronUp, faSignInAlt, faSitemap, faT
interface Props {
/** The invocation to display */
invocation: components["schemas"]["WorkflowInvocationElementView"];
invocation: WorkflowInvocationElementView;
/** The workflow which was run */
workflow: Workflow;
/** Whether the invocation is terminal */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { faChevronDown, faChevronUp, faSignInAlt } from "@fortawesome/free-solid
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { computed, ref, watch } from "vue";
import { components } from "@/api/schema";
import { WorkflowInvocationElementView } from "@/api/invocations";
import { isWorkflowInput } from "@/components/Workflow/constants";
import type { GraphStep } from "@/composables/useInvocationGraph";
import type { Workflow } from "@/stores/workflowStore";
Expand All @@ -19,7 +19,7 @@ interface Props {
/** The store id for the invocation graph */
storeId: string;
/** The invocation to display */
invocation: components["schemas"]["WorkflowInvocationElementView"];
invocation: WorkflowInvocationElementView;
/** The workflow which was run */
workflow: Workflow;
/** Whether the invocation graph is hidden */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BAlert, BButton, BButtonGroup, BTab, BTabs } from "bootstrap-vue";
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
import { InvocationJobsSummary, WorkflowInvocationElementView } from "@/api/invocations";
import { components } from "@/api/schema";
import { type InvocationJobsSummary, type WorkflowInvocationElementView } from "@/api/invocations";
import type { StoredWorkflowDetailed } from "@/api/workflows";
import { useAnimationFrameResizeObserver } from "@/composables/sensors/animationFrameResizeObserver";
import { useInvocationStore } from "@/stores/invocationStore";
import { useWorkflowStore } from "@/stores/workflowStore";
Expand All @@ -27,8 +27,6 @@ import LoadingSpan from "@/components/LoadingSpan.vue";
library.add(faArrowLeft, faClock, faEdit, faEye, faHdd, faPlay, faSitemap);
type StoredWorkflowDetailed = components["schemas"]["StoredWorkflowDetailed"];
interface Props {
invocationId: string;
index?: number;
Expand Down
29 changes: 2 additions & 27 deletions client/src/composables/useInvocationGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from "@fortawesome/free-solid-svg-icons";
import Vue, { computed, type Ref, ref } from "vue";

import { components, fetcher } from "@/api/schema";
import { stepJobsSummaryFetcher, type StepJobSummary, type WorkflowInvocationElementView } from "@/api/invocations";
import { isWorkflowInput } from "@/components/Workflow/constants";
import { fromSimple } from "@/components/Workflow/Editor/modules/model";
import { getWorkflowFull } from "@/components/Workflow/workflows.services";
Expand All @@ -20,11 +20,6 @@ import { rethrowSimple } from "@/utils/simple-error";

import { provideScopedWorkflowStores } from "./workflowStores";

// Type Definitions
type StepJobSummary =
| components["schemas"]["InvocationStepJobsResponseStepModel"]
| components["schemas"]["InvocationStepJobsResponseJobModel"]
| components["schemas"]["InvocationStepJobsResponseCollectionJobsModel"];
export interface GraphStep extends Step {
state?:
| "new"
Expand All @@ -48,13 +43,6 @@ interface InvocationGraph extends Workflow {
steps: { [index: number]: GraphStep };
}

// Fetchers
const stepJobsSummaryFetcher = fetcher
.path("/api/invocations/{invocation_id}/step_jobs_summary")
.method("get")
.create();
const invocationStepFetcher = fetcher.path("/api/invocations/steps/{step_id}").method("get").create();

/** Classes for states' icons */
export const iconClasses: Record<string, { icon: IconDefinition; spin?: boolean; class?: string }> = {
ok: { icon: faCheckCircle, class: "text-success" },
Expand All @@ -78,7 +66,7 @@ const ALL_INSTANCES_STATES = ["deleted", "skipped", "new", "queued"];
* @param workflowId - The id of the workflow that was invoked
*/
export function useInvocationGraph(
invocation: Ref<components["schemas"]["WorkflowInvocationElementView"]>,
invocation: Ref<WorkflowInvocationElementView>,
workflowId: string | undefined,
workflowVersion: number | undefined
) {
Expand Down Expand Up @@ -265,24 +253,11 @@ export function useInvocationGraph(
// await fromSimple(storeId.value, invocationGraph.value as any);
// }

async function getInvocationStep(name: string, id: number) {
const step_id = invocation.value.steps[id]?.id;
if (step_id) {
try {
const { data: invocationStep } = await invocationStepFetcher({ step_id });
return invocationStep;
} catch (e) {
rethrowSimple(e);
}
}
}

return {
/** An id used to scope the store to the invocation's id */
storeId,
/** The steps of the invocation graph */
steps,
getInvocationStep,
/** Fetches the original workflow structure (once) and the step job summaries for each step in the invocation,
* and displays the job states on the workflow graph steps.
*/
Expand Down

0 comments on commit e1d35aa

Please sign in to comment.