Skip to content

Commit 05ba8c8

Browse files
committed
Add seperate entry and validation string for NeMo and external dataSource in NIMCache
Signed-off-by: Sheng Lin <shelin@nvidia.com>
1 parent f2d2247 commit 05ba8c8

7 files changed

Lines changed: 316 additions & 66 deletions

File tree

api/apps/v1alpha1/nimcache_types.go

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,52 @@ type NIMCacheSpec struct {
5858
Proxy *ProxySpec `json:"proxy,omitempty"`
5959
}
6060

61+
// +kubebuilder:validation:XValidation:rule="(has(self.ngc) ? 1 : 0) + (has(self.dataStore) ? 1 : 0) + (has(self.externalDataStore) ? 1 : 0) == 1",message="Exactly one of ngc, dataStore, or externalDataStore must be defined"
6162
// NIMSource defines the source for caching NIM model.
6263
type NIMSource struct {
6364
// NGCSource represents models stored in NGC
6465
NGC *NGCSource `json:"ngc,omitempty"`
6566

66-
// NGCSource represents models stored in NVIDIA DataStore service
67-
DataStore *DataStoreSource `json:"dataStore,omitempty"`
67+
// DataStore represents models stored in NVIDIA NeMo DataStore service
68+
DataStore *NemoDataStoreSource `json:"dataStore,omitempty"`
69+
// ExternalDataStore represents models stored in external data store
70+
ExternalDataStore *ExternalDataStoreSource `json:"externalDataStore,omitempty"`
71+
}
72+
73+
// +kubebuilder:validation:XValidation:rule="(has(self.modelName) ? 1 : 0) + (has(self.datasetName) ? 1 : 0) == 1",message="Exactly one of modelName or datasetName must be defined"
74+
type DataStoreFields struct {
75+
// modelName is the name of the model
76+
ModelName *string `json:"modelName,omitempty"`
77+
// datasetName is the name of the dataset
78+
DatasetName *string `json:"datasetName,omitempty"`
79+
// authSecret is the name of the secret containing the "HF_TOKEN" token
80+
// +kubebuilder:validation:MinLength=1
81+
AuthSecret string `json:"authSecret"`
82+
// modelPuller is the containerized huggingface-cli image to pull the data
83+
// +kubebuilder:validation:MinLength=1
84+
ModelPuller string `json:"modelPuller"`
85+
// pullSecret is the name of the image pull secret for the modelPuller image
86+
// +kubebuilder:validation:MinLength=1
87+
PullSecret string `json:"pullSecret,omitempty"`
88+
}
89+
90+
type NemoDataStoreSource struct {
91+
// Endpoint is the HuggingFace endpoint from NeMo DataStore
92+
// +kubebuilder:validation:Pattern=`^https?://.*/v1/hf/?$`
93+
Endpoint string `json:"endpoint"`
94+
// Namespace is the namespace for the data
95+
// +kubebuilder:default="default"
96+
Namespace string `json:"namespace"`
97+
DataStoreFields `json:",inline"`
98+
}
99+
100+
type ExternalDataStoreSource struct {
101+
// Endpoint is the HuggingFace endpoint
102+
// +kubebuilder:validation:Pattern=`^https?://.*$`
103+
Endpoint string `json:"endpoint"`
104+
// +kubebuilder:validation:MinLength=1
105+
Namespace string `json:"namespace"`
106+
DataStoreFields `json:",inline"`
68107
}
69108

70109
// NGCSource references a model stored on NVIDIA NGC.
@@ -108,26 +147,6 @@ type GPUSpec struct {
108147
IDs []string `json:"ids,omitempty"`
109148
}
110149

