Skip to content

Commit

Permalink
Revert "Removing NGC Home path and HF_HOME env (#202)"
Browse files Browse the repository at this point in the history
This reverts commit 425f91d.

Signed-off-by: Vishesh Tanksale <[email protected]>
  • Loading branch information
visheshtanksale committed Nov 5, 2024
1 parent 425f91d commit a7f4823
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 11 additions & 4 deletions internal/controller/nimcache_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down Expand Up @@ -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 {
Expand All @@ -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...)
}
}
Expand Down
9 changes: 6 additions & 3 deletions internal/controller/nimcache_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -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() {
Expand Down

0 comments on commit a7f4823

Please sign in to comment.