From da0485faf763de9b0db2b452ea1c97c24f2d213b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20G=C3=B3mez?= Date: Wed, 24 Apr 2024 10:03:47 +0200 Subject: [PATCH] Fix use default inputs with remote LaunchPlan (#2372) Signed-off-by: Andres Gomez Ferrer --- flytekit/core/promise.py | 5 ++--- tests/flytekit/unit/core/test_promise.py | 10 +++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/flytekit/core/promise.py b/flytekit/core/promise.py index d3af6d1823..aa4e5f3150 100644 --- a/flytekit/core/promise.py +++ b/flytekit/core/promise.py @@ -965,9 +965,8 @@ def create_and_link_node_from_remote( for k in sorted(typed_interface.inputs): var = typed_interface.inputs[k] if k not in kwargs: - if _inputs_not_allowed and _ignorable_inputs: - if k in _ignorable_inputs or k in _inputs_not_allowed: - continue + if (_ignorable_inputs and k in _ignorable_inputs) or (_inputs_not_allowed and k in _inputs_not_allowed): + continue # TODO to improve the error message, should we show python equivalent types for var.type? raise _user_exceptions.FlyteAssertion("Missing input `{}` type `{}`".format(k, var.type)) v = kwargs[k] diff --git a/tests/flytekit/unit/core/test_promise.py b/tests/flytekit/unit/core/test_promise.py index 979b80b45f..654bff0294 100644 --- a/tests/flytekit/unit/core/test_promise.py +++ b/tests/flytekit/unit/core/test_promise.py @@ -77,6 +77,9 @@ def wf(i: int, j: int): ... lp = LaunchPlan.get_or_create(wf, name="promise-test", fixed_inputs={"i": 1}, default_inputs={"j": 10}) + lp_without_fixed_inpus = LaunchPlan.get_or_create( + wf, name="promise-test-no-fixed", fixed_inputs=None, default_inputs={"j": 10} + ) ctx = context_manager.FlyteContext.current_context().with_compilation_state(CompilationState(prefix="")) # without providing the _inputs_not_allowed or _ignorable_inputs, all inputs to lp become required, @@ -87,9 +90,14 @@ def wf(i: int, j: int): # Even if j is not provided it will default create_and_link_node_from_remote(ctx, lp, _inputs_not_allowed={"i"}, _ignorable_inputs={"j"}) + # Even if i,j is not provided it will default + create_and_link_node_from_remote( + ctx, lp_without_fixed_inpus, _inputs_not_allowed=None, _ignorable_inputs={"i", "j"} + ) + # value of `i` cannot be overridden with pytest.raises( - FlyteAssertion, match="ixed inputs cannot be specified. Please remove the following inputs - {'i'}" + FlyteAssertion, match="Fixed inputs cannot be specified. Please remove the following inputs - {'i'}" ): create_and_link_node_from_remote(ctx, lp, _inputs_not_allowed={"i"}, _ignorable_inputs={"j"}, i=15)