111-
// DataStoreSource references a model stored on NVIDIA DataStore service.
112-
type DataStoreSource struct {
113-
// HF-compatible datastore endpoint
114-
// +kubebuilder:validation:Pattern=`^http(s)?://.*$`
115-
Endpoint string `json:"endpoint"`
116-
// +kubebuilder:default="default"
117-
Namespace string `json:"namespace"`
118-
119-
// Name of either model or dataset to download
120-
ModelName *string `json:"modelName,omitempty"`
121-
DatasetName *string `json:"datasetName,omitempty"`
122-
123-
// The name of an existing auth secret containing the HF_TOKEN
124-
AuthSecret string `json:"authSecret"`
125-
// ModelPuller is the container image that can pull the model
126-
ModelPuller string `json:"modelPuller"`
127-
// PullSecret for the model puller image
128-
PullSecret string `json:"pullSecret,omitempty"`
129-
}
130-
131150
// NIMCacheStorage defines the attributes of various storage targets used to store the model.
132151
type NIMCacheStorage struct {
133152
// PersistentVolumeClaim is the pvc volume used for caching NIM

api/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 42 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/apps.nvidia.com_nimcaches.yaml

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,38 +239,91 @@ spec:
239239
description: Source is the NIM model source to cache
240240
properties:
241241
dataStore:
242-
description: NGCSource represents models stored in NVIDIA DataStore
243-
service
242+
description: DataStore represents models stored in NVIDIA NeMo
243+
DataStore service
244244
properties:
245245
authSecret:
246-
description: The name of an existing auth secret containing
247-
the HF_TOKEN
246+
description: authSecret is the name of the secret containing
247+
the "HF_TOKEN" token
248+
minLength: 1
248249
type: string
249250
datasetName:
251+
description: datasetName is the name of the dataset
250252
type: string
251253
endpoint:
252-
description: HF-compatible datastore endpoint
253-
pattern: ^http(s)?://.*$
254+
description: Endpoint is the HuggingFace endpoint from NeMo
255+
DataStore
256+
pattern: ^https?://.*/v1/hf/?$
254257
type: string
255258
modelName:
256-
description: Name of either model or dataset to download
259+
description: modelName is the name of the model
257260
type: string
258261
modelPuller:
259-
description: ModelPuller is the container image that can pull
260-
the model
262+
description: modelPuller is the containerized huggingface-cli
263+
image to pull the data
264+
minLength: 1
261265
type: string
262266
namespace:
263267
default: default
268+
description: Namespace is the namespace for the data
269+
type: string
270+
pullSecret:
271+
description: pullSecret is the name of the image pull secret
272+
for the modelPuller image
273+
minLength: 1
274+
type: string
275+
required:
276+
- authSecret
277+
- endpoint
278+
- modelPuller
279+
- namespace
280+
type: object
281+
x-kubernetes-validations:
282+
- message: Exactly one of modelName or datasetName must be defined
283+
rule: '(has(self.modelName) ? 1 : 0) + (has(self.datasetName)
284+
? 1 : 0) == 1'
285+
externalDataStore:
286+
description: ExternalDataStore represents models stored in external
287+
data store
288+
properties:
289+
authSecret:
290+
description: authSecret is the name of the secret containing
291+
the "HF_TOKEN" token
292+
minLength: 1
293+
type: string
294+
datasetName:
295+
description: datasetName is the name of the dataset
296+
type: string
297+
endpoint:
298+
description: Endpoint is the HuggingFace endpoint
299+
pattern: ^https?://.*$
300+
type: string
301+
modelName:
302+
description: modelName is the name of the model
303+
type: string
304+
modelPuller:
305+
description: modelPuller is the containerized huggingface-cli
306+
image to pull the data
307+
minLength: 1
308+
type: string
309+
namespace:
310+
minLength: 1
264311
type: string
265312
pullSecret:
266-
description: PullSecret for the model puller image
313+
description: pullSecret is the name of the image pull secret
314+
for the modelPuller image
315+
minLength: 1
267316
type: string
268317
required:
269318
- authSecret
270319
- endpoint
271320
- modelPuller
272321
- namespace
273322
type: object
323+
x-kubernetes-validations:
324+
- message: Exactly one of modelName or datasetName must be defined
325+
rule: '(has(self.modelName) ? 1 : 0) + (has(self.datasetName)
326+
? 1 : 0) == 1'
274327
ngc:
275328
description: NGCSource represents models stored in NGC
276329
properties:
@@ -349,6 +402,11 @@ spec:
349402
- modelPuller
350403
type: object
351404
type: object
405+
x-kubernetes-validations:
406+
- message: Exactly one of ngc, dataStore, or externalDataStore must
407+
be defined
408+
rule: '(has(self.ngc) ? 1 : 0) + (has(self.dataStore) ? 1 : 0) +
409+
(has(self.externalDataStore) ? 1 : 0) == 1'
352410
storage:
353411
description: Storage is the target storage for caching NIM model
354412
properties:

