Skip to content

Commit 97ea801

Browse files
authored
Exclude the builder from image tag calculation (#3188)
* Exclude the builder from image tag calculation Signed-off-by: Kevin Su <pingsutw@apache.org> * hash Signed-off-by: Kevin Su <pingsutw@apache.org> --------- Signed-off-by: Kevin Su <pingsutw@apache.org>
1 parent 253834e commit 97ea801

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

flytekit/image_spec/image_spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def id(self) -> str:
160160
161161
:return: a unique identifier of the ImageSpec
162162
"""
163-
parameters_to_exclude = ["pip_secret_mounts"]
163+
parameters_to_exclude = ["pip_secret_mounts", "builder"]
164164
# Only get the non-None values in the ImageSpec to ensure the hash is consistent across different Flytekit versions.
165165
image_spec_dict = asdict(
166166
self, dict_factory=lambda x: {k: v for (k, v) in x if v is not None and k not in parameters_to_exclude}

tests/flytekit/unit/core/image_spec/test_image_spec.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_image_spec(mock_image_spec_builder, monkeypatch):
6363
assert image_spec.entrypoint == ["/bin/bash"]
6464
assert image_spec.copy == ["/src/file1.txt", "/src", "/src/file2.txt"]
6565

66-
assert image_spec.image_name() == f"localhost:30001/flytekit:AjLtng9gJfYzLnjbNy70gA"
66+
assert image_spec.image_name() == f"localhost:30001/flytekit:{image_spec.tag}"
6767
ctx = context_manager.FlyteContext.current_context()
6868
with context_manager.FlyteContextManager.with_context(
6969
ctx.with_execution_state(ctx.execution_state.with_params(mode=ExecutionState.Mode.TASK_EXECUTION))
@@ -294,3 +294,10 @@ def test_image_spec_same_id_and_tag_with_pip_secret_mounts():
294294
image_spec_with_pip_secret_mounts = ImageSpec(name="my_image", pip_secret_mounts=[("src", "dst")])
295295
assert image_spec.id == image_spec_with_pip_secret_mounts.id
296296
assert image_spec.tag == image_spec_with_pip_secret_mounts.tag
297+
298+
299+
def test_image_spec_same_id_and_tag_with_builder():
300+
image_spec = ImageSpec(name="my_image")
301+
image_spec_with_builder = ImageSpec(name="my_image", builder="envd")
302+
assert image_spec.id == image_spec_with_builder.id
303+
assert image_spec.tag == image_spec_with_builder.tag

0 commit comments

Comments
 (0)