Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use default inputs with remote LaunchPlan #2372

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
pingsutw marked this conversation as resolved.
Show resolved Hide resolved
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
Loading