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

NIM deployment #3265

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions frontend/src/k8sTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ export type ServingContainer = {
affinity?: PodAffinity;
resources?: ContainerResources;
volumeMounts?: VolumeMount[];
env?: {
name: string;
value?: string;
valueFrom?: {
secretKeyRef?: {
name: string;
key: string;
};
};
}[];
};

export type ServingRuntimeKind = K8sResourceCommon & {
Expand All @@ -430,6 +440,7 @@ export type ServingRuntimeKind = K8sResourceCommon & {
replicas?: number;
tolerations?: Toleration[];
volumes?: Volume[];
imagePullSecrets?: { name: string }[];
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import DeleteModal from '~/pages/projects/components/DeleteModal';
import { InferenceServiceKind, ServingRuntimeKind } from '~/k8sTypes';
import { deleteInferenceService, deletePvc, deleteServingRuntime } from '~/api';
import { deleteInferenceService, deletePvc, deleteSecret, deleteServingRuntime } from '~/api';
import { getDisplayNameFromK8sResource } from '~/concepts/k8s/utils';
import { byName, ProjectsContext } from '~/concepts/projects/ProjectsContext';
import { isProjectNIMSupported } from '~/pages/modelServing/screens/projects/nimUtils';
Expand Down Expand Up @@ -48,6 +48,14 @@
const pvcName = servingRuntime?.spec.volumes?.find(
(vol) => vol.persistentVolumeClaim?.claimName,
)?.persistentVolumeClaim?.claimName;
const containerWithEnv = servingRuntime?.spec.containers.find(
(container) =>
container.env && container.env.some((env) => env.valueFrom?.secretKeyRef?.name),
);
const nimSecretName = containerWithEnv?.env?.find(
(env) => env.valueFrom?.secretKeyRef?.name,
)?.valueFrom?.secretKeyRef?.name;
const imagePullSecretName = servingRuntime?.spec.imagePullSecrets?.[0]?.name ?? '';
Promise.all([
deleteInferenceService(
inferenceService.metadata.name,
Expand All @@ -64,6 +72,16 @@
...(isKServeNIMEnabled && pvcName
? [deletePvc(pvcName, inferenceService.metadata.namespace)]
: []),
...(isKServeNIMEnabled &&
project &&
nimSecretName &&
nimSecretName.length > 0 &&
imagePullSecretName.length > 0
? [

Check warning on line 80 in frontend/src/pages/modelServing/screens/global/DeleteInferenceServiceModal.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/modelServing/screens/global/DeleteInferenceServiceModal.tsx#L76-L80

Added lines #L76 - L80 were not covered by tests
deleteSecret(project.metadata.name, nimSecretName),
deleteSecret(project.metadata.name, imagePullSecretName),
Comment on lines +81 to +82
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. if you don't find these names, you'll fire off requests to no effect -- probably could write this logic a little more defensive and build out something to spread into the Promise.all before based on the various conditions

]
: []),
])

.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import { useIsNIMAvailable } from '~/pages/modelServing/screens/projects/useIsNIMAvailable';
import { isProjectNIMSupported } from '~/pages/modelServing/screens/projects/nimUtils';
import { useDashboardNamespace } from '~/redux/selectors';
import DeployNIMServiceModal from '~/pages/modelServing/screens/projects/NIMServiceModal/DeployNIMServiceModal';
import ManageServingRuntimeModal from './ServingRuntimeModal/ManageServingRuntimeModal';
import ModelMeshServingRuntimeTable from './ModelMeshSection/ServingRuntimeTable';
import ModelServingPlatformButtonAction from './ModelServingPlatformButtonAction';
Expand Down Expand Up @@ -275,6 +276,15 @@
onSubmit(submit);
}}
/>
{isNIMAvailable && (
<DeployNIMServiceModal

Check warning on line 280 in frontend/src/pages/modelServing/screens/projects/ModelServingPlatform.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/modelServing/screens/projects/ModelServingPlatform.tsx#L280

Added line #L280 was not covered by tests
isOpen={platformSelected === ServingRuntimePlatform.SINGLE}
projectContext={{ currentProject, dataConnections }}
onClose={(submit: boolean) => {
onSubmit(submit);

Check warning on line 284 in frontend/src/pages/modelServing/screens/projects/ModelServingPlatform.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/modelServing/screens/projects/ModelServingPlatform.tsx#L283-L284

Added lines #L283 - L284 were not covered by tests
}}
/>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
const [actionInProgress, setActionInProgress] = React.useState(false);
const [error, setError] = React.useState<Error | undefined>();
const [alertVisible, setAlertVisible] = React.useState(true);
const [pvcSize, setPvcSize] = React.useState<string>('');
const [pvcSize, setPvcSize] = React.useState<string>('30Gi');

Check warning on line 129 in frontend/src/pages/modelServing/screens/projects/NIMServiceModal/DeployNIMServiceModal.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/modelServing/screens/projects/NIMServiceModal/DeployNIMServiceModal.tsx#L129

Added line #L129 was not covered by tests

React.useEffect(() => {
if (currentProjectName && isOpen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const NIMModelListSection: React.FC<NIMModelListSectionProps> = ({
return (
<FormGroup label="NVIDIA NIM" fieldId="nim-model-list-selection" isRequired>
<SimpleSelect
isScrollable
isFullWidth
isDisabled={isEditing || options.length === 0}
id="nim-model-list-selection"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/modelServing/screens/projects/nimUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
throw new Error(`Error fetching secret: ${response.statusText}`);
}
const secretData = await response.json();
return secretData;
return secretData.body;

Check warning on line 25 in frontend/src/pages/modelServing/screens/projects/nimUtils.ts

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/modelServing/screens/projects/nimUtils.ts#L25

Added line #L25 was not covered by tests
} catch (error) {
throw new Error(`Failed to fetch secret: ${secretName}.`);
}
};
export const getNIMData = async (isNGC: boolean): Promise<Record<string, string> | undefined> => {
const nimSecretData = isNGC
const nimSecretData: SecretKind = isNGC
? await getNIMSecretData(NIM_NGC_SECRET_NAME)
: await getNIMSecretData(NIM_SECRET_NAME);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import AddModelFooter from '~/pages/projects/screens/detail/overview/serverModel
import { InferenceServiceKind } from '~/k8sTypes';
import { ProjectSectionID } from '~/pages/projects/screens/detail/types';
import ModelServingContextProvider from '~/pages/modelServing/ModelServingContext';
import { isProjectNIMSupported } from '~/pages/modelServing/screens/projects/nimUtils';
import DeployedModelsCard from './DeployedModelsCard';

interface DeployedModelsSectionProps {
Expand All @@ -53,6 +54,8 @@ const DeployedModelsSection: React.FC<DeployedModelsSectionProps> = ({ isMultiPl
);
const [deployedModels, setDeployedModels] = React.useState<InferenceServiceKind[]>([]);

const isKServeNIMEnabled = isProjectNIMSupported(currentProject);

React.useEffect(() => {
if (!inferenceServicesLoaded || !modelServersLoaded) {
return;
Expand Down Expand Up @@ -176,7 +179,7 @@ const DeployedModelsSection: React.FC<DeployedModelsSectionProps> = ({ isMultiPl
</TextContent>
)}
</CardBody>
{!platformError ? <AddModelFooter /> : null}
{!platformError ? <AddModelFooter isNIM={isKServeNIMEnabled} /> : null}
</OverviewCard>
);
}
Expand Down
Loading