-
Notifications
You must be signed in to change notification settings - Fork 333
Add support cache for dynamic spec #3209
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
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 | ||||
---|---|---|---|---|---|---|
|
@@ -28,6 +28,7 @@ | |||||
from enum import Enum | ||||||
from typing import Any, Callable, Iterable, List, Optional, Tuple, TypeVar, Union, cast | ||||||
|
||||||
from flyteidl.core import tasks_pb2 | ||||||
from flytekit.configuration import ImageConfig, ImageSpec, SerializationSettings | ||||||
from flytekit.core import launch_plan as _annotated_launch_plan | ||||||
from flytekit.core.base_task import Task, TaskMetadata, TaskResolverMixin | ||||||
|
@@ -127,6 +128,21 @@ class ExecutionBehavior(Enum): | |||||
DYNAMIC = 2 | ||||||
EAGER = 3 | ||||||
|
||||||
def to_flyte_idl(self) -> tasks_pb2.TaskMetadata.ExecutionMode: | ||||||
"""convert ExecutionBehavior into flyteidl type""" | ||||||
return { | ||||||
self.DEFAULT: tasks_pb2.TaskMetadata.ExecutionMode.DEFAULT, | ||||||
self.DYNAMIC: tasks_pb2.TaskMetadata.ExecutionMode.DYNAMIC, | ||||||
}[self] | ||||||
|
||||||
@classmethod | ||||||
def from_flyte_idl(cls, execution_mode: tasks_pb2.TaskMetadata.ExecutionMode): | ||||||
"""convert flyteidl type into ExecutionBehavior""" | ||||||
return { | ||||||
tasks_pb2.TaskMetadata.ExecutionMode.DEFAULT: cls.DEFAULT, | ||||||
tasks_pb2.TaskMetadata.ExecutionMode.DYNAMIC: cls.DYNAMIC, | ||||||
}[execution_mode] | ||||||
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. Missing fallback for unknown enum values
The Code suggestionCheck the AI-generated fix before applying
Suggested change
Code Review Run #0d112d Should Bito avoid suggestions like this for future reviews? (Manage Rules)
|
||||||
|
||||||
def __init__( | ||||||
self, | ||||||
task_config: T, | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -183,6 +183,7 @@ def __init__( | |||||||||||||||||
cache_serializable, | ||||||||||||||||||
pod_template_name, | ||||||||||||||||||
cache_ignore_input_vars, | ||||||||||||||||||
execution_mode, | ||||||||||||||||||
is_eager: bool = False, | ||||||||||||||||||
generates_deck: bool = False, | ||||||||||||||||||
): | ||||||||||||||||||
|
@@ -221,6 +222,13 @@ def __init__( | |||||||||||||||||
self._cache_ignore_input_vars = cache_ignore_input_vars | ||||||||||||||||||
self._is_eager = is_eager | ||||||||||||||||||
self._generates_deck = generates_deck | ||||||||||||||||||
self._execution_mode = execution_mode | ||||||||||||||||||
|
||||||||||||||||||
def __post_init__(self): | ||||||||||||||||||
if self.execution_mode is None: | ||||||||||||||||||
from flytekit.core.python_function_task import PythonFunctionTask | ||||||||||||||||||
|
||||||||||||||||||
self.execution_mode = PythonFunctionTask.ExecutionBehavior.DEFAULT | ||||||||||||||||||
Comment on lines
+228
to
+231
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. Missing property getter for execution_mode attribute
The Code suggestionCheck the AI-generated fix before applying
Suggested change
Code Review Run #0d112d Should Bito avoid suggestions like this for future reviews? (Manage Rules)
|
||||||||||||||||||
|
||||||||||||||||||
@property | ||||||||||||||||||
def is_eager(self): | ||||||||||||||||||
|
@@ -318,6 +326,13 @@ def cache_ignore_input_vars(self): | |||||||||||||||||
""" | ||||||||||||||||||
return self._cache_ignore_input_vars | ||||||||||||||||||
|
||||||||||||||||||
@property | ||||||||||||||||||
def execution_mode(self): | ||||||||||||||||||
""" | ||||||||||||||||||
The execution mode is either default or dynamic | ||||||||||||||||||
""" | ||||||||||||||||||
return self._execution_mode | ||||||||||||||||||
|
||||||||||||||||||
def to_flyte_idl(self): | ||||||||||||||||||
""" | ||||||||||||||||||
:rtype: flyteidl.admin.task_pb2.TaskMetadata | ||||||||||||||||||
|
@@ -334,6 +349,7 @@ def to_flyte_idl(self): | |||||||||||||||||
cache_ignore_input_vars=self.cache_ignore_input_vars, | ||||||||||||||||||
is_eager=self.is_eager, | ||||||||||||||||||
generates_deck=BoolValue(value=self.generates_deck), | ||||||||||||||||||
mode=self.execution_mode.to_flyte_idl(), | ||||||||||||||||||
) | ||||||||||||||||||
if self.timeout: | ||||||||||||||||||
tm.timeout.FromTimedelta(self.timeout) | ||||||||||||||||||
|
@@ -345,6 +361,8 @@ def from_flyte_idl(cls, pb2_object: _core_task.TaskMetadata): | |||||||||||||||||
:param flyteidl.core.task_pb2.TaskMetadata pb2_object: | ||||||||||||||||||
:rtype: TaskMetadata | ||||||||||||||||||
""" | ||||||||||||||||||
from flytekit.core.python_function_task import PythonFunctionTask | ||||||||||||||||||
|
||||||||||||||||||
return cls( | ||||||||||||||||||
discoverable=pb2_object.discoverable, | ||||||||||||||||||
runtime=RuntimeMetadata.from_flyte_idl(pb2_object.runtime), | ||||||||||||||||||
|
@@ -358,6 +376,7 @@ def from_flyte_idl(cls, pb2_object: _core_task.TaskMetadata): | |||||||||||||||||
cache_ignore_input_vars=pb2_object.cache_ignore_input_vars, | ||||||||||||||||||
is_eager=pb2_object.is_eager, | ||||||||||||||||||
generates_deck=pb2_object.generates_deck.value if pb2_object.HasField("generates_deck") else False, | ||||||||||||||||||
execution_mode=PythonFunctionTask.ExecutionBehavior.from_flyte_idl(pb2_object.mode), | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,6 +7,7 @@ | |||||
from flytekit.models import interface, literals, security, task, types | ||||||
from flytekit.models.core import identifier | ||||||
from flytekit.models.core import types as _core_types | ||||||
from flytekit.core.python_function_task import PythonFunctionTask | ||||||
|
||||||
LIST_OF_SCALAR_LITERAL_TYPES = [ | ||||||
types.LiteralType(simple=types.SimpleType.BINARY), | ||||||
|
@@ -125,8 +126,9 @@ | |||||
cache_serializable, | ||||||
pod_template_name, | ||||||
cache_ignore_input_vars, | ||||||
execution_mode, | ||||||
) | ||||||
for discoverable, runtime_metadata, timeout, retry_strategy, interruptible, discovery_version, deprecated, cache_serializable, pod_template_name, cache_ignore_input_vars in product( | ||||||
for discoverable, runtime_metadata, timeout, retry_strategy, interruptible, discovery_version, deprecated, cache_serializable, pod_template_name, cache_ignore_input_vars, execution_mode in product( | ||||||
[True, False], | ||||||
LIST_OF_RUNTIME_METADATA, | ||||||
[timedelta(days=i) for i in range(3)], | ||||||
|
@@ -137,6 +139,7 @@ | |||||
[True, False], | ||||||
["A", "B"], | ||||||
[()], | ||||||
[PythonFunctionTask.ExecutionBehavior.DEFAULT] | ||||||
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. Missing comma in product function parameters
The product function is now including Code suggestionCheck the AI-generated fix before applying
Suggested change
Code Review Run #0d112d Should Bito avoid suggestions like this for future reviews? (Manage Rules)
|
||||||
) | ||||||
] | ||||||
|
||||||
|
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's an undefined name
PythonFunctionTask
in theTaskMetadata
class. This class is likely imported from another module but the import is missing. Consider adding the appropriate import or using a string literal for the type annotation.Code suggestion
Code Review Run #0d112d
Should Bito avoid suggestions like this for future reviews? (Manage Rules)