-
Notifications
You must be signed in to change notification settings - Fork 309
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
base: master
Are you sure you want to change the base?
Changes from all commits
ff7b2c5
5f790d6
f5a72f7
0eb643d
f2ddb80
bb6e187
e66743f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -104,6 +104,7 @@ def task( | |||||||
interruptible: Optional[bool] = ..., | ||||||||
deprecated: str = ..., | ||||||||
timeout: Union[datetime.timedelta, int] = ..., | ||||||||
image: Optional[Union[str, ImageSpec]] = ..., | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider consolidating duplicate image parameters
Consider consolidating the Code suggestionCheck the AI-generated fix before applying
Code Review Run #e396c5 Is this a valid issue, or was it incorrectly flagged by the Agent?
|
||||||||
container_image: Optional[Union[str, ImageSpec]] = ..., | ||||||||
environment: Optional[Dict[str, str]] = ..., | ||||||||
requests: Optional[Resources] = ..., | ||||||||
|
@@ -143,6 +144,7 @@ def task( | |||||||
interruptible: Optional[bool] = ..., | ||||||||
deprecated: str = ..., | ||||||||
timeout: Union[datetime.timedelta, int] = ..., | ||||||||
image: Optional[Union[str, ImageSpec]] = ..., | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider consolidating duplicate image parameters
Consider consolidating the Code suggestionCheck the AI-generated fix before applying
Code Review Run #e396c5 Is this a valid issue, or was it incorrectly flagged by the Agent?
|
||||||||
container_image: Optional[Union[str, ImageSpec]] = ..., | ||||||||
environment: Optional[Dict[str, str]] = ..., | ||||||||
requests: Optional[Resources] = ..., | ||||||||
|
@@ -181,6 +183,7 @@ def task( | |||||||
interruptible: Optional[bool] = None, | ||||||||
deprecated: str = "", | ||||||||
timeout: Union[datetime.timedelta, int] = 0, | ||||||||
image: Optional[Union[str, ImageSpec]] = None, | ||||||||
container_image: Optional[Union[str, ImageSpec]] = None, | ||||||||
environment: Optional[Dict[str, str]] = None, | ||||||||
requests: Optional[Resources] = None, | ||||||||
|
@@ -272,7 +275,7 @@ def my_task(x: int, y: typing.Dict[str, str]) -> str: | |||||||
indicates that the task is active and not deprecated | ||||||||
:param timeout: the max amount of time for which one execution of this task should be executed for. The execution | ||||||||
will be terminated if the runtime exceeds the given timeout (approximately). | ||||||||
:param container_image: By default the configured FLYTE_INTERNAL_IMAGE is used for every task. This directive can be | ||||||||
:param image: By default the configured FLYTE_INTERNAL_IMAGE is used for every task. This directive can be | ||||||||
used to provide an alternate image for a specific task. This is useful for the cases in which images | ||||||||
bloat because of various dependencies and a dependency is only required for this or a set of tasks, | ||||||||
and they vary from the default. | ||||||||
|
@@ -282,15 +285,16 @@ def my_task(x: int, y: typing.Dict[str, str]) -> str: | |||||||
# Use default image name `fqn` and alter the tag to `tag-{{default.tag}}` tag of the default image | ||||||||
# with a prefix. In this case, it is assumed that the image like | ||||||||
# flytecookbook:tag-gitsha is published alongwith the default of flytecookbook:gitsha | ||||||||
@task(container_image='{{.images.default.fqn}}:tag-{{images.default.tag}}') | ||||||||
@task(image='{{.images.default.fqn}}:tag-{{images.default.tag}}') | ||||||||
def foo(): | ||||||||
... | ||||||||
|
||||||||
# Refer to configurations to configure fqns for other images besides default. In this case it will | ||||||||
# lookup for an image named xyz | ||||||||
@task(container_image='{{.images.xyz.fqn}}:{{images.default.tag}}') | ||||||||
@task(image='{{.images.xyz.fqn}}:{{images.default.tag}}') | ||||||||
def foo2(): | ||||||||
... | ||||||||
:param container_image: Deprecated, please use `image` instead. | ||||||||
:param environment: Environment variables that should be added for this tasks execution | ||||||||
:param requests: Specify compute resource requests for your task. For Pod-plugin tasks, these values will apply only | ||||||||
to the primary container. | ||||||||
|
@@ -374,6 +378,7 @@ def wrapper(fn: Callable[P, Any]) -> PythonFunctionTask[T]: | |||||||
task_config, | ||||||||
decorated_fn, | ||||||||
metadata=_metadata, | ||||||||
image=image, | ||||||||
container_image=container_image, | ||||||||
Comment on lines
+381
to
382
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider consolidating image parameters
Consider consolidating the image parameters. Currently both Code suggestionCheck the AI-generated fix before applying
Suggested change
Code Review Run #5e8094 Is this a valid issue, or was it incorrectly flagged by the Agent?
|
||||||||
environment=environment, | ||||||||
requests=requests, | ||||||||
|
@@ -584,7 +589,6 @@ async def eager_workflow(x: int) -> int: | |||||||
async def eager_workflow(x: int) -> int: | ||||||||
... | ||||||||
""" | ||||||||
|
||||||||
if _fn is None: | ||||||||
return partial( | ||||||||
eager, | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -380,7 +380,7 @@ class DC: | |||||
a: Union[int, bool, str, float] | ||||||
b: Union[int, bool, str, float] | ||||||
@task(container_image=custom_image) | ||||||
@task(image=custom_image) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider maintaining parameter name consistency
Consider updating the parameter name from Code suggestionCheck the AI-generated fix before applying
Suggested change
Code Review Run #e396c5 Is this a valid issue, or was it incorrectly flagged by the Agent?
|
||||||
def add(a: Union[int, bool, str, float], b: Union[int, bool, str, float]) -> Union[int, bool, str, float]: | ||||||
return a + b | ||||||
|
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." |
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 i. Thanks for your guidance!