@@ -555,18 +555,20 @@ func isModelSelectionDone(nimCache *appsv1alpha1.NIMCache) bool {
555555}
556556
557557func getSelectedProfiles (nimCache * appsv1alpha1.NIMCache ) ([]string , error ) {
558- // Return profiles explicitly specified by the user in the spec
559- if len (nimCache .Spec .Source .NGC .Model .Profiles ) > 0 {
560- return nimCache .Spec .Source .NGC .Model .Profiles , nil
561- } else if isModelSelectionRequired (nimCache ) {
562- // Retrieve the selected profiles from the annotation
563- var selectedProfiles []string
564- if annotation , exists := nimCache .Annotations [SelectedNIMProfilesAnnotationKey ]; exists {
565- if err := json .Unmarshal ([]byte (annotation ), & selectedProfiles ); err != nil {
566- return nil , err
558+ if nimCache .Spec .Source .NGC != nil {
559+ if len (nimCache .Spec .Source .NGC .Model .Profiles ) > 0 {
560+ return nimCache .Spec .Source .NGC .Model .Profiles , nil
561+ }
562+
563+ if isModelSelectionDone (nimCache ) {
564+ var selectedProfiles []string
565+ if annotation , exists := nimCache .Annotations [SelectedNIMProfilesAnnotationKey ]; exists {
566+ if err := json .Unmarshal ([]byte (annotation ), & selectedProfiles ); err != nil {
567+ return nil , err
568+ }
567569 }
570+ return selectedProfiles , nil
568571 }
569- return selectedProfiles , nil
570572 }
571573 return nil , nil
572574}
@@ -1105,19 +1107,27 @@ func (r *NIMCacheReconciler) constructJob(ctx context.Context, nimCache *appsv1a
11051107 outputPath = fmt .Sprintf ("%v/%v" , outputPath , * nimCache .Spec .Storage .HostPath )
11061108 }
11071109 var command []string
1108- if nimCache .Spec .Source .DataStore .ModelName != nil && nimCache .Spec .Source .DataStore .CheckpointName != nil { // nolint:gocritic
1109- command = []string {"datastore-tools" , "checkpoint" , "download" , "--model-name" , * nimCache .Spec .Source .DataStore .ModelName , "--checkpoint-name" , * nimCache .Spec .Source .DataStore .CheckpointName , "--path" , outputPath , "--end-point" , nimCache .Spec .Source .DataStore .Endpoint }
1110+
1111+ if nimCache .Spec .Source .DataStore .ModelName != nil { // nolint:gocritic
1112+ hfRepo := fmt .Sprintf ("%s/%s" , nimCache .Spec .Source .DataStore .Namespace , * nimCache .Spec .Source .DataStore .ModelName )
1113+ command = []string {"huggingface-cli" , "download" , "--local-dir" , outputPath , "--repo-type" , "model" , hfRepo }
11101114 } else if nimCache .Spec .Source .DataStore .DatasetName != nil {
1111- command = []string {"datastore-tools" , "dataset" , "download" , "--dataset-name" , * nimCache .Spec .Source .DataStore .DatasetName , "--path" , outputPath , "--end-point" , nimCache .Spec .Source .DataStore .Endpoint }
1115+ hfRepo := fmt .Sprintf ("%s/%s" , nimCache .Spec .Source .DataStore .Namespace , * nimCache .Spec .Source .DataStore .DatasetName )
1116+ command = []string {"huggingface-cli" , "download" , "--local-dir" , outputPath , "--repo-type" , "dataset" , hfRepo }
11121117 } else {
1113- return nil , errors .NewBadRequest ("either datasetName or (modelName and checkpointName) must be provided" )
1118+ return nil , errors .NewBadRequest ("either modelName or datasetName must be provided" )
11141119 }
11151120 job .Spec .Template .Spec .Containers = []corev1.Container {
11161121 {
11171122 Name : NIMCacheContainerName ,
11181123 Image : nimCache .Spec .Source .DataStore .ModelPuller ,
11191124 EnvFrom : nimCache .Spec .Source .EnvFromSecrets (),
1120- Env : []corev1.EnvVar {},
1125+ Env : []corev1.EnvVar {
1126+ {
1127+ Name : "HF_ENDPOINT" ,
1128+ Value : nimCache .Spec .Source .DataStore .Endpoint ,
1129+ },
1130+ },
11211131 VolumeMounts : []corev1.VolumeMount {
11221132 {
11231133 Name : "nim-cache-volume" ,
@@ -1152,6 +1162,8 @@ func (r *NIMCacheReconciler) constructJob(ctx context.Context, nimCache *appsv1a
11521162 Name : nimCache .Spec .Source .DataStore .PullSecret ,
11531163 },
11541164 }
1165+ // Merge env with the user provided values
1166+ job .Spec .Template .Spec .Containers [0 ].Env = utils .MergeEnvVars (job .Spec .Template .Spec .Containers [0 ].Env , nimCache .Spec .Env )
11551167 } else if nimCache .Spec .Source .NGC != nil {
11561168 job .Spec .Template .Spec .Containers = []corev1.Container {
11571169 {
0 commit comments