Skip to content

Commit

Permalink
Fix model 500s on main page (#5097)
Browse files Browse the repository at this point in the history
Co-authored-by: Yohann Paris <[email protected]>
  • Loading branch information
kbirk and YohannParis authored Oct 8, 2024
1 parent bdc22e2 commit c3a8bfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
8 changes: 5 additions & 3 deletions packages/client/hmi-client/src/services/model.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import API from '@/api/api';
import { useProjects } from '@/composables/project';
import type { MMT } from '@/model-representation/mira/mira-common';
import * as EventService from '@/services/event';
import type { Initial, InterventionPolicy, Model, ModelConfiguration, ModelParameter } from '@/types/Types';
import { Artifact, EventType } from '@/types/Types';
import { AMRSchemaNames } from '@/types/common';
import { fileToJson } from '@/utils/file';
import { isEmpty } from 'lodash';
import type { MMT } from '@/model-representation/mira/mira-common';
import { Ref } from 'vue';

export async function createModel(model: Model): Promise<Model | null> {
Expand Down Expand Up @@ -38,8 +38,10 @@ export async function createModelAndModelConfig(file: File, progress?: Ref<numbe
* Get Model from the data service
* @return Model|null - the model, or null if none returned by API
*/
export async function getModel(modelId: string): Promise<Model | null> {
const response = await API.get(`/models/${modelId}`);
export async function getModel(modelId: string, projectId?: string): Promise<Model | null> {
const response = await API.get(`/models/${modelId}`, {
params: { 'project-id': projectId }
});
return response?.data ?? null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import { useProjects } from '@/composables/project';
import {
CloneProjectStatusUpdate,
ExtractionStatusUpdate,
NotificationItem,
NotificationItemStatus
} from '@/types/common';
import { ProjectPages } from '@/types/Project';
import {
AssetType,
ClientEvent,
Expand All @@ -10,19 +18,11 @@ import {
TaskStatus
} from '@/types/Types';
import { logger } from '@/utils/logger';
import { Ref } from 'vue';
import {
CloneProjectStatusUpdate,
ExtractionStatusUpdate,
NotificationItem,
NotificationItemStatus
} from '@/types/common';
import { snakeToCapitalSentence } from '@/utils/text';
import { ProjectPages } from '@/types/Project';
import { useProjects } from '@/composables/project';
import { Ref } from 'vue';
import { getDocumentAsset } from './document-assets';
import { getWorkflow } from './workflow';
import { getModel } from './model';
import { getWorkflow } from './workflow';

type NotificationEventData = TaskResponse | StatusUpdate<unknown>;
/**
Expand Down Expand Up @@ -158,7 +158,9 @@ export const createNotificationEventHandlers = (notificationItems: Ref<Notificat
created.supportCancel = true;
created.assetId = event.data.additionalProperties.modelId as string;
created.pageType = AssetType.Model;
getModel(created.assetId).then((model) => Object.assign(created, { sourceName: model?.name || '' }));
getModel(created.assetId, created.projectId).then((model) =>
Object.assign(created, { sourceName: model?.name || '' })
);
});
registerHandler<TaskResponse>(ClientEventType.TaskGollmConfigureModelFromDocument, (event, created) => {
created.supportCancel = true;
Expand Down

0 comments on commit c3a8bfa

Please sign in to comment.