-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
[Frontend] Refactor error handling for multiple exceptions in preprocessing #26694
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -127,18 +127,9 @@ async def create_completion( | |||||
prompt_embeds=request.prompt_embeds, | ||||||
config=self._build_render_config(request), | ||||||
) | ||||||
except ValueError as e: | ||||||
logger.exception("Error in preprocessing prompt inputs") | ||||||
return self.create_error_response(str(e)) | ||||||
except TypeError as e: | ||||||
logger.exception("Error in preprocessing prompt inputs") | ||||||
return self.create_error_response(str(e)) | ||||||
except RuntimeError as e: | ||||||
logger.exception("Error in preprocessing prompt inputs") | ||||||
return self.create_error_response(str(e)) | ||||||
except jinja2.TemplateError as e: | ||||||
except (ValueError, TypeError, RuntimeError, jinja2.TemplateError) as e: | ||||||
logger.exception("Error in preprocessing prompt inputs") | ||||||
return self.create_error_response(str(e)) | ||||||
return self.create_error_response(f"{e} {e.__cause__}") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While including
Suggested change
|
||||||
|
||||||
# Schedule the request and get the result generator. | ||||||
generators: list[AsyncGenerator[RequestOutput, None]] = [] | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -111,7 +111,7 @@ async def _preprocess( | |||||
return None | ||||||
except (ValueError, TypeError) as e: | ||||||
logger.exception("Error in preprocessing prompt inputs") | ||||||
return self.create_error_response(str(e)) | ||||||
return self.create_error_response(f"{e} {e.__cause__}") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While including
Suggested change
|
||||||
|
||||||
def _build_render_config(self, request: EmbeddingCompletionRequest) -> RenderConfig: | ||||||
# Set max_length based on chunked processing capability | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -163,7 +163,7 @@ async def create_pooling( | |||||
raise ValueError(f"Unsupported request of type {type(request)}") | ||||||
except (ValueError, TypeError, jinja2.TemplateError) as e: | ||||||
logger.exception("Error in preprocessing prompt inputs") | ||||||
return self.create_error_response(str(e)) | ||||||
return self.create_error_response(f"{e} {e.__cause__}") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While including
Suggested change
|
||||||
|
||||||
# Schedule the request and get the result generator. | ||||||
generators: list[AsyncGenerator[PoolingRequestOutput, None]] = [] | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -179,7 +179,7 @@ async def _create_speech_to_text( | |||||
|
||||||
except ValueError as e: | ||||||
logger.exception("Error in preprocessing prompt inputs") | ||||||
return self.create_error_response(str(e)) | ||||||
return self.create_error_response(f"{e} {e.__cause__}") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While including
Suggested change
|
||||||
|
||||||
list_result_generator: list[AsyncGenerator[RequestOutput, None]] | None = None | ||||||
try: | ||||||
|
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.
While including
e.__cause__
is a great improvement for error message clarity, it can beNone
. In that case, the current f-string would append the literal string" None"
to the error message, which could be confusing for the end-user. To provide a cleaner error message, it's better to conditionally include the cause only when it exists.