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

pod template inplace operations #2899

Merged
Merged
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
4 changes: 4 additions & 0 deletions flytekit/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import datetime
import inspect
import os
Expand Down Expand Up @@ -147,6 +148,9 @@

if pod_template.pod_spec is None:
return {}

pod_template = copy.deepcopy(pod_template)

Check warning on line 152 in flytekit/core/utils.py

View check run for this annotation

Codecov / codecov/patch

flytekit/core/utils.py#L152

Added line #L152 was not covered by tests

containers = cast(V1PodSpec, pod_template.pod_spec).containers
primary_exists = False

Expand Down
28 changes: 28 additions & 0 deletions tests/flytekit/unit/core/test_pod_template_mutation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from flytekit import PodTemplate, task
from flytekit.configuration import SerializationSettings, ImageConfig, Image


def test_mutation():
pod_template_before = PodTemplate(
labels={"lKeyA": "lValA", "lKeyB": "lValB"},
)

pod_template_after = PodTemplate(
labels={"lKeyA": "lValA", "lKeyB": "lValB"},
)

settings = SerializationSettings(image_config=ImageConfig(default_image=Image(
name='default',
fqn='cr.flyte.org/flyteorg/flytekit',
tag='latest',
digest=None
)))

@task(pod_template=pod_template_before)
def my_task():
pass

my_task.get_k8s_pod(settings=settings)


assert pod_template_before == pod_template_after
Loading