Skip to content
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

Revert "Removing NGC Home path and HF_HOME env (#202)" #213

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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