-
Notifications
You must be signed in to change notification settings - Fork 163
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
Config map nim model name fetch #3276
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
initialAcceleratorProfile?: AcceleratorProfileState, | ||
selectedAcceleratorProfile?: AcceleratorProfileSelectFieldState, | ||
isModelMesh?: boolean, | ||
nimPVCName?: string, | ||
): ServingRuntimeKind => { | ||
const { | ||
name: displayName, | ||
|
@@ -133,6 +134,15 @@ | |
if (!volumeMounts.find((volumeMount) => volumeMount.mountPath === '/dev/shm')) { | ||
volumeMounts.push(getshmVolumeMount()); | ||
} | ||
const updatedVolumeMounts = volumeMounts.map((volumeMount) => { | ||
if (volumeMount.name === 'nim-pvc' && nimPVCName) { | ||
return { | ||
...volumeMount, | ||
name: nimPVCName, | ||
}; | ||
} | ||
return volumeMount; | ||
}); | ||
|
||
const updatedContainer = { | ||
...container, | ||
|
@@ -145,7 +155,7 @@ | |
...containerWithoutResources, | ||
...(isModelMesh ? { resources } : {}), | ||
affinity, | ||
volumeMounts, | ||
volumeMounts: updatedVolumeMounts, | ||
}; | ||
}, | ||
); | ||
|
@@ -171,8 +181,33 @@ | |
volumes.push(getshmVolume('2Gi')); | ||
} | ||
|
||
updatedServingRuntime.spec.volumes = volumes; | ||
if (nimPVCName) { | ||
const updatedVolumes = volumes.map((volume) => { | ||
if (volume.name === 'nim-pvc') { | ||
return { | ||
...volume, | ||
name: nimPVCName, | ||
persistentVolumeClaim: { | ||
claimName: nimPVCName, | ||
}, | ||
}; | ||
} | ||
return volume; | ||
}); | ||
|
||
if (!updatedVolumes.find((volume) => volume.name === nimPVCName)) { | ||
updatedVolumes.push({ | ||
name: nimPVCName, | ||
persistentVolumeClaim: { | ||
claimName: nimPVCName, | ||
}, | ||
}); | ||
} | ||
|
||
updatedServingRuntime.spec.volumes = updatedVolumes; | ||
} else { | ||
updatedServingRuntime.spec.volumes = volumes; | ||
} | ||
return updatedServingRuntime; | ||
}; | ||
|
||
|
@@ -242,6 +277,7 @@ | |
initialAcceleratorProfile?: AcceleratorProfileState; | ||
selectedAcceleratorProfile?: AcceleratorProfileSelectFieldState; | ||
isModelMesh?: boolean; | ||
nimPVCName?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was unnecessary -- you don't support edit, updating the serving runtime is not done currently. |
||
}): Promise<ServingRuntimeKind> => { | ||
const { | ||
data, | ||
|
@@ -251,6 +287,7 @@ | |
initialAcceleratorProfile, | ||
selectedAcceleratorProfile, | ||
isModelMesh, | ||
nimPVCName, | ||
} = options; | ||
|
||
const updatedServingRuntime = assembleServingRuntime( | ||
|
@@ -262,6 +299,7 @@ | |
initialAcceleratorProfile, | ||
selectedAcceleratorProfile, | ||
isModelMesh, | ||
nimPVCName, | ||
); | ||
|
||
return k8sUpdateResource<ServingRuntimeKind>( | ||
|
@@ -284,6 +322,7 @@ | |
initialAcceleratorProfile?: AcceleratorProfileState; | ||
selectedAcceleratorProfile?: AcceleratorProfileSelectFieldState; | ||
isModelMesh?: boolean; | ||
nimPVCName?: string; | ||
}): Promise<ServingRuntimeKind> => { | ||
const { | ||
data, | ||
|
@@ -294,6 +333,7 @@ | |
initialAcceleratorProfile, | ||
selectedAcceleratorProfile, | ||
isModelMesh, | ||
nimPVCName, | ||
} = options; | ||
const assembledServingRuntime = assembleServingRuntime( | ||
data, | ||
|
@@ -304,6 +344,7 @@ | |
initialAcceleratorProfile, | ||
selectedAcceleratorProfile, | ||
isModelMesh, | ||
nimPVCName, | ||
); | ||
|
||
return k8sCreateResource<ServingRuntimeKind>( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
useEffect(() => { | ||
const getModelNames = async () => { | ||
try { | ||
const modelInfos = await fetchNIMModelNames(dashboardNamespace); | ||
const modelInfos = await fetchNIMModelNames(); | ||
Check warning on line 35 in frontend/src/pages/modelServing/screens/projects/NIMServiceModal/NIMModelListSection.tsx Codecov / codecov/patchfrontend/src/pages/modelServing/screens/projects/NIMServiceModal/NIMModelListSection.tsx#L35
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your hook still has |
||
if (modelInfos && modelInfos.length > 0) { | ||
const fetchedOptions = modelInfos.flatMap((modelInfo) => | ||
modelInfo.tags.map((tag) => ({ | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,9 +9,9 @@ | |||||
export const getNGCSecretType = (isNGC: boolean): string => | ||||||
isNGC ? 'kubernetes.io/dockerconfigjson' : 'Opaque'; | ||||||
|
||||||
const getNIMSecretData = async (secretName: string): Promise<SecretKind> => { | ||||||
export const getNIMResource = async (resourceName: string): Promise<SecretKind> => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not just a
Suggested change
In your one location you call this, you'll want to call it like:
See my next comment. |
||||||
try { | ||||||
const response = await fetch(`/api/nim-serving/${secretName}`, { | ||||||
const response = await fetch(`/api/nim-serving/${resourceName}`, { | ||||||
method: 'GET', | ||||||
headers: { | ||||||
'Content-Type': 'application/json', | ||||||
|
@@ -21,16 +21,16 @@ | |||||
if (!response.ok) { | ||||||
throw new Error(`Error fetching secret: ${response.statusText}`); | ||||||
} | ||||||
const secretData = await response.json(); | ||||||
return secretData.body; | ||||||
const resourceData = await response.json(); | ||||||
return resourceData.body; | ||||||
} catch (error) { | ||||||
throw new Error(`Failed to fetch secret: ${secretName}.`); | ||||||
throw new Error(`Failed to fetch the resource: ${resourceName}.`); | ||||||
} | ||||||
}; | ||||||
export const getNIMData = async (isNGC: boolean): Promise<Record<string, string> | undefined> => { | ||||||
const nimSecretData: SecretKind = isNGC | ||||||
? await getNIMSecretData(NIM_NGC_SECRET_NAME) | ||||||
: await getNIMSecretData(NIM_SECRET_NAME); | ||||||
? await getNIMResource(NIM_NGC_SECRET_NAME) | ||||||
: await getNIMResource(NIM_SECRET_NAME); | ||||||
|
||||||
if (!nimSecretData.data) { | ||||||
throw new Error(`Error retrieving NIM ${isNGC ? 'NGC' : ''} secret data`); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -40,15 +40,18 @@ import { | |||||
createPvc, | ||||||
createSecret, | ||||||
createServingRuntime, | ||||||
getConfigMap, | ||||||
updateInferenceService, | ||||||
updateServingRuntime, | ||||||
} from '~/api'; | ||||||
import { isDataConnectionAWS } from '~/pages/projects/screens/detail/data-connections/utils'; | ||||||
import { removeLeadingSlash } from '~/utilities/string'; | ||||||
import { RegisteredModelDeployInfo } from '~/pages/modelRegistry/screens/RegisteredModels/useRegisteredModelDeployInfo'; | ||||||
import { AcceleratorProfileSelectFieldState } from '~/pages/notebookController/screens/server/AcceleratorProfileSelectField'; | ||||||
import { getNGCSecretType, getNIMData } from '~/pages/modelServing/screens/projects/nimUtils'; | ||||||
import { | ||||||
getNGCSecretType, | ||||||
getNIMData, | ||||||
getNIMResource, | ||||||
} from '~/pages/modelServing/screens/projects/nimUtils'; | ||||||
|
||||||
const NIM_CONFIGMAP_NAME = 'nvidia-nim-images-data'; | ||||||
|
||||||
|
@@ -449,6 +452,7 @@ export const getSubmitServingRuntimeResourcesFn = ( | |||||
currentProject?: ProjectKind, | ||||||
name?: string, | ||||||
isModelMesh?: boolean, | ||||||
nimPVCName?: string, | ||||||
): ((opts: { dryRun?: boolean }) => Promise<void | (string | void | ServingRuntimeKind)[]>) => { | ||||||
if (!servingRuntimeSelected) { | ||||||
return () => | ||||||
|
@@ -498,6 +502,7 @@ export const getSubmitServingRuntimeResourcesFn = ( | |||||
selectedAcceleratorProfile: controlledState, | ||||||
initialAcceleratorProfile, | ||||||
isModelMesh, | ||||||
nimPVCName, | ||||||
}), | ||||||
setUpTokenAuth( | ||||||
servingRuntimeData, | ||||||
|
@@ -524,6 +529,7 @@ export const getSubmitServingRuntimeResourcesFn = ( | |||||
selectedAcceleratorProfile: controlledState, | ||||||
initialAcceleratorProfile, | ||||||
isModelMesh, | ||||||
nimPVCName, | ||||||
}).then((servingRuntime) => | ||||||
setUpTokenAuth( | ||||||
servingRuntimeData, | ||||||
|
@@ -579,10 +585,8 @@ export interface ModelInfo { | |||||
updatedDate: string; | ||||||
} | ||||||
|
||||||
export const fetchNIMModelNames = async ( | ||||||
dashboardNamespace: string, | ||||||
): Promise<ModelInfo[] | undefined> => { | ||||||
const configMap = await getConfigMap(dashboardNamespace, NIM_CONFIGMAP_NAME); | ||||||
export const fetchNIMModelNames = async (): Promise<ModelInfo[] | undefined> => { | ||||||
const configMap = await getNIMResource(NIM_CONFIGMAP_NAME); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (configMap.data && Object.keys(configMap.data).length > 0) { | ||||||
const modelInfos: ModelInfo[] = []; | ||||||
for (const [key, value] of Object.entries(configMap.data)) { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should never have been here -- you folks need to work on lowering your points of contact when fixing a blocker fix. You snuck this PVC thing into a high trafficked area for 2 other flows you're not touching instead of just adding this to your serving runtime template before ever calling this flow.
This change has already been tested and I'm going to let it in. But please do not sneak more "nice to have" code in when you need to fix critical blocking issues.