From 00a7c03242dbe219a8146790c7ad19cdc37097a6 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Fri, 5 May 2023 11:06:48 -0700 Subject: [PATCH] lint Signed-off-by: Kevin Su --- flytekit/core/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flytekit/core/utils.py b/flytekit/core/utils.py index 0d06b5e7e9..437d2b71a4 100644 --- a/flytekit/core/utils.py +++ b/flytekit/core/utils.py @@ -139,10 +139,12 @@ def _sanitize_resource_name(resource: "task_models.Resources.ResourceEntry") -> def _serialize_pod_spec(pod_template: "PodTemplate", primary_container: "task_models.Container") -> Dict[str, Any]: - from kubernetes.client import ApiClient + from kubernetes.client import ApiClient, V1PodSpec from kubernetes.client.models import V1Container, V1EnvVar, V1ResourceRequirements - containers = cast(PodTemplate, pod_template).pod_spec.containers + if pod_template.pod_spec is None: + return {} + containers = cast(V1PodSpec, pod_template.pod_spec).containers primary_exists = False for container in containers: @@ -177,7 +179,7 @@ def _serialize_pod_spec(pod_template: "PodTemplate", primary_container: "task_mo container.env or [] ) final_containers.append(container) - cast(PodTemplate, pod_template).pod_spec.containers = final_containers + cast(V1PodSpec, pod_template.pod_spec).containers = final_containers return ApiClient().sanitize_for_serialization(cast(PodTemplate, pod_template).pod_spec)