-
Notifications
You must be signed in to change notification settings - Fork 291
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
[Core feature] Flytekit should support unsafe
mode for types
#2419
Open
Mecoli1219
wants to merge
19
commits into
flyteorg:master
Choose a base branch
from
Mecoli1219:#5319
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.
+155
−11
Open
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3570363
Enable unsafe type task & workflow
Mecoli1219 8c7e5fa
Add unsafe unit test
Mecoli1219 c7c9a2a
Formatting
Mecoli1219 1524c81
Change Optional[Any] to Any
Mecoli1219 0519fe6
Fix Scalar Void() error
Mecoli1219 9885189
Modify unit test
Mecoli1219 f107b35
Update 2 unit tests
Mecoli1219 8db4bce
merged master
pingsutw aa1760c
nit
pingsutw df0f898
Merge branch 'master' into #5319
Mecoli1219 8368723
Fix merge
Mecoli1219 1b5bfeb
Merge remote-tracking branch 'upstream/master' into #5319
Mecoli1219 51ea34c
rename unsafe to pickle_untyped
Mecoli1219 d35c231
Merge branch 'master' into #5319
Mecoli1219 933458a
Fix merge
Mecoli1219 11b5d9c
nit
Mecoli1219 75296df
merge upstream
Mecoli1219 7db0869
Update unit test
Mecoli1219 43f8948
revert None support
Mecoli1219 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import os | ||
import typing | ||
from typing import Type | ||
from typing import Optional, Type | ||
|
||
import cloudpickle | ||
|
||
from flytekit.core.context_manager import FlyteContext, FlyteContextManager | ||
from flytekit.core.type_engine import TypeEngine, TypeTransformer | ||
from flytekit.models.core import types as _core_types | ||
from flytekit.models.literals import Blob, BlobMetadata, Literal, Scalar | ||
from flytekit.models.literals import Blob, BlobMetadata, Literal, Scalar, Void | ||
from flytekit.models.types import LiteralType | ||
|
||
T = typing.TypeVar("T") | ||
|
@@ -86,13 +86,16 @@ def assert_type(self, t: Type[T], v: T): | |
# Every type can serialize to pickle, so we don't need to check the type here. | ||
... | ||
|
||
def to_python_value(self, ctx: FlyteContext, lv: Literal, expected_python_type: Type[T]) -> T: | ||
def to_python_value(self, ctx: FlyteContext, lv: Literal, expected_python_type: Type[T]) -> Optional[T]: | ||
if lv.scalar.blob is None: | ||
return None | ||
uri = lv.scalar.blob.uri | ||
return FlytePickle.from_pickle(uri) | ||
|
||
def to_literal(self, ctx: FlyteContext, python_val: T, python_type: Type[T], expected: LiteralType) -> Literal: | ||
if python_val is None: | ||
raise AssertionError("Cannot pickle None Value.") | ||
# raise AssertionError("Cannot pickle None Value.") | ||
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. Can this be removed? 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. yes sure. I'll remove that recently |
||
return Literal(scalar=Scalar(none_type=Void())) | ||
meta = BlobMetadata( | ||
type=_core_types.BlobType( | ||
format=self.PYTHON_PICKLE_FORMAT, dimensionality=_core_types.BlobType.BlobDimensionality.SINGLE | ||
|
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
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.
@kumare3 Since you proposed the
safe
parameter name, are you okay with usingpickle_untyped
?My concerned is that
safe=False
could mean so many unsafe behavior.pickle_untyped
is explicit about the behavior.