-
Notifications
You must be signed in to change notification settings - Fork 67
Ianmacleod/error handling #282
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d27bedc
changing exception location
ian-scale-2 93a88d4
Merge branch 'main' of github.com:scaleapi/llm-engine into ianmacleod…
ian-scale-2 e5f448c
adding exception handling for generic exceptions
ian-scale-2 f770842
Merge branch 'main' into ianmacleod/error_handling
ian-scale ab3171f
moving more error handling, still haven't gotten middleware working
ian-scale-2 cd0f733
precommit
ian-scale-2 c3964c1
Merge branch 'ianmacleod/error_handling' of github.com:scaleapi/llm-e…
ian-scale-2 51c63c1
add new error handler middleware
ian-scale-2 9d2fb6b
iterating
ian-scale-2 2675ebf
iterating
ian-scale-2 18a3f14
iterating
ian-scale-2 db470d6
setting DD_REMOTE_CONFIGURATION_ENABLED as false so that we don't get…
ian-scale-2 ffafc2a
updated tracer working?
ian-scale-2 b82acb3
cleanup
ian-scale-2 1c061a6
precommit hooks
ian-scale-2 0b9af7e
Merge branch 'main' into ianmacleod/error_handling
ian-scale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| get_external_interfaces_read_only, | ||
| verify_authentication, | ||
| ) | ||
| from model_engine_server.common.datadog_utils import add_trace_resource_name | ||
| from model_engine_server.common.datadog_utils import add_trace_resource_name, get_request_id | ||
| from model_engine_server.common.dtos.model_endpoints import ( | ||
| CreateModelEndpointV1Request, | ||
| CreateModelEndpointV1Response, | ||
|
|
@@ -24,19 +24,17 @@ | |
| UpdateModelEndpointV1Response, | ||
| ) | ||
| from model_engine_server.core.auth.authentication_repository import User | ||
| from model_engine_server.core.domain_exceptions import ( | ||
| ObjectAlreadyExistsException, | ||
| ObjectHasInvalidValueException, | ||
| ObjectNotApprovedException, | ||
| ObjectNotAuthorizedException, | ||
| ObjectNotFoundException, | ||
| ) | ||
| from model_engine_server.core.loggers import filename_wo_ext, make_logger | ||
| from model_engine_server.domain.exceptions import ( | ||
| EndpointDeleteFailedException, | ||
| EndpointLabelsException, | ||
| EndpointResourceInvalidRequestException, | ||
| ExistingEndpointOperationInProgressException, | ||
| ObjectAlreadyExistsException, | ||
| ObjectHasInvalidValueException, | ||
| ObjectNotApprovedException, | ||
| ObjectNotAuthorizedException, | ||
| ObjectNotFoundException, | ||
| ) | ||
| from model_engine_server.domain.use_cases.model_endpoint_use_cases import ( | ||
| CreateModelEndpointV1UseCase, | ||
|
|
@@ -94,6 +92,13 @@ async def create_model_endpoint( | |
| status_code=404, | ||
| detail="The specified model bundle could not be found.", | ||
| ) from exc | ||
| except Exception as exc: | ||
| request_id = get_request_id() | ||
| logger.exception(f"Internal service error for request {request_id}: {exc}") | ||
| raise HTTPException( | ||
| status_code=500, | ||
| detail=f"Internal error for request_id {request_id}.", | ||
| ) | ||
|
|
||
|
|
||
| @model_endpoint_router_v1.get("/model-endpoints", response_model=ListModelEndpointsV1Response) | ||
|
|
@@ -108,10 +113,18 @@ async def list_model_endpoints( | |
| """ | ||
| add_trace_resource_name("model_endpoints_get") | ||
| logger.info(f"GET /model-endpoints?name={name}&order_by={order_by} for {auth}") | ||
| use_case = ListModelEndpointsV1UseCase( | ||
| model_endpoint_service=external_interfaces.model_endpoint_service, | ||
| ) | ||
| return await use_case.execute(user=auth, name=name, order_by=order_by) | ||
| try: | ||
| use_case = ListModelEndpointsV1UseCase( | ||
| model_endpoint_service=external_interfaces.model_endpoint_service, | ||
| ) | ||
| return await use_case.execute(user=auth, name=name, order_by=order_by) | ||
| except Exception as exc: | ||
| request_id = get_request_id() | ||
| logger.exception(f"Internal service error for request {request_id}: {exc}") | ||
| raise HTTPException( | ||
| status_code=500, | ||
| detail=f"Internal error for request_id {request_id}.", | ||
| ) | ||
|
|
||
|
|
||
| @model_endpoint_router_v1.get( | ||
|
|
@@ -137,6 +150,13 @@ async def get_model_endpoint( | |
| status_code=404, | ||
| detail=f"Model Endpoint {model_endpoint_id} was not found.", | ||
| ) from exc | ||
| except Exception as exc: | ||
| request_id = get_request_id() | ||
| logger.exception(f"Internal service error for request {request_id}: {exc}") | ||
| raise HTTPException( | ||
| status_code=500, | ||
| detail=f"Internal error for request_id {request_id}.", | ||
| ) | ||
|
|
||
|
|
||
| @model_endpoint_router_v1.put( | ||
|
|
@@ -181,6 +201,13 @@ async def update_model_endpoint( | |
| status_code=409, | ||
| detail="Existing operation on endpoint in progress, try again later.", | ||
| ) from exc | ||
| except Exception as exc: | ||
| request_id = get_request_id() | ||
| logger.exception(f"Internal service error for request {request_id}: {exc}") | ||
| raise HTTPException( | ||
| status_code=500, | ||
| detail=f"Internal error for request_id {request_id}.", | ||
| ) | ||
|
|
||
|
|
||
| @model_endpoint_router_v1.delete( | ||
|
|
@@ -216,3 +243,10 @@ async def delete_model_endpoint( | |
| status_code=500, | ||
| detail="deletion of endpoint failed, compute resources still exist.", | ||
| ) from exc | ||
| except Exception as exc: | ||
| request_id = get_request_id() | ||
|
Member
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. Think this is fine for now, but as we revisit self-hosting in VPCs, we'll probably want some sort of Gateway abstraction for getting the request/trace ID. |
||
| logger.exception(f"Internal service error for request {request_id}: {exc}") | ||
| raise HTTPException( | ||
| status_code=500, | ||
| detail=f"Internal error for request_id {request_id}.", | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
adding this configuration because we are currently seeing error logs related to this not being properly set up, the error logs go away when this is off. ref: DataDog/dd-trace-py#5212