Skip to content

Commit

Permalink
Improve error message when omitting task kwarg in workflows (flyteorg…
Browse files Browse the repository at this point in the history
…#1921)

Signed-off-by: Fabio Grätz <[email protected]>
Co-authored-by: Fabio Grätz <[email protected]>
  • Loading branch information
2 people authored and ringohoffman committed Nov 24, 2023
1 parent 5504a43 commit f591e2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion flytekit/core/promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,18 @@ def create_and_link_node(
)
is_optional = True
if not is_optional:
raise _user_exceptions.FlyteAssertion("Input was not specified for: {} of type {}".format(k, var.type))
from flytekit.core.base_task import Task

error_msg = f"Input {k} of type {interface.inputs[k]} was not specified for function {entity.name}"

_, _default = interface.inputs_with_defaults[k]
if isinstance(entity, Task) and _default is not None:
error_msg += (
". Flyte workflow syntax is a domain-specific language (DSL) for building execution graphs which "
"supports a subset of Python’s semantics. When calling tasks, all kwargs have to be provided."
)

raise _user_exceptions.FlyteAssertion(error_msg)
else:
continue
v = kwargs[k]
Expand Down
4 changes: 2 additions & 2 deletions tests/flytekit/unit/core/test_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def test_lps(resource_type):
with context_manager.FlyteContextManager.with_context(ctx.with_new_compilation_state()) as ctx:
with pytest.raises(Exception) as e:
ref_entity()
assert "Input was not specified" in f"{e}"
assert "was not specified for function" in f"{e}"

output = ref_entity(a="hello", b=3)
assert isinstance(output, VoidPromise)
Expand Down Expand Up @@ -321,7 +321,7 @@ def test_ref_sub_wf():
with context_manager.FlyteContextManager.with_context(ctx.with_new_compilation_state()) as ctx:
with pytest.raises(Exception) as e:
ref_entity()
assert "Input was not specified" in f"{e}"
assert "was not specified for function" in f"{e}"

output = ref_entity(a="hello", b=3)
assert isinstance(output, VoidPromise)
Expand Down

0 comments on commit f591e2d

Please sign in to comment.