feat(sdk/python)!: align portable resource requirements

Update reusable workload template construction and tests for the shared ResourceRequirements protobuf shape while preserving the high-level builder arguments.

BREAKING CHANGE: Raw reusable-template protobuf callers must use resources.cpu.limit and resources.memory.limit instead of string fields.

Part of #2838

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2026-09-18 21:30:38 +02:00
parent 803fa815dd
commit 8bb845ae0b
2 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -1736,9 +1736,9 @@ def _sandbox_workload_template(
if environment:
template.spec.workload.environment.update(dict(environment))
if cpu is not None:
template.spec.workload.resources.cpu = cpu
template.spec.workload.resources.cpu.quantity = cpu
if memory is not None:
template.spec.workload.resources.memory = memory
template.spec.workload.resources.memory.quantity = memory
if gpu or gpu_count is not None:
template.spec.workload.resources.gpu.SetInParent()
if gpu_count is not None:
+4 -4
View File
@@ -1960,8 +1960,8 @@ def _make_workload_template_proto(
template.metadata.name = name
template.metadata.workspace = workspace
template.spec.workload.image = f"ghcr.io/test/{name}:latest"
template.spec.workload.resources.cpu = "1"
template.spec.workload.resources.memory = "512Mi"
template.spec.workload.resources.cpu.quantity = "1"
template.spec.workload.resources.memory.quantity = "512Mi"
return template
@@ -2256,8 +2256,8 @@ def test_sandbox_template_create_builds_template_from_public_fields() -> None:
assert dict(template.metadata.annotations) == {"owner": "platform"}
assert template.spec.workload.image == "ghcr.io/test/gpu-kata:latest"
assert dict(template.spec.workload.environment) == {"FEATURE_FLAG": "on"}
assert template.spec.workload.resources.cpu == "1"
assert template.spec.workload.resources.memory == "512Mi"
assert template.spec.workload.resources.cpu.quantity == "1"
assert template.spec.workload.resources.memory.quantity == "512Mi"
assert template.spec.workload.resources.gpu.count == 2
assert template.spec.driver_config["kubernetes"]["runtime_class_name"] == "kata"