MLServer icon indicating copy to clipboard operation
MLServer copied to clipboard

Show protocol extensions (e.g. model repository) in Swagger docs

Open sauerburger opened this issue 2 years ago • 4 comments

First of all: Thank you for all the work that went into version 1.3.x.

With version 1.2.4, I used to navigate to http://localhost:8080/docs and check which models were loaded, see screenshot below. With the new docs endpoints in 1.3.x, the root /docs route no longer exists. Was this intentional? From the release notes, it sounded to me that the new endpoints were added additionally.

I understand that each model now has a more detailed swagger endpoint, but the repository endpoints are gone. Is there another way to query the list of loaded models?

Screenshot 2023-05-22 at 16 10 01

sauerburger avatar May 22 '23 14:05 sauerburger

Hey @sauerburger ,

The previous docs has now moved to /v2/docs (or /v2/models/.../docs for the model-specific docs). This is also now aligned with the base OpenAPI spec for the Open Inference Protocol which, as you found out, doesn't include the model repository endpoints which fall under an extension to the protocol.

Having said that, I think it's a fair request to also show any protocol extensions on the API docs. I'll rename the issue to make it clear what the fix should incorporate.

In the meantime though, it's important to keep in mind that those are just docs documenting the existing endpoints. The underlying endpoints are still exposed and you can hit them as normal doing something like:

curl -X POST localhost:8080/v2/repository/index -d '{"ready": "true"}'

adriangonz avatar May 23 '23 10:05 adriangonz

Hi @adriangonz ! Thank you for the workaround to reach the /repository/index endpoint, but are you sure this endpoint still works for MLFlow models ? Because I just tested it for MLFlow models and I got:

➜  curl -X POST localhost:8080/v2/repository/index -d '{"ready": "true"}'
{"detail":[{"loc":["body"],"msg":"value is not a valid dict","type":"type_error.dict"}]}%   

MLServer logs:

...
[2023-05-24 12:14:37,716] INFO /root/.mlflow/envs/mlflow-d22cad4ea97c93fd582713c6d2427716a751e0c0/lib/python3.9/site-packages/mlserver/registry.py:167 - Loaded model 'mlflow-model' succesfully.
2023-05-24 12:14:37,719 [mlserver] INFO - Loaded model 'mlflow-model' succesfully.
INFO:     172.17.0.1:50418 - "POST /v2/repository/index HTTP/1.1" 422 Unprocessable Entity

MLServer version: 1.3.2 MLFlow version: 2.3.2

M4nouel avatar May 24 '23 12:05 M4nouel

The workaround above was just provided as guidance. All you need to do is send a POST request (which is all that Swagger UI does). You can use any HTTP client for this.

In this case though, you probably are just missing the right Content-Type:

curl -X POST -H 'Content-Type: application/json' localhost:8080/v2/repository/index -d '{}' 

adriangonz avatar May 24 '23 12:05 adriangonz

My bad, Thank you, it works perfectly !

M4nouel avatar May 24 '23 12:05 M4nouel