Skip to main content

MLflow plugin adding a Knative deployment target

Project description

MLflow Knative Deployment Plugin

MLflow plugin adding a Knative deployment client to MLflow CLI and Python API.

Note: MLServer (V2 Inference API) is enabled for all Docker builds.

Requirements

  • Python 3.10+
  • MLflow 2+
  • Docker

The target Kubernetes cluster must be running Knative 1.10+.

Installation

pip install mlflow-knative

Getting Started

A Kubernetes context is required to define the Knative target.
You can list available contexts with kubectl config get-contexts.

Make sure Docker is running locally if you intend create or update a deployment, as this is required to build an image from the MLflow model.

The plugin adds support for a knative target scheme to the mlflow deployments CLI.

Setting the image_repository config key is required to make the Docker image of the model available for deployment by Knative. Additionally you may also provide an image tag with the image_tag config key (defaults to latest).

mlflow deployments create \
  --target knative:/<context> \
  --name <deployment-name> \
  --model-uri models:/<model-name>/<model-version> \
  --config image_repository=<image-repository-URI> \
  --config image_tag=<image-tag>

The plugin provides detailed target help.

mlflow deployments help --target knative

All features are also available as a Python API deployment client.

from mlflow.deployments import get_deploy_client

client = get_deploy_client("knative:/my-cluster")
client.create_deployment(
	"hello-world",
	"models:/hello-world/1",
	config={
		"image_repository": "hello-world"
	}
)

Using a Private Image Repository

To use a private Docker image repository, simply run docker login defore running the deployment client, then use the full repository URI as value for the image_repository config key.

docker login --username <username> --password-stdin <private-repository-URL>

# If using AWS ECR:
aws ecr get-login-password | docker login --username AWS --password-stdin <private-repository-URL>

mlflow deployments create \
  --target knative:/<context> \
  --name <deployment-name> \
  --model-uri models:/<model-name>/<model-version> \
  --config image_repository=<image-repository-URI>  # e.g.: 000000000000.dkr.ecr.eu-west-3.amazonaws.com/model-name

Using a Remote MLflow Model Registry

Set an environment variable as export MLFLOW_TRACKING_URI=<tracking-server-uri> to use a remote MLflow model registry. This also works with a private model registry secured with OAuth 2, using the MLflow OIDC Client Plugin.

Knative Service Configuration

The deployment client can use any available namespace on the target cluster by setting the namespace config key. The default value is default.

mlflow deployments create \
  --target knative:/<context> \
  --name <deployment-name> \
  --model-uri models:/<model-name>/<model-version> \
  --config image_repository=<image-repository-URI> \
  --config namespace=<my-namespace>

To deploy a Knative service with a custom templated manifest, set the service_template config key. The value is a path to the YAML manifest you will be using.

mlflow deployments create \
  --target knative:/<context> \
  --name <deployment-name> \
  --model-uri models:/<model-name>/<model-version> \
  --config image_repository=<image-repository-URI> \
  --config service_template=<path/to/manifest>

$name, $namespace and $image templated values are respectively the deployment name, the provided namespace (or "default"), the image determined from the provided image repository and tag.

License

This project is licensed under the terms of the MIT license.

A yzr Free and Open Source project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlflow_knative-0.1.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlflow_knative-0.1.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file mlflow_knative-0.1.1.tar.gz.

File metadata

  • Download URL: mlflow_knative-0.1.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.4.109+

File hashes

Hashes for mlflow_knative-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ea0e0d3249b49bfc345208dd1d35842b0bb92d42dce69f1ec1dde260f95d3336
MD5 eefe550cbfdc09a18bca800815f23406
BLAKE2b-256 72b89101388f303a75dbdbab6e3b4106f0479ee3882db39127a4f332df0bb27a

See more details on using hashes here.

File details

Details for the file mlflow_knative-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mlflow_knative-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.4.109+

File hashes

Hashes for mlflow_knative-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b1e795fab40f81251513dd8a8eec24e8f3637210c64081daa5347d22d98b588
MD5 8ffefeca4c0efb7dcdc8bf14b25c5a3d
BLAKE2b-256 46825fcd96a1ada277dd6d20b15881b085fdedba209c480654e6f01296e51543

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page