-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Core][Fix] Fix "No error is raised when the "bind" args does not match the function signature" #47773
Conversation
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.
Otherwise LGTM.
python/ray/actor.py
Outdated
try: | ||
signature.flatten_args(self._signature, args, kwargs) | ||
except TypeError as e: | ||
signature_copy = self._signature.copy() | ||
if len(signature_copy) > 0 and signature_copy[-1].name == "_ray_trace_ctx": | ||
# Remove the trace context arg for readability. | ||
signature_copy.pop(-1) | ||
signature_copy = inspect.Signature(parameters=signature_copy) | ||
raise TypeError( | ||
f"{str(e)}. The function `{self._method_name}` has a signature " | ||
f"`{signature_copy}`, but it doesn't match a given argument to a " | ||
f"bind function. args: {args}. kwargs: {kwargs}." | ||
) from None |
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.
Should this be wrapped into another util method like flatten_args
in signature.py
?
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.
I created a new API validate_args.
For this question, I feel like adding error message here is better (since it needs to access several private attribute. Feel awkward to create a separate util func)
cc @ruisearch42 can you take a look again? |
Just noticed this message, I will review soon! |
Need to fix DCO |
Why are these changes needed?
bind
doesn't check if the arg matches the signature. Fortunately, we already have the logic in .remote that checks it, and we just use the same mechanism. This also provides very nice error message;Related issue number
Closes #47598
Closes #47709
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.