autotraderuk / fastapi-mlflow

Deploy mlflow models as JSON APIs with minimal new code
Apache License 2.0
19 stars 4 forks source link

Uncaught ValidationErrors causing 500 responses #12

Closed Andrew-Crosby closed 1 year ago

Andrew-Crosby commented 1 year ago

This try/catch block should cover the full function body. The Response constructor can raise a ValidationError if response_data does not have the expected response type.

https://github.com/autotraderuk/fastapi-mlflow/blob/98701a0f5af535ceedda78c07759f5a3b6b62b8e/fastapi_mlflow/predictors.py#L80-L87

bloomonkey commented 1 year ago

Thanks @Andrew-Crosby

Yes, I see. Do you think it would be best to raise the same PyFuncModelPredictError or would something like PyFuncModelPredictionTypeError be better? Either way, I think that this will probably continue to raise a 500 Internal Server Error, as the model is returning data that does not comply with the specified signature (assuming that relevant data types are correctly mapped, see #10 and #11), and there's not much that the fastapi-mlflow code can do to repair or recover.