-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hi everybody!
I am following the official tutorials and thus my run function looks like this:
@input_schema('data', StandardPythonParameterType(input_sample))
@output_schema(StandardPythonParameterType(output_sample))
def run(data):
try:
result = model.predict(data)
return [result]
except Exception as e:
error = str(e)
return errorSo everything runs fine if the there is no error. But in case of error (e.g. the user inputing the data in the wrong format) the API returns a 200 status code as well accompanied by the string error message as output. This behavior is clear from reading the code. My question is now: how can I make the API return a 500 on error and output the error message?
I tried something like this, but then the 500 was simply included in the output string and it still returned a 200:
return error, 500This happily gives me the string ["some error message", 500] with a 200 status code :)
Any idea how I can achieve this?
Thanks in advance!
Metadata
Metadata
Assignees
Labels
No labels