-
Notifications
You must be signed in to change notification settings - Fork 310
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
feat: support positional args for ref entity #3104
feat: support positional args for ref entity #3104
Conversation
Signed-off-by: machichima <[email protected]>
Signed-off-by: machichima <[email protected]>
Code Review Agent Run #942e72Actionable Suggestions - 1
Review Details
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3104 +/- ##
===========================================
+ Coverage 76.85% 95.24% +18.38%
===========================================
Files 206 85 -121
Lines 21851 3803 -18048
Branches 2837 0 -2837
===========================================
- Hits 16794 3622 -13172
+ Misses 4269 181 -4088
+ Partials 788 0 -788 ☔ View full report in Codecov by Sentry. |
Changelist by BitoThis pull request implements the following key changes.
|
flytekit/core/reference_entity.py
Outdated
@@ -187,7 +186,7 @@ def construct_node_metadata(self) -> _workflow_model.NodeMetadata: | |||
return _workflow_model.NodeMetadata(name=extract_obj_name(self.name)) | |||
|
|||
def compile(self, ctx: FlyteContext, *args, **kwargs): | |||
return create_and_link_node(ctx, entity=self, **kwargs) | |||
return create_and_link_node(ctx, self, *args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider if the change from entity=self
to positional argument self
could impact any callers expecting keyword arguments. The function signature in create_and_link_node
expects entity
as a keyword parameter.
Code suggestion
Check the AI-generated fix before applying
return create_and_link_node(ctx, self, *args, **kwargs) | |
return create_and_link_node(ctx, entity=self, *args, **kwargs) |
Code Review Run #942e72
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
@@ -200,10 +199,6 @@ def __call__(self, *args, **kwargs): | |||
# nothing. Subsequent tasks will have to know how to unwrap these. If by chance a non-Flyte task uses a | |||
# task output as an input, things probably will fail pretty obviously. | |||
# Since this is a reference entity, it still needs to be mocked otherwise an exception will be raised. | |||
if len(args) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we convert args to kwargs here instead? Then, we don't need to change the signature of create_and_link_node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be great to have a small test for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I will modify it and add some tests
Signed-off-by: machichima <[email protected]>
Signed-off-by: machichima <[email protected]>
Signed-off-by: machichima <[email protected]>
Code Review Agent Run #204b34Actionable Suggestions - 2
Additional Suggestions - 10
Review Details
|
flytekit/core/reference_entity.py
Outdated
# Check if we have more arguments than expected | ||
if len(args) > len(interface.inputs): | ||
raise AssertionError( | ||
f"Received more arguments than expected in function '{entity.name}'. Expected {len(interface.inputs)} but got {len(args)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message in the AssertionError
references an undefined entity.name
. Consider using self.name
instead since this is within the ReferenceEntity
class.
Code suggestion
Check the AI-generated fix before applying
f"Received more arguments than expected in function '{entity.name}'. Expected {len(interface.inputs)} but got {len(args)}" | |
f"Received more arguments than expected in function '{self.name}'. Expected {len(interface.inputs)} but got {len(args)}" |
Code Review Run #204b34
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
flytekit/core/reference_entity.py
Outdated
# Convert args to kwargs | ||
for arg, input_name in zip(args, interface.inputs.keys()): | ||
if input_name in kwargs: | ||
raise AssertionError(f"Got multiple values for argument '{input_name}' in function '{entity.name}'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous issue, the error message uses entity.name
which is undefined. Consider using self.name
for consistency.
Code suggestion
Check the AI-generated fix before applying
raise AssertionError(f"Got multiple values for argument '{input_name}' in function '{entity.name}'") | |
raise AssertionError(f"Got multiple values for argument '{input_name}' in function '{self.name}'") |
Code Review Run #204b34
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Signed-off-by: machichima <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Code Review Agent Run #90a123Actionable Suggestions - 0Review Details
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
Signed-off-by: machichima <[email protected]>
Signed-off-by: machichima <[email protected]>
8544ace
Code Review Agent Run #e70869Actionable Suggestions - 0Additional Suggestions - 10
Review Details
|
Signed-off-by: machichima <[email protected]>
Signed-off-by: machichima <[email protected]>
Code Review Agent Run #8bdf2aActionable Suggestions - 0Review Details
|
Tracking issue
Similar to issue: flyteorg/flyte#5320, but for reference entities
Why are the changes needed?
Support positional args for reference task, workflow, and launch plan.
Originally, following code will fail with error like:
FlyteAssertion: USER:AssertionError: error=Cannot call reference entity with args - detected 2 positional args (Promise(node:.x.[]), Promise(node:.y.[]))
What changes were proposed in this pull request?
Write values in positional arguments (args) into kwargs
How was this patch tested?
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Summary by Bito
This PR implements comprehensive Flytekit enhancements including: positional argument support for reference entities, improved task caching with configurable policies, shared memory support in containers, better Ray task configuration and pod template handling, enhanced remote execution monitoring, and updated agent implementations with LiteralMap for output handling. These changes focus on improving system reliability, maintainability, and authentication mechanisms with expanded test coverage.Unit tests added: True
Estimated effort to review (1-5, lower is better): 5