Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix model 500s on main page #5097

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }
YohannParis marked this conversation as resolved.
Show resolved Hide resolved
});
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