Skip to content

Commit

Permalink
fixes tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <pingsutw@apache.org>
  • Loading branch information
pingsutw committed May 9, 2023
1 parent 5d8cfd2 commit 28930f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions flytekit/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@ def ensure_literal(
except Exception as e:
logger.debug(f"Failed to convert {python_value} to {lt_type} with error {e}")
raise TypeError(f"Failed to convert {python_value} to {input_type}")
if isinstance(python_value, list):
if isinstance(python_value, list) and input_type.collection_type:
collection_lit_type = input_type.collection_type
collection_py_type = get_args(py_type)[0]
xx = [self.ensure_literal(ctx, collection_py_type, collection_lit_type, pv) for pv in python_value]
return _literal_models.Literal(collection=_literal_models.LiteralCollection(literals=xx))
elif isinstance(python_value, dict):
elif isinstance(python_value, dict) and input_type.map_value_type:
mapped_lit_type = input_type.map_value_type
mapped_py_type = get_args(py_type)[1]
xx = {k: self.ensure_literal(ctx, mapped_py_type, mapped_lit_type, v) for k, v in python_value.items()} # type: ignore
Expand All @@ -321,7 +321,7 @@ def ensure_literal(
return res
except TypeTransformerFailedError as exc:
raise TypeError(
f"Failed to convert input argument '{python_value}' of workflow '{self.name}':\n{exc}"
f"Failed to convert input '{python_value}' of workflow '{self.name}':\n {exc}"
) from exc

def local_execute(self, ctx: FlyteContext, **kwargs) -> Union[Tuple[Promise], Promise, VoidPromise, None]:
Expand Down
8 changes: 3 additions & 5 deletions tests/flytekit/unit/core/test_type_conversion_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ def test_workflow_with_task_error(correct_input):
def test_workflow_with_input_error(incorrect_input):
with pytest.raises(
TypeError,
match=(
r"Encountered error while executing workflow '{}':\n"
r" Failed to convert input argument 'a' of workflow '.+':\n"
r" Expected value of type \<class 'int'\> but got .+ of type"
).format(wf_with_output_error.name),
match=(r"Encountered error while executing workflow '{}':\n" r" Failed to convert input").format(
wf_with_output_error.name
),
):
wf_with_output_error(a=incorrect_input)

Expand Down

0 comments on commit 28930f6

Please sign in to comment.