Skip to content

Commit

Permalink
Fix: Check for duplicate input names before converting args to kwargs
Browse files Browse the repository at this point in the history
- Added validation to check for duplicate input names in the function's input interface.
- Raised a ValueError if duplicate input names are detected to prevent issues during argument assignment.
- Simplified the conversion of args to kwargs by removing the redundant multiple values check.
  • Loading branch information
dalaoqi committed Nov 16, 2024
1 parent c198c1b commit 2ad9c6c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions flytekit/core/promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -1407,10 +1407,14 @@ def flyte_entity_call_handler(
f"Received more arguments than expected in function '{entity.name}'. Expected {len(entity.python_interface.inputs)} but got {len(args)}"
)

input_names = list(entity.python_interface.inputs.keys())

# check for duplicate input names
if len(input_names) != len(set(input_names)):
raise ValueError(f"Duplicate input names detected in function '{entity.name}': {input_names}")

# Convert args to kwargs
for arg, input_name in zip(args, entity.python_interface.inputs.keys()):
if input_name in kwargs:
raise AssertionError(f"Got multiple values for argument '{input_name}' in function '{entity.name}'")
kwargs[input_name] = arg

ctx = FlyteContextManager.current_context()
Expand Down

0 comments on commit 2ad9c6c

Please sign in to comment.