Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw committed Nov 30, 2021
1 parent b9f80c2 commit 8a1d09f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
15 changes: 15 additions & 0 deletions flytekit/remote/executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from flytekit.common.exceptions import user as _user_exceptions
from flytekit.common.exceptions import user as user_exceptions
from flytekit.core.type_engine import LiteralsResolver
from flytekit.models import execution as execution_models
from flytekit.models import node_execution as node_execution_models
from flytekit.models.admin import task_execution as admin_task_execution_models
Expand Down Expand Up @@ -83,6 +84,8 @@ def __init__(self, *args, **kwargs):
self._inputs = None
self._outputs = None
self._flyte_workflow: Optional[FlyteWorkflow] = None
self._raw_inputs: Optional[LiteralsResolver] = None
self._raw_outputs: Optional[LiteralsResolver] = None

@property
def node_executions(self) -> Dict[str, "FlyteNodeExecution"]:
Expand Down Expand Up @@ -111,6 +114,18 @@ def outputs(self) -> Dict[str, Any]:
raise _user_exceptions.FlyteAssertion("Outputs could not be found because the execution ended in failure.")
return self._outputs

@property
def raw_outputs(self) -> LiteralsResolver:
if self._raw_outputs is None:
raise ValueError(f"WF execution: {self} doesn't have raw outputs set")
return self._raw_outputs

@property
def raw_inputs(self) -> LiteralsResolver:
if self._raw_inputs is None:
raise ValueError(f"WF execution: {self} doesn't have raw inputs set")
return self._raw_inputs

@property
def error(self) -> core_execution_models.ExecutionError:
"""
Expand Down
2 changes: 2 additions & 0 deletions tests/flytekit/integration/remote/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def test_fetch_execute_task(flyteclient, flyte_workflows_register):
execution = remote.execute(flyte_task, {"a": 10}, wait=True)
assert execution.outputs["t1_int_output"] == 12
assert execution.outputs["c"] == "world"
assert execution.raw_inputs.get("a", int) == 10
assert execution.raw_outputs.get("c", str) == "world"


def test_execute_python_task(flyteclient, flyte_workflows_register, flyte_remote_env):
Expand Down
13 changes: 10 additions & 3 deletions tests/flytekit/unit/core/test_type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,15 @@ def test_guess_of_dataclass():
class Foo(object):
x: int
y: str
z: typing.Dict[int, str]
z: typing.Dict[str, int]

def hello(self):
...

lt = TypeEngine.to_literal_type(Foo)
# This will need to be improved in the future after fixing the Model class.
TypeEngine.guess_python_type(lt)
foo = Foo(1, "hello", {"world": 3})
lv = TypeEngine.to_literal(FlyteContext.current_context(), foo, Foo, lt)
lit_dict = {"a": lv}
lr = LiteralsResolver(lit_dict)
assert lr.get("a", Foo) == foo
assert hasattr(lr.get("a", Foo), "hello") is True

0 comments on commit 8a1d09f

Please sign in to comment.