Wallaroo SDK Essentials Guide: Model Uploads and Registrations: Containerized MLFlow
Table of Contents
Parameter | Description |
---|---|
Web Site | https://mlflow.org |
Supported Libraries | mlflow==1.3.0 |
For models that do not fall under the supported model frameworks, organizations can use containerized MLFlow ML Models.
This guide details how to add ML Models from a model registry service into Wallaroo.
Wallaroo supports both public and private containerized model registries. See the Wallaroo Private Containerized Model Container Registry Guide for details on how to configure a Wallaroo instance with a private model registry.
Wallaroo users can register their trained MLFlow ML Models from a containerized model container registry into their Wallaroo instance and perform inferences with it through a Wallaroo pipeline.
As of this time, Wallaroo only supports MLFlow 1.30.0 containerized models. For information on how to containerize an MLFlow model, see the MLFlow Documentation.
Model Naming Requirements
Model names map onto Kubernetes objects, and must be DNS compliant. The strings for model names must be lower case ASCII alpha-numeric characters or dash (-) only. .
and _
are not allowed.
Containerized MLFlow Model Operations
Register a Containerized MLFlow Model
Parameter | Description |
---|---|
Web Site | https://mlflow.org |
Supported Libraries | mlflow==1.3.0 |
For models that do not fall under the supported model frameworks, organizations can use containerized MLFlow ML Models.
This guide details how to add ML Models from a model registry service into Wallaroo.
Wallaroo supports both public and private containerized model registries. See the Wallaroo Private Containerized Model Container Registry Guide for details on how to configure a Wallaroo instance with a private model registry.
Wallaroo users can register their trained MLFlow ML Models from a containerized model container registry into their Wallaroo instance and perform inferences with it through a Wallaroo pipeline.
As of this time, Wallaroo only supports MLFlow 1.30.0 containerized models. For information on how to containerize an MLFlow model, see the MLFlow Documentation.
Containerized MLFlow models are not uploaded, but registered from a container registry service. This is performed through the wallaroo.client.register_model_image(options)
, and wallaroo.model_version.configure(options)
method.
IMPORTANT NOTICE
Wallaroo supports both public and private containerized model registries. See the Wallaroo Private Containerized Model Container Registry Guide for details on how to configure a Wallaroo instance with a private model registry.IMPORTANT NOTICE
Models registered through the Wallaroo SDK are associated with the current workspace in the SDK session, assigned as the user’s Default Workspace by default. See Wallaroo SDK Essentials Guide: Workspace Management for full details on creating and working with workspaces.Register a Containerized MLFlow Model Parameters
The following parameters must be set for wallaroo.client.register_model_image(options)
and wallaroo.model_version.configure(options)
for a Containerized MLFlow model to be registered in Wallaroo.
Register Model Image Parameters
Parameter | Type | Description |
---|---|---|
model_name | string (Required) | The name of the model. Model names are unique per workspace. Models that are uploaded with the same name are assigned as a new version of the model. |
image | string (Required) | The URL to the containerized MLFlow model in the MLFlow Registry.. |
Model Version Configuration Parameters
Model version configurations are updated with the wallaroo.model_version.config
and include the following parameters.
Parameter | Type | Description |
---|---|---|
tensor_fields | (List[string]) (Optional) | A list of alternate input fields. For example, if the model accepts the input fields ['variable1', 'variable2'] , tensor_fields allows those inputs to be overridden to ['square_feet', 'house_age'] , or other values as required. These only apply to ONNX models. |
batch_config | (List[string]) (Optional) | Batch config is either None for multiple-input inferences, or single to accept an inference request with only one row of data. |
For model version configuration for MLFlow models, the following must be defined:
runtime
: Set asmlflow
.input_schema
: The input schema from the Apache Arrowpyarrow.lib.Schema
format.output_schema
: The output schema from the Apache Arrowpyarrow.lib.Schema
format.
Register a Containerized MLFlow Model Returns
wallaroo.client.register_model_image(options)
returns the model version. The model version refers to the version of the model object in Wallaroo. In Wallaroo, a model version update happens when we upload a new model file (artifact) against the same model object name.
- Note that models are uploaded to the current workspace assigned in the SDK session. By default, this is the user’s Default Workspace.
Field | Type | Description |
---|---|---|
id | Integer | The numerical identifier of the model version. |
name | String | The name of the model. |
version | String | The model version as a unique UUID. |
file_name | String | The file name of the model as stored in Wallaroo. |
image_path | String | The image used to deploy the model in the Wallaroo engine. |
last_update_time | DateTime | When the model was last updated. |
Register a Containerized MLFlow Model Example
The following example demonstrates registering a Statsmodel model stored in a MLFLow container with a Wallaroo instance.
sm_input_schema = pa.schema([
pa.field('temp', pa.float32()),
pa.field('holiday', pa.uint8()),
pa.field('workingday', pa.uint8()),
pa.field('windspeed', pa.float32())
])
sm_output_schema = pa.schema([
pa.field('predicted_mean', pa.float32())
])
sm_model = wl.register_model_image(
name="mlflow-statmodels",
image="ghcr.io/wallaroolabs/wallaroo_tutorials/mlflow-statsmodels-example:2023.1"
).configure("mlflow",
input_schema=sm_input_schema,
output_schema=sm_output_schema
)
sm_model
Name | mlflowstatmodels |
---|---|
Version | eb1bcec8-63fe-4a82-98ea-fc4945786973 |
File Name | none |
SHA | 3afd13d9c5070679e284050cd099e84aa2e5cb7c08a788b21d6cb2397615d018 |
Status | ready |
Image Path | ghcr.io/wallaroolabs/wallaroo_tutorials/mlflow-statsmodels-example:2023.1 |
Architecture | None |
Updated At | 2024-30-Jan 16:11:55 |
MLFlow Data Formats
When using containerized MLFlow models with Wallaroo, the inputs and outputs must be named. For example, the following output:
[-12.045839810372835]
Would need to be wrapped with the data values named:
[{"prediction": -12.045839810372835}]
A short sample code for wrapping data may be:
output_df = pd.DataFrame(prediction, columns=["prediction"])
return output_df