If you have a trained MLflow model you are able to deploy one (or several) of the versions saved using Seldon's prepackaged MLflow server. During initialisation, the built-in reusable server will create the Conda environment specified on your conda.yaml file.
Pre-requisites
To use the built-in MLflow server the following pre-requisites need to be met:
Your MLmodel artifact folder needs to be accessible remotely (e.g. as gs://seldon-models/mlflow/elasticnet_wine_1.8.0).
Your MLproject environment needs to be specified using Conda.
Conda environment creation
The MLflow built-in server will create the Conda environment specified on your MLmodel's conda.yaml file during initialisation. Note that this approach may slow down your Kubernetes SeldonDeployment startup time considerably.
In some cases, it may be worth to consider creating your own custom reusable server. For example, when the Conda environment can be considered stable, you can create your own image with a fixed set of dependencies. This image can then be re-used across different model versions using the same pre-loaded environment.
Note that installation of conda packages may take longer than the livenessProbe limits. This can be worked around by setting longer limits, see our elasticnet wine manifest for an example.
Examples
An example for a saved Iris prediction model can be found below:
By default the server will call your loaded model's predict function with a numpy.ndarray. If you wish for it to call it with pandas.DataFrame instead, you can pass a parameter xtype and set it to DataFrame. For example:
The MLFlow server can also be used to expose an API compatible with the Open Inference Protocol. Note that, under the hood, it will use the Seldon MLServer runtime.
Create a model using mlflow and deploy to seldon-core
As an example we are going to use the elasticnet wine model.
Create a conda environment
Install mlflow
Train the elasticnet wine example
After the script ends, there will be a models persisted at mlruns/0/<uuid>/artifacts/model. This can be fetched from the ui (mlflow ui)
Install additional packaged required to deploy and pack the conda environment using conda-pack
This will pack the current conda environment to environment.tar.gz, this will be required by mlserver to create the same environment used during train for serving the model.
copy the model directory to a Google Storage bucket that is accessible by seldon-core
deploy the model to seldon-core In order to enable support for the Open Inference Protocol, it's enough to specify the protocol of the SeldonDeployment to use v2. For example,
get predictions from the deployed model using REST
Caveats
The version of mlserver installed in the conda environment will need to match the supported version in seldon-core. We are working on tooling to make this more seamless.