diff --git a/sdk/python/kfp/gcp.py b/sdk/python/kfp/gcp.py index 41de43f874f..7e6433412c5 100644 --- a/sdk/python/kfp/gcp.py +++ b/sdk/python/kfp/gcp.py @@ -112,9 +112,10 @@ def _set_preemptible(task): node_affinity = V1NodeAffinity(required_during_scheduling_ignored_during_execution= V1NodeSelector(node_selector_terms=[node_selector_term])) else: - node_affinity = V1NodeAffinity(preferred_during_scheduling_ignored_during_execution= + node_affinity = V1NodeAffinity(preferred_during_scheduling_ignored_during_execution=[ V1PreferredSchedulingTerm(preference=node_selector_term, - weight=50)) + weight=50) + ]) affinity = V1Affinity(node_affinity=node_affinity) task.add_affinity(affinity=affinity) return task diff --git a/sdk/python/tests/compiler/testdata/preemptible_tpu_gpu.yaml b/sdk/python/tests/compiler/testdata/preemptible_tpu_gpu.yaml index 4ab70988439..85fb22644c2 100644 --- a/sdk/python/tests/compiler/testdata/preemptible_tpu_gpu.yaml +++ b/sdk/python/tests/compiler/testdata/preemptible_tpu_gpu.yaml @@ -13,7 +13,7 @@ spec: - affinity: nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: - preference: + - preference: matchExpressions: - key: cloud.google.com/gke-preemptible operator: In