Skip to content

Commit

Permalink
Improve Type Engine Error Msg (#3063)
Browse files Browse the repository at this point in the history
* update

Signed-off-by: Future-Outlier <[email protected]>

* ficx

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* test

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* udpate

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* updatre

Signed-off-by: Future-Outlier <[email protected]>

---------

Signed-off-by: Future-Outlier <[email protected]>
  • Loading branch information
Future-Outlier authored Jan 16, 2025
1 parent 4b50681 commit c3cfa89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 8 additions & 3 deletions flytekit/core/type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,9 +1518,14 @@ async def _literal_map_to_kwargs(
TypeEngine.async_to_python_value(ctx, lm.literals[k], python_interface_inputs[k])
)
await asyncio.gather(*kwargs.values())
except TypeTransformerFailedError as exc:
exc.args = (f"Error converting input '{k}' at position {i}:\n {exc.args[0]}",)
raise
except Exception as e:
raise TypeTransformerFailedError(
f"Error converting input '{k}' at position {i}:\n"
f"Literal value: {lm.literals[k]}\n"
f"Literal type: {literal_types}\n"
f"Expected Python type: {python_interface_inputs[k]}\n"
f"Exception: {e}"
)

kwargs = {k: v.result() for k, v in kwargs.items() if v is not None}
return kwargs
Expand Down
9 changes: 4 additions & 5 deletions tests/flytekit/unit/core/test_type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1896,12 +1896,11 @@ def wf2(a: typing.Union[int, str]) -> typing.Union[int, str]:

with pytest.raises(
TypeError,
match=re.escape(
f"Error encountered while converting inputs of '{exec_prefix}tests.flytekit.unit.core.test_type_hints.t2':\n"
r" Cannot convert from Flyte Serialized object (Literal):"
),
match=(
rf"Error encountered while converting inputs of '{exec_prefix}tests\.flytekit\.unit\.core\.test_type_hints\.t2':\n\s+Error converting input 'a' at position 0:"
),
):
assert wf2(a="2") == "2"
wf2(a="2") # Removed assert as it was not necessary for the exception to be raised


def test_optional_type():
Expand Down

0 comments on commit c3cfa89

Please sign in to comment.