ai4os / DEEPaaS

A REST API to serve machine learning and deep learning models
https://deepaas.readthedocs.io
Apache License 2.0
35 stars 15 forks source link

Exceptions in predict are not propagated to the user #174

Open IgnacioHeredia opened 4 months ago

IgnacioHeredia commented 4 months ago

When a module throws an Exception, the Exception is not forwarded to the user

def predict(**kwargs):
    raise Exception('Test exceptions')

--> Swagger output:

Response body:
500 Internal Server Error
Server got itself in trouble

At some point, I do remember the following approach worked for forwarding errors, but it no longer does:

from aiohttp.web import HTTPBadRequest

def predict(**kwargs):
    raise HTTPBadRequest(reason='Test exceptions')

Swagger seems frozen, and deepaas process throws the following error:

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/home/iheredia/anaconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/iheredia/anaconda3/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/iheredia/anaconda3/lib/python3.8/multiprocessing/pool.py", line 576, in _handle_results
    task = get()
  File "/home/iheredia/anaconda3/lib/python3.8/multiprocessing/connection.py", line 251, in recv
    return _ForkingPickler.loads(buf.getbuffer())
TypeError: __init__() takes 1 positional argument but 2 were given