config/crd/bases/apps.nvidia.com_nimcaches.yaml

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,38 +239,91 @@ spec:
239239
description: Source is the NIM model source to cache
240240
properties:
241241
dataStore:
242-
description: NGCSource represents models stored in NVIDIA DataStore
243-
service
242+
description: DataStore represents models stored in NVIDIA NeMo
243+
DataStore service
244244
properties:
245245
authSecret:
246-
description: The name of an existing auth secret containing
247-
the HF_TOKEN
246+
description: authSecret is the name of the secret containing
247+
the "HF_TOKEN" token
248+
minLength: 1
248249
type: string
249250
datasetName:
251+
description: datasetName is the name of the dataset
250252
type: string
251253
endpoint:
252-
description: HF-compatible datastore endpoint
253-
pattern: ^http(s)?://.*$
254+
description: Endpoint is the HuggingFace endpoint from NeMo
255+
DataStore
256+
pattern: ^https?://.*/v1/hf/?$
254257
type: string
255258
modelName:
256-
description: Name of either model or dataset to download
259+
description: modelName is the name of the model
257260
type: string
258261
modelPuller:
259-
description: ModelPuller is the container image that can pull
260-
the model
262+
description: modelPuller is the containerized huggingface-cli
263+
image to pull the data
264+
minLength: 1
261265
type: string
262266
namespace:
263267
default: default
268+
description: Namespace is the namespace for the data
269+
type: string
270+
pullSecret:
271+
description: pullSecret is the name of the image pull secret
272+
for the modelPuller image
273+
minLength: 1
274+
type: string
275+
required:
276+
- authSecret
277+
- endpoint
278+
- modelPuller
279+
- namespace
280+
type: object
281+
x-kubernetes-validations:
282+
- message: Exactly one of modelName or datasetName must be defined
283+
rule: '(has(self.modelName) ? 1 : 0) + (has(self.datasetName)
284+
? 1 : 0) == 1'
285+
externalDataStore:
286+
description: ExternalDataStore represents models stored in external
287+
data store
288+
properties:
289+
authSecret:
290+
description: authSecret is the name of the secret containing
291+
the "HF_TOKEN" token
292+
minLength: 1
293+
type: string
294+
datasetName:
295+
description: datasetName is the name of the dataset
296+
type: string
297+
endpoint:
298+
description: Endpoint is the HuggingFace endpoint
299+
pattern: ^https?://.*$
300+
type: string
301+
modelName:
302+
description: modelName is the name of the model
303+
type: string
304+
modelPuller:
305+
description: modelPuller is the containerized huggingface-cli
306+
image to pull the data
307+
minLength: 1
308+
type: string
309+
namespace:
310+
minLength: 1
264311
type: string
265312
pullSecret:
266-
description: PullSecret for the model puller image
313+
description: pullSecret is the name of the image pull secret
314+
for the modelPuller image
315+
minLength: 1
267316
type: string
268317
required:
269318
- authSecret
270319
- endpoint
271320
- modelPuller
272321
- namespace
273322
type: object
323+
x-kubernetes-validations:
324+
- message: Exactly one of modelName or datasetName must be defined
325+
rule: '(has(self.modelName) ? 1 : 0) + (has(self.datasetName)
326+
? 1 : 0) == 1'
274327
ngc:
275328
description: NGCSource represents models stored in NGC
276329
properties:
@@ -349,6 +402,11 @@ spec:
349402
- modelPuller
350403
type: object
351404
type: object
405+
x-kubernetes-validations:
406+
- message: Exactly one of ngc, dataStore, or externalDataStore must
407+
be defined
408+
rule: '(has(self.ngc) ? 1 : 0) + (has(self.dataStore) ? 1 : 0) +
409+
(has(self.externalDataStore) ? 1 : 0) == 1'
352410
storage:
353411
description: Storage is the target storage for caching NIM model
354412
properties:

0 commit comments

Comments
 (0)