Skip to content

Commit

Permalink
unit test for pickling (#2805)
Browse files Browse the repository at this point in the history
  • Loading branch information
wild-endeavor authored Oct 11, 2024
1 parent ef4dada commit 51751eb
Showing 1 changed file with 32 additions and 0 deletions.
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

0 comments on commit 51751eb

Please sign in to comment.