Skip to content
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

predict-drug-target API results in internal server error #3

Open
micheldumontier opened this issue Jun 4, 2024 · 3 comments
Open

Comments

@micheldumontier
Copy link
Collaborator

@vemonet

running /predict-drug-target at https://predict-drug-target.137.120.31.160.nip.io/docs#/

with

{
"subjects": ["PUBCHEM.COMPOUND:5329102"]
}

yields an Internal Server Error

did this service ever work? or ideas about what could be happening? thanks!

@micheldumontier micheldumontier changed the title predict-drug-target API call times out predict-drug-target API results in internal server error Jun 4, 2024
@vemonet
Copy link
Member

vemonet commented Jun 5, 2024

This is the API deployed from the GPU server workspace container, it was more for faster training and testing, the idea was to import the prediction endpoint in translator-openpredict, so we don't need to maintain 5 different APIs, and the underlying trained model was not stable (once boost, once random forest), so there might be change to do in the predict function: https://github.com/MaastrichtU-IDS/predict-drug-target/blob/main/src/predict_drug_target/predict.py

Also checking if the pretrained model file loaded for prediction is were the code expects it to be

Checkout the docker compose logs for more details on the error normally

@micheldumontier
Copy link
Collaborator Author

@vemonet thanks for the info!

@ensaremirerol can you check the docker logs?

@ensaremirerol
Copy link
Member

Pydantic throws validation error when parsing the Response Object

predict-drug-target-api-1  | INFO:     172.19.0.6:49168 - "POST /predict-drug-target HTTP/1.1" 500 Internal Server Error
predict-drug-target-api-1  | 2024-06-05 14:38:36,180 ERROR: [h11_impl:run_asgi] Exception in ASGI application
predict-drug-target-api-1  | Traceback (most recent call last):
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 98, in receive
predict-drug-target-api-1  |     return self.receive_nowait()
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 93, in receive_nowait
predict-drug-target-api-1  |     raise WouldBlock
predict-drug-target-api-1  | anyio.WouldBlock
predict-drug-target-api-1  |
predict-drug-target-api-1  | During handling of the above exception, another exception occurred:
predict-drug-target-api-1  |
predict-drug-target-api-1  | Traceback (most recent call last):
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 78, in call_next
predict-drug-target-api-1  |     message = await recv_stream.receive()
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 118, in receive
predict-drug-target-api-1  |     raise EndOfStream
predict-drug-target-api-1  | anyio.EndOfStream
predict-drug-target-api-1  |
predict-drug-target-api-1  | During handling of the above exception, another exception occurred:
predict-drug-target-api-1  |
predict-drug-target-api-1  | Traceback (most recent call last):
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
predict-drug-target-api-1  |     result = await app(  # type: ignore[func-returns-value]
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
predict-drug-target-api-1  |     return await self.app(scope, receive, send)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/fastapi/applications.py", line 292, in __call__
predict-drug-target-api-1  |     await super().__call__(scope, receive, send)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/applications.py", line 122, in __call__
predict-drug-target-api-1  |     await self.middleware_stack(scope, receive, send)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 184, in __call__
predict-drug-target-api-1  |     raise exc
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 162, in __call__
predict-drug-target-api-1  |     await self.app(scope, receive, _send)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 108, in __call__
predict-drug-target-api-1  |     response = await self.dispatch_func(request, call_next)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/trapi_predict_kit/trapi.py", line 221, in add_process_time_header
predict-drug-target-api-1  |     response = await call_next(request)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 84, in call_next
predict-drug-target-api-1  |     raise app_exc
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 70, in coro
predict-drug-target-api-1  |     await self.app(scope, receive_or_disconnect, send_no_error)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 91, in __call__
predict-drug-target-api-1  |     await self.simple_response(scope, receive, send, request_headers=headers)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 146, in simple_response
predict-drug-target-api-1  |     await self.app(scope, receive, send)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 79, in __call__
predict-drug-target-api-1  |     raise exc
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 68, in __call__
predict-drug-target-api-1  |     await self.app(scope, receive, sender)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
predict-drug-target-api-1  |     raise e
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
predict-drug-target-api-1  |     await self.app(scope, receive, send)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 718, in __call__
predict-drug-target-api-1  |     await route.handle(scope, receive, send)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 276, in handle
predict-drug-target-api-1  |     await self.app(scope, receive, send)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 66, in app
predict-drug-target-api-1  |     response = await func(request)
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 291, in app
predict-drug-target-api-1  |     content = await serialize_response(
predict-drug-target-api-1  |   File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 154, in serialize_response
predict-drug-target-api-1  |     raise ResponseValidationError(
predict-drug-target-api-1  | fastapi.exceptions.ResponseValidationError: 1 validation errors:
predict-drug-target-api-1  |   {'loc': ('response',), 'msg': 'value is not a valid dict', 'type': 'type_error.dict'}
predict-drug-target-api-1  |

I have no clue where this exceptions starts but I would start checking from the end of that function.

Also maybe casting result to its data object might be a good idea in terms of logging

result_dict = {"hits": scores_list, "count": len(scores_list)}
try:
   result_model = PredictOutput(**result_dict)
except ValidationError as e:
   # Logging - print the dict for debugging
except e:
   # For other exceptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants