From a7f4823176c14367273c594e72afd4d8d9fcd394 Mon Sep 17 00:00:00 2001 From: Vishesh Tanksale Date: Tue, 5 Nov 2024 23:04:43 +0000 Subject: [PATCH] Revert "Removing NGC Home path and HF_HOME env (#202)" This reverts commit 425f91d8f5bff1a736b678f5b78d2f33233d2ff0. Signed-off-by: Vishesh Tanksale --- internal/controller/nimcache_controller.go | 15 +++++++++++---- internal/controller/nimcache_controller_test.go | 9 ++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/internal/controller/nimcache_controller.go b/internal/controller/nimcache_controller.go index 15f99435..a3aa735c 100644 --- a/internal/controller/nimcache_controller.go +++ b/internal/controller/nimcache_controller.go @@ -1075,13 +1075,21 @@ func (r *NIMCacheReconciler) constructJob(ctx context.Context, nimCache *appsv1a { Name: NIMCacheContainerName, Image: nimCache.Spec.Source.NGC.ModelPuller, - Args: []string{"download-to-cache"}, + Command: []string{"download-to-cache"}, EnvFrom: nimCache.Spec.Source.EnvFromSecrets(), Env: []corev1.EnvVar{ + { + Name: "HF_HOME", + Value: "/model-store/huggingface", + }, { Name: "NIM_CACHE_PATH", Value: "/model-store", }, + { + Name: "NGC_HOME", + Value: "/model-store/ngc", + }, }, VolumeMounts: []corev1.VolumeMount{ { @@ -1118,7 +1126,6 @@ func (r *NIMCacheReconciler) constructJob(ctx context.Context, nimCache *appsv1a Name: nimCache.Spec.Source.NGC.PullSecret, }, } - // Pass specific profiles to download based on user selection or auto-selection selectedProfiles, err := getSelectedProfiles(nimCache) if err != nil { @@ -1132,9 +1139,9 @@ func (r *NIMCacheReconciler) constructJob(ctx context.Context, nimCache *appsv1a if len(selectedProfiles) > 0 { if utils.ContainsElement(selectedProfiles, AllProfiles) { - job.Spec.Template.Spec.Containers[0].Args = append(job.Spec.Template.Spec.Containers[0].Args, "--all") + job.Spec.Template.Spec.Containers[0].Args = []string{"--all"} } else { - job.Spec.Template.Spec.Containers[0].Args = append(job.Spec.Template.Spec.Containers[0].Args, "--profiles") + job.Spec.Template.Spec.Containers[0].Args = []string{"--profiles"} job.Spec.Template.Spec.Containers[0].Args = append(job.Spec.Template.Spec.Containers[0].Args, selectedProfiles...) } } diff --git a/internal/controller/nimcache_controller_test.go b/internal/controller/nimcache_controller_test.go index 35e184c2..b2d4bc13 100644 --- a/internal/controller/nimcache_controller_test.go +++ b/internal/controller/nimcache_controller_test.go @@ -393,7 +393,8 @@ var _ = Describe("NIMCache Controller", func() { Expect(job.Name).To(Equal(getJobName(nimCache))) Expect(job.Spec.Template.Spec.Containers[0].Image).To(Equal("nvcr.io/nim:test")) Expect(job.Spec.Template.Spec.ImagePullSecrets[0].Name).To(Equal("my-secret")) - Expect(job.Spec.Template.Spec.Containers[0].Args).To(ContainElements("download-to-cache", "--profiles", "36fc1fa4fc35c1d54da115a39323080b08d7937dceb8ba47be44f4da0ec720ff")) + Expect(job.Spec.Template.Spec.Containers[0].Command).To(ContainElements("download-to-cache")) + Expect(job.Spec.Template.Spec.Containers[0].Args).To(ContainElements("--profiles", "36fc1fa4fc35c1d54da115a39323080b08d7937dceb8ba47be44f4da0ec720ff")) Expect(*job.Spec.Template.Spec.SecurityContext.RunAsUser).To(Equal(int64(1000))) Expect(*job.Spec.Template.Spec.SecurityContext.FSGroup).To(Equal(int64(2000))) Expect(*job.Spec.Template.Spec.SecurityContext.RunAsNonRoot).To(Equal(true)) @@ -423,7 +424,8 @@ var _ = Describe("NIMCache Controller", func() { Expect(job.Name).To(Equal(getJobName(nimCache))) Expect(job.Spec.Template.Spec.Containers[0].Image).To(Equal("nvcr.io/nim:test")) Expect(job.Spec.Template.Spec.ImagePullSecrets[0].Name).To(Equal("my-secret")) - Expect(job.Spec.Template.Spec.Containers[0].Args).To(ContainElements("download-to-cache", "--profiles", "36fc1fa4fc35c1d54da115a39323080b08d7937dceb8ba47be44f4da0ec720ff", "04fdb4d11f01be10c31b00e7c0540e2835e89a0079b483ad2dd3c25c8cc12345")) + Expect(job.Spec.Template.Spec.Containers[0].Command).To(ContainElements("download-to-cache")) + Expect(job.Spec.Template.Spec.Containers[0].Args).To(ContainElements("--profiles", "36fc1fa4fc35c1d54da115a39323080b08d7937dceb8ba47be44f4da0ec720ff", "04fdb4d11f01be10c31b00e7c0540e2835e89a0079b483ad2dd3c25c8cc12345")) Expect(*job.Spec.Template.Spec.SecurityContext.RunAsUser).To(Equal(int64(1000))) Expect(*job.Spec.Template.Spec.SecurityContext.FSGroup).To(Equal(int64(2000))) Expect(*job.Spec.Template.Spec.SecurityContext.RunAsNonRoot).To(Equal(true)) @@ -449,7 +451,8 @@ var _ = Describe("NIMCache Controller", func() { Expect(job.Name).To(Equal(getJobName(nimCache))) Expect(job.Spec.Template.Spec.Containers[0].Image).To(Equal("nvcr.io/nim:test")) Expect(job.Spec.Template.Spec.ImagePullSecrets[0].Name).To(Equal("my-secret")) - Expect(job.Spec.Template.Spec.Containers[0].Args).To(ContainElements("download-to-cache", "--all")) + Expect(job.Spec.Template.Spec.Containers[0].Command).To(ContainElements("download-to-cache")) + Expect(job.Spec.Template.Spec.Containers[0].Args).To(ContainElements("--all")) }) It("should create a job with the correct specifications", func() {