Skip to content

Commit

Permalink
Merge pull request #1 from yzhao583/nim-integration-demo
Browse files Browse the repository at this point in the history
nim-integration-demo
  • Loading branch information
yzhao583 authored Apr 24, 2024
2 parents 6391d08 + fb98d89 commit 9b11a44
Show file tree
Hide file tree
Showing 12 changed files with 675 additions and 35 deletions.
6 changes: 3 additions & 3 deletions frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ODH_IS_PROJECT_ROOT_DIR=false
ODH_PORT=${FRONTEND_PORT}

########## Change the following three variables for ODH/OpenShift AI ##########
ODH_LOGO=odh-logo.svg
ODH_PRODUCT_NAME=Open Data Hub
ODH_FAVICON=odh-favicon.svg
ODH_LOGO=rhoai-logo.svg
ODH_PRODUCT_NAME=Red Hat OpenShift AI
ODH_FAVICON=rhoai-favicon.svg
ODH_NOTEBOOK_REPO=opendatahub
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import * as React from 'react';
import {
Bullseye,
Card,
CardBody,
CardFooter,
CardTitle,
Text,
TextContent,
TextVariants
} from '@patternfly/react-core';
import { ProjectDetailsContext } from '~/pages/projects/ProjectDetailsContext';
import { ServingRuntimePlatform } from '~/types';
import {
getSortedTemplates,
getTemplateEnabled,
getTemplateEnabledForPlatform,
} from '~/pages/modelServing/customServingRuntimes/utils';
import ModelServingPlatformButtonAction from '~/pages/modelServing/screens/projects/ModelServingPlatformButtonAction';
import DeployNIMServiceModal from './NIMServiceModal/DeployNIMServiceModal';

const EmptyNIMModelServingCard: React.FC = () => {
const {
dataConnections: { data: dataConnections },
} = React.useContext(ProjectDetailsContext);
const [open, setOpen] = React.useState(false);

const {
servingRuntimes: { refresh: refreshServingRuntime },
servingRuntimeTemplates: { data: templates },
servingRuntimeTemplateOrder: { data: templateOrder },
servingRuntimeTemplateDisablement: { data: templateDisablement },
serverSecrets: { refresh: refreshTokens },
inferenceServices: { refresh: refreshInferenceServices },
currentProject,
} = React.useContext(ProjectDetailsContext);

const onSubmit = (submit: boolean) => {
if (submit) {
refreshServingRuntime();
refreshInferenceServices();
setTimeout(refreshTokens, 500); // need a timeout to wait for tokens creation
}
};

const templatesSorted = getSortedTemplates(templates, templateOrder);
const templatesEnabled = templatesSorted.filter((template) =>
getTemplateEnabled(template, templateDisablement),
);
const emptyTemplates = templatesEnabled.length === 0;

return (
<>
<Card
style={{
height: '100%',
border: '1px solid var(--pf-v5-global--BorderColor--100)',
borderRadius: 16,
}}
data-testid="single-serving-platform-card"
>
<CardTitle>
<TextContent>
<Text component={TextVariants.h2}>NVIDIA NIM model serving platform</Text>
</TextContent>
</CardTitle>
<CardBody>
Models are deployed using NVIDIA NIM microservices. Choose this option when you want to deploy your model within a NIM container. Please provide the API key to authenticate with the NIM service.
</CardBody>
<CardFooter>
<Bullseye>
<ModelServingPlatformButtonAction
isProjectModelMesh={false}
emptyTemplates={emptyTemplates}
onClick={() => setOpen(true)}
variant="secondary"
testId="single-serving-deploy-button"
/>
</Bullseye>
</CardFooter>
</Card>
<DeployNIMServiceModal
isOpen={open}
projectContext={{
currentProject,
dataConnections,
}}
servingRuntimeTemplates={templatesEnabled.filter((template) =>
getTemplateEnabledForPlatform(template, ServingRuntimePlatform.SINGLE),
)}
onClose={(submit) => {
onSubmit(submit);
setOpen(false);
}}
/>
</>
);
};

export default EmptyNIMModelServingCard;
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import DetailsSection from '~/pages/projects/screens/detail/DetailsSection';
import EmptyDetailsView from '~/components/EmptyDetailsView';
import EmptySingleModelServingCard from '~/pages/modelServing/screens/projects/EmptySingleModelServingCard';
import EmptyMultiModelServingCard from '~/pages/modelServing/screens/projects/EmptyMultiModelServingCard';
import EmptyNIMModelServingCard from '~/pages/modelServing/screens/projects/EmptyNIMModelServingCard';
import { ProjectObjectType, typedEmptyImage } from '~/concepts/design/utils';
import EmptyModelServingPlatform from '~/pages/modelServing/screens/projects/EmptyModelServingPlatform';
import ManageServingRuntimeModal from './ServingRuntimeModal/ManageServingRuntimeModal';
Expand Down Expand Up @@ -197,6 +198,9 @@ const ModelServingPlatform: React.FC = () => {
<GalleryItem>
<EmptyMultiModelServingCard />
</GalleryItem>
<GalleryItem>
<EmptyNIMModelServingCard />
</GalleryItem>
</Gallery>
</StackItem>
<StackItem>
Expand Down
Loading

0 comments on commit 9b11a44

Please sign in to comment.