Page MenuHomePhabricator

Investigate a way to return other 2xx status code from predict in kserve
Open, Needs TriagePublic

Description

For batch requests to the RRLA model, we want to return HTTP 207 (multi_status) to users when some requests succeed and others fail. We attempted to modify the status code using JSONResponse:

return JSONResponse(
    status_code=HTTPStatus.MULTI_STATUS,
    content={"predictions": predictions + error_msg},
)

However, this resulted in an AttributeError:

"AttributeError : 'JSONResponse' object has no attribute 'encode'"

Full traceback: P62477

In kserve, the response from the predict function appears to be expected to be of dict type, not a JSONResponse or Response that would allow us to change the status code.

In the task, we want to investigate if there is a way to return the status code to another 2xx status code from the predict function.

Relevant links:
https://gerrit.wikimedia.org/r/plugins/gitiles/machinelearning/liftwing/inference-services/+/refs/heads/main/revert_risk_model/model_server/batch_model.py#150
https://github.com/kserve/kserve/blob/v0.12.0/python/kserve/kserve/protocol/rest/v1_endpoints.py#L55
https://github.com/encode/starlette/blob/0.36.3/starlette/responses.py#L44

Related Objects