-
Notifications
You must be signed in to change notification settings - Fork 310
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
Rename container_image to image for improved UX #3094
Open
JiangJiaWei1103
wants to merge
8
commits into
flyteorg:master
Choose a base branch
from
JiangJiaWei1103:rename-image-for-container-ux
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+134
−20
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ff7b2c5
refactor: Rename container_image to image for improved UX
JiangJiaWei1103 5f790d6
refactor: Use image instead of container_image in task decorator for …
JiangJiaWei1103 f5a72f7
test: Test image attr in task and dynamic decorators
JiangJiaWei1103 0eb643d
test: Test image attr in eager decorator
JiangJiaWei1103 f2ddb80
Recover plugins-related interface
JiangJiaWei1103 bb6e187
refactor: Move validation logic into PythonAutoContainerTask
JiangJiaWei1103 e66743f
docs: Add docstring for _container_image setter
JiangJiaWei1103 896553e
Merge branch 'master' into rename-image-for-container-ux
JiangJiaWei1103 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,87 @@ | ||
import os | ||
import pytest | ||
|
||
from flytekit import task, dynamic, eager | ||
from flytekit.core.task import decorate_function | ||
from flytekit.core.utils import str2bool | ||
from flytekit.interactive import vscode | ||
from flytekit.interactive.constants import FLYTE_ENABLE_VSCODE_KEY | ||
|
||
|
||
IMAGE = os.environ.get("FLYTEKIT_IMAGE", "localhost:30000/flytekit:dev") | ||
|
||
|
||
def test_decorate_python_task(monkeypatch: pytest.MonkeyPatch): | ||
def t1(a: int, b: int) -> int: | ||
return a + b | ||
|
||
assert decorate_function(t1) is t1 | ||
monkeypatch.setenv(FLYTE_ENABLE_VSCODE_KEY, str2bool("True")) | ||
assert isinstance(decorate_function(t1), vscode) | ||
|
||
|
||
def test_image(): | ||
# Define expected warning and error messages | ||
WARN_MSG = "container_image is deprecated and will be removed in the future. Please use image instead." | ||
ERR_MSG = ( | ||
"Cannot specify both image and container_image. " | ||
"Please use image because container_image is deprecated and will be removed in the future." | ||
) | ||
|
||
# Plain tasks | ||
@task(image=IMAGE) | ||
def t1() -> str: | ||
return "Use image in @task." | ||
assert t1._container_image == IMAGE, f"_container_image of t1 should match the user-specified {IMAGE}" | ||
|
||
with pytest.warns(DeprecationWarning, match=WARN_MSG): | ||
@task(container_image=IMAGE) | ||
def t2() -> str: | ||
return "Use container_image in @task." | ||
assert t2._container_image == IMAGE, f"_container_image of t2 should match the user-specified {IMAGE}" | ||
|
||
with pytest.raises(ValueError, match=ERR_MSG): | ||
@task(image=IMAGE, container_image=IMAGE) | ||
def t3() -> str: | ||
return "Use both image and container_image in @task." | ||
|
||
# Dynamic workflow tasks | ||
@dynamic(image=IMAGE) | ||
def dy_t1(i: int) -> str: | ||
return "Use image in @dynamic." | ||
assert dy_t1._container_image == IMAGE, f"_container_image of dy_t1 should match the user-specified {IMAGE}" | ||
|
||
with pytest.warns(DeprecationWarning, match=WARN_MSG): | ||
@dynamic(container_image=IMAGE) | ||
def dy_t2(i: int) -> str: | ||
return "Use container_image in @dynamic." | ||
assert dy_t2._container_image == IMAGE, f"_container_image of dy_t2 should match the user-specified {IMAGE}" | ||
|
||
with pytest.raises(ValueError, match=ERR_MSG): | ||
@dynamic(image=IMAGE, container_image=IMAGE) | ||
def dy_t3(i: int) -> str: | ||
return "Use both image and container_image in @dynamic." | ||
|
||
|
||
# Eager workflow task | ||
@eager(image=IMAGE) | ||
def eager_t1(dummy: bool) -> str: | ||
if dummy: | ||
print(f"Eager!") | ||
return "Use image in @eager." | ||
assert eager_t1._container_image == IMAGE, f"_container_image of eager_t1 should match the user-specified {IMAGE}" | ||
|
||
with pytest.warns(DeprecationWarning, match=WARN_MSG): | ||
@eager(container_image=IMAGE) | ||
def eager_t2(dummy: bool) -> str: | ||
if dummy: | ||
print(f"Eager!") | ||
return "Use container_image in @eager." | ||
assert eager_t2._container_image == IMAGE, f"_container_image of eager_t2 should match the user-specified {IMAGE}" | ||
|
||
with pytest.raises(ValueError, match=ERR_MSG): | ||
@eager(image=IMAGE, container_image=IMAGE) | ||
def eager_t3(dummy: bool) -> str: | ||
if dummy: | ||
print(f"Eager!") | ||
return "Use both image and container_image in @eager." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Thomas,
I’ve just added it. Thanks for your guidance!