MLFlow Server
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 model needs to be compatible with the python_function flavour.
Your
MLprojectenvironment 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:
apiVersion: machinelearning.seldon.io/v1alpha2
kind: SeldonDeployment
metadata:
name: mlflow
spec:
name: wines
predictors:
- graph:
children: []
implementation: MLFLOW_SERVER
modelUri: gs://seldon-models/mlflow/elasticnet_wine_1.8.0
name: classifier
name: default
replicas: 1MLFlow xtype
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:
You can also try out a worked notebook or check our talk at the Spark + AI Summit 2019.
Open Inference Protocol (or V2 protocol)
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
mlflow and deploy to seldon-coreAs an example we are going to use the elasticnet wine model.
Create a
condaenvironment
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
protocolof theSeldonDeploymentto usev2. For example,
get predictions from the deployed model using REST
Caveats
The version of
mlserverinstalled in the conda environment will need to match the supported version inseldon-core. We are working on tooling to make this more seamless.Check the caveats of using
conda-pack
Last updated
Was this helpful?