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

chore(backend): use GetResourceType and GetResourceCount. Fixes #11375. #11409

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 deletions backend/src/v2/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,16 @@ func initPodSpecPatch(
}
accelerator := container.GetResources().GetAccelerator()
if accelerator != nil {
if accelerator.GetType() != "" && accelerator.GetCount() > 0 {
q, err := k8sres.ParseQuantity(fmt.Sprintf("%v", accelerator.GetCount()))
// TODO: do not ignore the err obj from the strconv function
// TODO: communicate with the team to decide to have GetResourceCount as
// int
resourceCountInt, _ := strconv.Atoi(accelerator.GetResourceCount())
if accelerator.GetResourceType() != "" && resourceCountInt > 0 {
q, err := k8sres.ParseQuantity(fmt.Sprintf("%v", resourceCountInt))
if err != nil {
return nil, fmt.Errorf("failed to init podSpecPatch: %w", err)
}
res.Limits[k8score.ResourceName(accelerator.GetType())] = q
res.Limits[k8score.ResourceName(accelerator.GetResourceType())] = q
}
}
podSpec := &k8score.PodSpec{
Expand Down Expand Up @@ -2021,7 +2025,7 @@ func createCache(
fmt.Errorf("failed to get id from createdExecution")
}
task := &api.Task{
//TODO how to differentiate between shared pipeline and namespaced pipeline
// TODO how to differentiate between shared pipeline and namespaced pipeline
PipelineName: "pipeline/" + opts.PipelineName,
Namespace: opts.Namespace,
RunId: opts.RunID,
Expand Down
20 changes: 10 additions & 10 deletions backend/src/v2/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func Test_initPodSpecPatch_acceleratorConfig(t *testing.T) {
CpuLimit: 1.0,
MemoryLimit: 0.65,
Accelerator: &pipelinespec.PipelineDeploymentConfig_PipelineContainerSpec_ResourceSpec_AcceleratorConfig{
Type: "nvidia.com/gpu",
Count: 1,
ResourceType: "nvidia.com/gpu",
ResourceCount: "1",
},
},
},
Expand Down Expand Up @@ -96,8 +96,8 @@ func Test_initPodSpecPatch_acceleratorConfig(t *testing.T) {
CpuLimit: 1.0,
MemoryLimit: 0.65,
Accelerator: &pipelinespec.PipelineDeploymentConfig_PipelineContainerSpec_ResourceSpec_AcceleratorConfig{
Type: "amd.com/gpu",
Count: 1,
ResourceType: "amd.com/gpu",
ResourceCount: "1",
},
},
},
Expand Down Expand Up @@ -135,8 +135,8 @@ func Test_initPodSpecPatch_acceleratorConfig(t *testing.T) {
CpuLimit: 1.0,
MemoryLimit: 0.65,
Accelerator: &pipelinespec.PipelineDeploymentConfig_PipelineContainerSpec_ResourceSpec_AcceleratorConfig{
Type: "cloud-tpus.google.com/v3",
Count: 1,
ResourceType: "cloud-tpus.google.com/v3",
ResourceCount: "1",
},
},
},
Expand Down Expand Up @@ -174,8 +174,8 @@ func Test_initPodSpecPatch_acceleratorConfig(t *testing.T) {
CpuLimit: 1.0,
MemoryLimit: 0.65,
Accelerator: &pipelinespec.PipelineDeploymentConfig_PipelineContainerSpec_ResourceSpec_AcceleratorConfig{
Type: "cloud-tpus.google.com/v2",
Count: 1,
ResourceType: "cloud-tpus.google.com/v2",
ResourceCount: "1",
},
},
},
Expand Down Expand Up @@ -213,8 +213,8 @@ func Test_initPodSpecPatch_acceleratorConfig(t *testing.T) {
CpuLimit: 1.0,
MemoryLimit: 0.65,
Accelerator: &pipelinespec.PipelineDeploymentConfig_PipelineContainerSpec_ResourceSpec_AcceleratorConfig{
Type: "custom.example.com/accelerator-v1",
Count: 1,
ResourceType: "custom.example.com/accelerator-v1",
ResourceCount: "1",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/kubeflow/kfp-tekton/tekton-catalog/pipeline-loops v0.0.0-20231127195001-a75d4b3711ff
github.com/kubeflow/kfp-tekton/tekton-catalog/tekton-exithandler v0.0.0-20231127195001-a75d4b3711ff
github.com/kubeflow/kfp-tekton/tekton-catalog/tekton-kfptask v0.0.0-20231127195001-a75d4b3711ff
github.com/kubeflow/pipelines/api v0.0.0-20231027040853-58ce09e07d03
github.com/kubeflow/pipelines/api v0.0.0-20241126190553-5cc1b8d22116
github.com/kubeflow/pipelines/kubernetes_platform v0.0.0-20240725205754-d911c8b73b49
github.com/kubeflow/pipelines/third_party/ml-metadata v0.0.0-20230810215105-e1f0c010f800
github.com/lestrrat-go/strftime v1.0.4
Expand Down
7 changes: 4 additions & 3 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading