Skip to content

Commit

Permalink
Modify servingRuntimes to generate resources
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhao583 committed Jul 29, 2024
1 parent f114a86 commit cca658d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
17 changes: 12 additions & 5 deletions frontend/src/api/k8s/servingRuntimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ServingRuntimeAnnotations,
ServingRuntimeKind,
} from '~/k8sTypes';
import { CreatingServingRuntimeObject } from '~/pages/modelServing/screens/types';
import { CreatingServingRuntimeObject, SupportedModelFormatsInfo } from '~/pages/modelServing/screens/types';

Check failure on line 16 in frontend/src/api/k8s/servingRuntimes.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Replace `·CreatingServingRuntimeObject,·SupportedModelFormatsInfo·` with `⏎··CreatingServingRuntimeObject,⏎··SupportedModelFormatsInfo,⏎`

Check failure on line 16 in frontend/src/api/k8s/servingRuntimes.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Replace `·CreatingServingRuntimeObject,·SupportedModelFormatsInfo·` with `⏎··CreatingServingRuntimeObject,⏎··SupportedModelFormatsInfo,⏎`
import { ContainerResources } from '~/types';
import { getModelServingRuntimeName } from '~/pages/modelServing/utils';
import { getDisplayNameFromK8sResource, translateDisplayNameForK8s } from '~/concepts/k8s/utils';
Expand All @@ -38,7 +38,7 @@ export const assembleServingRuntime = (
externalRoute,
tokenAuth,
imageName,
modelName,
supportedModelFormatsInfo,
} = data;
const createName = isCustomServingRuntimesEnabled
? translateDisplayNameForK8s(displayName)
Expand Down Expand Up @@ -145,14 +145,21 @@ export const assembleServingRuntime = (
},
);

if (modelName) {
if (supportedModelFormatsInfo) {
const supportedModelFormatsObj: SupportedModelFormatsInfo = {
name: supportedModelFormatsInfo.name,
version: supportedModelFormatsInfo.version,
autoSelect: true,
priority: 1

Check failure on line 153 in frontend/src/api/k8s/servingRuntimes.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Insert `,`

Check failure on line 153 in frontend/src/api/k8s/servingRuntimes.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Insert `,`
};

Check failure on line 155 in frontend/src/api/k8s/servingRuntimes.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Delete `····`

Check failure on line 155 in frontend/src/api/k8s/servingRuntimes.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Delete `····`
if (
updatedServingRuntime.spec.supportedModelFormats &&
updatedServingRuntime.spec.supportedModelFormats.length >= 1
) {
updatedServingRuntime.spec.supportedModelFormats[0].name = modelName;
updatedServingRuntime.spec.supportedModelFormats[0] = supportedModelFormatsObj;
} else {
updatedServingRuntime.spec.supportedModelFormats?.push({ name: modelName });
updatedServingRuntime.spec.supportedModelFormats?.push(supportedModelFormatsObj);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ const NIMModelListSection: React.FC<NIMModelListSectionProps> = ({
getModelNames();
}, []);

const getNIMModelName = (name: string) => `nvidia-nim-${name}`;
const getSupportedModelFormatsInfo = (name: string) => {
const modelInfo = options.find((option) => option.key === name);
if (modelInfo) {
return {
name: modelInfo.key,
version: modelInfo.label.split(' - ')[1],
};
}
return { name: '', version: '' };
};

const getNIMImageName = (name: string) => {
const imageInfo = options.find((option) => option.key === name);
Expand All @@ -60,7 +69,7 @@ const NIMModelListSection: React.FC<NIMModelListSectionProps> = ({
placeholder={isEditing ? inferenceServiceData.name : 'Select NVIDIA model'}
value={inferenceServiceData.format.name}
onChange={(name) => {
setServingRuntimeData('modelName', getNIMModelName(name));
setServingRuntimeData('supportedModelFormatsInfo', getSupportedModelFormatsInfo(name));
setServingRuntimeData('imageName', getNIMImageName(name));
setInferenceServiceData('format', { name });
}}
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/pages/modelServing/screens/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export type ModelStatus = {
failedToSchedule: boolean;
};

export type SupportedModelFormatsInfo = {
name: string;
version: string;
autoSelect?: boolean;
priority?: number;
};

export type CreatingServingRuntimeObject = {
name: string;
servingRuntimeTemplateName: string;
Expand All @@ -41,7 +48,7 @@ export type CreatingServingRuntimeObject = {
tokenAuth: boolean;
tokens: ServingRuntimeToken[];
imageName?: string;
modelName?: string;
supportedModelFormatsInfo?: SupportedModelFormatsInfo;
};

export type ServingRuntimeToken = {
Expand Down

0 comments on commit cca658d

Please sign in to comment.