-
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
Flytekit remote updates for notebooks and versions #3109
Conversation
Signed-off-by: Ketan Umare <[email protected]>
Code Review Agent Run #7eedadActionable Suggestions - 1
Additional Suggestions - 1
Review Details
|
flytekit/remote/remote.py
Outdated
def _resolve_version( | ||
self, version: typing.Optional[str], entity: typing.Any, ss: SerializationSettings | ||
) -> typing.Tuple[str, typing.Optional[PickledEntity]]: | ||
if version is None and self.interactive_mode_enabled: | ||
md5_bytes, pickled_target_dict = _get_pickled_target_dict(entity) | ||
return self._version_from_hash( | ||
md5_bytes, ss, entity.python_interface.default_inputs_as_kwargs, *self._get_image_names(entity) | ||
), pickled_target_dict | ||
elif version is not None: | ||
return version, None | ||
raise ValueError( | ||
"Version must be provided when not in interactive mode. If you want to use latest version pass 'latest'" | ||
) |
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.
Consider extracting the version resolution logic into a separate method for better code organization. The _resolve_version
method currently handles both version resolution and pickled entity management, which could be split for better maintainability.
Code suggestion
Check the AI-generated fix before applying
def _resolve_version( | |
self, version: typing.Optional[str], entity: typing.Any, ss: SerializationSettings | |
) -> typing.Tuple[str, typing.Optional[PickledEntity]]: | |
if version is None and self.interactive_mode_enabled: | |
md5_bytes, pickled_target_dict = _get_pickled_target_dict(entity) | |
return self._version_from_hash( | |
md5_bytes, ss, entity.python_interface.default_inputs_as_kwargs, *self._get_image_names(entity) | |
), pickled_target_dict | |
elif version is not None: | |
return version, None | |
raise ValueError( | |
"Version must be provided when not in interactive mode. If you want to use latest version pass 'latest'" | |
) | |
def _get_pickled_entity(self, entity: typing.Any) -> typing.Optional[PickledEntity]: | |
if not self.interactive_mode_enabled: | |
return None | |
md5_bytes, pickled_target_dict = _get_pickled_target_dict(entity) | |
return pickled_target_dict | |
def _resolve_version( | |
self, version: typing.Optional[str], entity: typing.Any, ss: SerializationSettings | |
) -> typing.Tuple[str, typing.Optional[PickledEntity]]: | |
if version is not None: | |
return version, None | |
if not self.interactive_mode_enabled: | |
raise ValueError( | |
"Version must be provided when not in interactive mode. If you want to use latest version pass 'latest'" | |
) | |
md5_bytes, pickled_target_dict = _get_pickled_target_dict(entity) | |
version = self._version_from_hash( | |
md5_bytes, ss, entity.python_interface.default_inputs_as_kwargs, *self._get_image_names(entity) | |
) | |
return version, pickled_target_dict |
Code Review Run #7eedad
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Signed-off-by: Samhita Alla <[email protected]>
Code Review Agent Run #dda473Actionable Suggestions - 2
Review Details
|
flytekit/remote/remote.py
Outdated
def _resolve_version( | ||
self, version: typing.Optional[str], entity: typing.Any, ss: SerializationSettings | ||
) -> typing.Tuple[str, typing.Optional[PickledEntity]]: | ||
if version is None and self.interactive_mode_enabled: | ||
md5_bytes, pickled_target_dict = _get_pickled_target_dict(entity) | ||
return self._version_from_hash( | ||
md5_bytes, ss, entity.python_interface.default_inputs_as_kwargs, *self._get_image_names(entity) | ||
), pickled_target_dict | ||
elif version is not None: | ||
return version, None | ||
raise ValueError( | ||
"Version must be provided when not in interactive mode. If you want to use latest version pass 'latest'" | ||
) |
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.
Consider adding type hints for entity
parameter in _resolve_version()
. The current implementation accepts typing.Any
which could lead to runtime errors if invalid types are passed.
Code suggestion
Check the AI-generated fix before applying
- def _resolve_version(self, version: typing.Optional[str], entity: typing.Any, ss: SerializationSettings
+ def _resolve_version(self, version: typing.Optional[str], entity: typing.Union[WorkflowBase, PythonTask], ss: SerializationSettings
Code Review Run #dda473
Consider consolidating the version handling logic. The conditions version is not None
and ss.version is not None
could be combined since they have the same outcome of returning version, None
or ss.version, None
respectively.
Code suggestion
Check the AI-generated fix before applying
- elif version is not None:
- return version, None
- elif ss.version is not None:
- return ss.version, None
+ elif version is not None or ss.version is not None:
+ return version or ss.version, None
Code Review Run #0c0f7f
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
project=self.default_project, | ||
domain=self.default_domain, | ||
) | ||
|
||
version, _ = self._resolve_version(version, entity, serialization_settings) |
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.
Consider moving the version resolution logic before the serialization settings initialization to avoid potential inconsistencies between version and settings.
Code suggestion
Check the AI-generated fix before applying
- serialization_settings = SerializationSettings(
- image_config=ImageConfig.auto_default_image(),
- project=self.default_project,
- domain=self.default_domain,
- )
-
- version, _ = self._resolve_version(version, entity, serialization_settings)
+ version, _ = self._resolve_version(version, entity, None)
+ serialization_settings = SerializationSettings(
+ image_config=ImageConfig.auto_default_image(),
+ project=self.default_project,
+ domain=self.default_domain,
+ version=version
+ )
Code Review Run #dda473
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
There's a breaking change here I wanted to highlight which may or may not be okay. I think it's technically more correct, but it is a change in behavior. Assuming you have a simple file like this from flytekit import task, workflow, ImageSpec, FlyteRemote, Config
image = ImageSpec(
name="yt_public",
builder="default",
registry="ghcr.io/wild-endeavor",
packages=["flytekit==v1.15.0b2"],
)
@task(container_image=image, enable_deck=True)
def print_hello():
print("hello")
@workflow
def wf():
print_hello()
if __name__ == "__main__":
remote = FlyteRemote(Config.for_sandbox(), default_project="flytesnacks", default_domain="development")
remote.register_workflow(wf, version="from_main_v4_pr") the behavior on master is as follows
The reason the code is built into the image in the second case is because the code currently is setting the project root. When the register workflow call triggers the downstream register task call, it gets set on the image spec, causing the user code to be built in. With this pr, without setting project root, pyflyte register remains the same, but If the user wants to make this work, they'd have to change to I think we can make a better experience actually - the register_workflow function right now never does fast register... even if the user passes in a serialization settings object with fast register enabled, so there's some discrepancy here to clean up. |
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Code Review Agent Run #0c0f7fActionable Suggestions - 1
Review Details
|
Signed-off-by: Yee Hing Tong <[email protected]>
Code Review Agent Run #b0d8ccActionable Suggestions - 0Review Details
|
Signed-off-by: Yee Hing Tong <[email protected]>
@kumare3 pushed a nit to get the monodocs build to pass. should we merge? Keep in mind there is a small breaking change (detailed above). I'm okay with this given the fact that this function is a bit broken to begin with (fast settings not being respected), and the behavior now actually might better align with expectations. |
Code Review Agent Run #37064eActionable Suggestions - 0Review Details
|
Problems:
latest
as a special versionExample cases, now works
![Screenshot 2025-02-04 at 9 35 13 PM](https://private-user-images.githubusercontent.com/16888709/409843455-27bfef6d-ad01-435d-a66c-c1f045ce228f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NTE4MTgsIm5iZiI6MTczOTQ1MTUxOCwicGF0aCI6Ii8xNjg4ODcwOS80MDk4NDM0NTUtMjdiZmVmNmQtYWQwMS00MzVkLWE2NmMtYzFmMDQ1Y2UyMjhmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDEyNTgzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQyNTc0Mzc0NTQ4NDcyMWI0MzkyYzQwYTNmMmI5ZmQ5ODI2ODA4YmMxNjllMWEyNzdjZWUzYzA2MmQzY2M2ZGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.VAkwyCLJ14WgEKWy4b2-jwv4BYf8lfyu8FyyWgHzUc8)
Summary by Bito
Implements standardized version handling in Flytekit's remote operations with 'latest' as default, enhancing consistency across interactive and notebook environments. Improves documentation for execution_name_prefix parameter and clarifies behavior of 'latest' version parameter. Includes code cleanup by removing unused elements and replacing print statements with proper logging. Updates documentation for improved clarity and conciseness.Unit tests added: False
Estimated effort to review (1-5, lower is better): 2