Skip to content

Commit

Permalink
Fix use default inputs with remote LaunchPlan (#2372)
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Gomez Ferrer <[email protected]>
  • Loading branch information
andresgomezfrr authored Apr 24, 2024
1 parent 069f87b commit da0485f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 2 additions & 3 deletions flytekit/core/promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 9 additions & 1 deletion tests/flytekit/unit/core/test_promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)

Expand Down

0 comments on commit da0485f

Please sign in to comment.