Skip to content

Commit

Permalink
feat(bindings): Task arguments default value binding
Browse files Browse the repository at this point in the history
Resolves: flyteorg/flyte#5321
Signed-off-by: Chi-Sheng Liu <[email protected]>
  • Loading branch information
MortalHappiness committed May 9, 2024
1 parent 4dd4d22 commit b434ddf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions flytekit/core/promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ def create_and_link_node(

for k in sorted(interface.inputs):
var = typed_interface.inputs[k]
if k not in kwargs:
if k not in kwargs and k not in interface.inputs_with_defaults:
is_optional = False
if var.type.union_type:
for variant in var.type.union_type.variants:
Expand All @@ -1079,7 +1079,7 @@ def create_and_link_node(
raise _user_exceptions.FlyteAssertion(error_msg)
else:
continue
v = kwargs[k]
v = kwargs.get(k) or interface.inputs_with_defaults.get(k)[1]
# This check ensures that tuples are not passed into a function, as tuples are not supported by Flyte
# Usually a Tuple will indicate that multiple outputs from a previous task were accidentally passed
# into the function.
Expand All @@ -1102,7 +1102,7 @@ def create_and_link_node(
except Exception as e:
raise AssertionError(f"Failed to Bind variable {k} for function {entity.name}.") from e

extra_inputs = used_inputs ^ set(kwargs.keys())
extra_inputs = used_inputs ^ (set(kwargs.keys()) | set(interface.inputs_with_defaults))
if len(extra_inputs) > 0:
raise _user_exceptions.FlyteAssertion(
"Too many inputs were specified for the interface. Extra inputs were: {}".format(extra_inputs)
Expand Down

0 comments on commit b434ddf

Please sign in to comment.