Skip to content

Use an MLflow Serving Run

The service is executed remotely. Call run.refresh() and inspect run.status to check its progress. When ready, the status includes the service details.

By default, invoke() sends requests to the MLServer V2 inference endpoint at http://<service_url>/v2/models/{model_name}/infer. The default model name is "model"; pass model_name if the endpoint uses a different name. You can also pass an explicit url, which must start with the service URL.

run.refresh()
run.status

response = run.invoke(
    model_name="my-model",
    json={"inputs": [...]}
)
invoke

Invoke served model. By default it exposes infer v2 endpoint (http:///v2/models/{model_name}/infer). The method defaults to "POST" if data or json is provided in kwargs, otherwise it defaults to "GET". The function returns a requests.Response object.

Parameters:

Name Type Description Default
model_name str

Name of the model to build the URL for.

None
method str

Method of the request (e.g., "GET", "POST").

'POST'
url str

URL to invoke. If specified, it must start with the service URL (http:// or https:// prefixes are required and stripped before comparison).

None
**kwargs dict

Keyword arguments to pass to the request.

{}

Returns:

Type Description
Response

Response from the request.