-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Olga Lavtar <[email protected]>
- Loading branch information
Showing
14 changed files
with
815 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
frontend/src/pages/modelServing/screens/projects/EmptyNIMModelServingCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
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: [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="nvidia-nim-model-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="nim-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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.