From a7f6341b9ac2bec68703a3c17da823dbc0bfe4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Gr=C3=A4tz?= Date: Thu, 26 Oct 2023 19:07:38 +0200 Subject: [PATCH 1/4] Improve error message when omitting task kwarg in workflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio Grätz --- flytekit/core/promise.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/flytekit/core/promise.py b/flytekit/core/promise.py index 5d598a017a..312007ddca 100644 --- a/flytekit/core/promise.py +++ b/flytekit/core/promise.py @@ -916,7 +916,17 @@ 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 {var.type} was not specified for function {entity.name}" + + if isinstance(entity, Task): + 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] From c9fd276466f770d5618ad18a93eaab4bfd055b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Gr=C3=A4tz?= Date: Thu, 26 Oct 2023 20:05:15 +0200 Subject: [PATCH 2/4] Only add error message addition if default is not None MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio Grätz --- flytekit/core/promise.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flytekit/core/promise.py b/flytekit/core/promise.py index 312007ddca..6f7634d0b2 100644 --- a/flytekit/core/promise.py +++ b/flytekit/core/promise.py @@ -920,7 +920,8 @@ def create_and_link_node( error_msg = f"Input {k} of type {var.type} was not specified for function {entity.name}" - if isinstance(entity, Task): + _, _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." From 380ac2d06279424551f6f1b0c39145d440205d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Gr=C3=A4tz?= Date: Fri, 27 Oct 2023 10:24:35 +0200 Subject: [PATCH 3/4] Adapt tests to modified error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio Grätz --- tests/flytekit/unit/core/test_references.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/flytekit/unit/core/test_references.py b/tests/flytekit/unit/core/test_references.py index 44cfbc7cf5..0e6fb9a70d 100644 --- a/tests/flytekit/unit/core/test_references.py +++ b/tests/flytekit/unit/core/test_references.py @@ -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) @@ -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) From c725eff9f197cf90b94ff7f07fc5096066407073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Gr=C3=A4tz?= Date: Mon, 30 Oct 2023 09:40:17 +0100 Subject: [PATCH 4/4] Log python type instead of literal type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio Grätz --- flytekit/core/promise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flytekit/core/promise.py b/flytekit/core/promise.py index 6f7634d0b2..02c724e3a1 100644 --- a/flytekit/core/promise.py +++ b/flytekit/core/promise.py @@ -918,7 +918,7 @@ def create_and_link_node( if not is_optional: from flytekit.core.base_task import Task - error_msg = f"Input {k} of type {var.type} was not specified for function {entity.name}" + 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: