Skip to content
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

Add unit test for pickling #2805

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/flytekit/unit/core/test_type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from flytekit.core.node import Node
from flytekit.core.promise import NodeOutput, Promise, VoidPromise
from flytekit.core.resources import Resources
from flytekit.types.pickle.pickle import FlytePickleTransformer
from flytekit.core.task import TaskMetadata, task
from flytekit.core.testing import patch, task_mock
from flytekit.core.type_engine import RestrictedTypeError, SimpleTransformer, TypeEngine, TypeTransformerFailedError
Expand Down Expand Up @@ -115,6 +116,37 @@ def my_task(a: int):
assert context_manager.FlyteContextManager.size() == 1


def test_transformer_override():
tf = FlytePickleTransformer()

@task
def my_task() -> Annotated[str, tf]:
return "Hello world"

@workflow
def wf() -> FlyteFile:
return my_task()

annotated_output = wf()

@task
def my_task_any() -> typing.Any:
return "Hello world"

@workflow
def wf_any() -> FlyteFile:
return my_task_any()

any_output = wf_any()

with open(annotated_output, "rb") as fh:
contents_annotated = fh.read()

with open(any_output, "rb") as fh:
contents_any = fh.read()
assert contents_annotated == contents_any


def test_single_output():
@task
def my_task() -> str:
Expand Down
Loading