-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[misc] add hint for AttributeError #5462
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.
@youkaichao I like the error message, however needing to manually add a decorator for each function seems messy.
Could you possibly try this method of attaching the decorator to all functions in the _custom_ops
module? I haven't tested this, but it should be something like this
def hint_on_error(fn):
def wrapper(*args, **kwargs):
try:
return fn(*args, **kwargs)
except AttributeError as e:
msg = (
"Error in calling custom op %s: %s\n"
"Possibly you have built or installed an obsolete version of vllm.\n"
"Please try a clean build and install of vllm,"
"or remove old built files such as vllm/*.so and build/ .")
logger.error(msg, fn.__name__, e)
raise e
return wrapper
import sys
import inspect
# Get the current module
current_module = sys.modules[__name__]
# Iterate through all functions in the current module
for name, obj in inspect.getmembers(current_module, inspect.isfunction):
# Apply the decorator to each function
setattr(current_module, name, hint_on_error(obj))
@mgoin I updated the code with auto-decoration. here is the example message I get:
I think this should be clear enough. |
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.
Nice job, I like your approach as a shim
try to fix #5456