Skip to content

Commit

Permalink
keep container validation
Browse files Browse the repository at this point in the history
Signed-off-by: byhsu <[email protected]>
  • Loading branch information
ByronHsu committed Feb 1, 2023
1 parent e6c810e commit a26affd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
12 changes: 1 addition & 11 deletions flytekit/core/pod_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,9 @@
PRIMARY_CONTAINER_DEFAULT_NAME = "primary"


# overwrite setter to bypass unnecessary validation
# https://github.com/kubernetes-client/python/blob/master/kubernetes/client/models/v1_pod_spec.py#L323
@V1PodSpec.containers.setter
def custom_containers_setter(self, containers):
self._containers = containers


V1PodSpec.containers = custom_containers_setter


@dataclass
class PodTemplate(object):
pod_spec: V1PodSpec = V1PodSpec()
pod_spec: V1PodSpec = V1PodSpec(containers=[])
primary_container_name: str = PRIMARY_CONTAINER_DEFAULT_NAME
labels: Optional[Dict[str, str]] = None
annotations: Optional[Dict[str, str]] = None
Expand Down
2 changes: 1 addition & 1 deletion flytekit/core/python_auto_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _get_container(self, settings: SerializationSettings) -> _task_model.Contain
)

def _serialize_pod_spec(self, settings: SerializationSettings) -> Dict[str, Any]:
containers = self.pod_template.pod_spec.containers if self.pod_template.pod_spec.containers is not None else []
containers = self.pod_template.pod_spec.containers
primary_exists = False

for container in containers:
Expand Down
4 changes: 1 addition & 3 deletions tests/flytekit/unit/core/test_python_auto_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ def test_pod_template(default_serialization_settings):
primary_container_name="primary",
labels={"lKeyA": "lValA"},
annotations={"aKeyA": "aValA"},
pod_spec=V1PodSpec(
volumes=[V1Volume(name="volume")],
),
pod_spec=V1PodSpec(volumes=[V1Volume(name="volume")], containers=[]),
),
pod_template_name="A",
)
Expand Down

0 comments on commit a26affd

Please sign in to comment.