Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Mlflow Mlflow Get Deploy Client

From Leeroopedia
Revision as of 13:18, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Mlflow_Mlflow_Get_Deploy_Client.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains ML_Ops, Model_Serving
Last Updated 2026-02-13 20:00 GMT

Overview

Concrete tool for obtaining a deployment client that manages model deployments on production platforms through a pluggable interface, provided by the MLflow library.

Description

The get_deploy_client() function is the primary entry point for MLflow's deployment plugin system. Given a target URI (e.g., "sagemaker", "databricks", "redisai"), it resolves the corresponding plugin module, locates the BaseDeploymentClient subclass within that module, and returns an initialized client instance. This client exposes a full CRUD interface for managing deployments: create_deployment(), update_deployment(), delete_deployment(), list_deployments(), get_deployment(), and predict().

The function uses a DeploymentPlugins registry to map target URIs to plugin modules. The "sagemaker" target is registered by default. Additional targets are discovered through Python entry points or explicit registration. If no target_uri is provided, the function falls back to the value set via set_deployments_target() or the MLFLOW_DEPLOYMENTS_TARGET environment variable.

The BaseDeploymentClient abstract base class defines the contract that all deployment plugins must implement. It requires concrete implementations of create_deployment(), update_deployment(), delete_deployment(), list_deployments(), get_deployment(), and predict(). Optional methods include predict_stream(), explain(), and endpoint management operations (create_endpoint(), update_endpoint(), delete_endpoint(), list_endpoints(), get_endpoint()).

Usage

Use this function when you need to programmatically deploy models to production platforms, update running deployments with new model versions, or run predictions against deployed models. It is the standard API for integrating MLflow model deployment into automated ML pipelines, CI/CD workflows, and model management scripts.

Code Reference

Source Location

  • Repository: mlflow
  • File: mlflow/deployments/interface.py (get_deploy_client), mlflow/deployments/base.py (BaseDeploymentClient)
  • Lines: L15-64 (get_deploy_client), L75-359 (BaseDeploymentClient)

Signature

def get_deploy_client(target_uri=None) -> BaseDeploymentClient:
    ...


class BaseDeploymentClient(abc.ABC):
    def __init__(self, target_uri):
        ...

    def create_deployment(self, name, model_uri, flavor=None, config=None, endpoint=None):
        ...

    def update_deployment(self, name, model_uri=None, flavor=None, config=None, endpoint=None):
        ...

    def delete_deployment(self, name, config=None, endpoint=None):
        ...

    def list_deployments(self, endpoint=None):
        ...

    def get_deployment(self, name, endpoint=None):
        ...

    def predict(self, deployment_name=None, inputs=None, endpoint=None):
        ...

Import

from mlflow.deployments import get_deploy_client

I/O Contract

Inputs

Name Type Required Description
target_uri str No URI of the deployment target (e.g., "sagemaker", "databricks"). Falls back to MLFLOW_DEPLOYMENTS_TARGET env var or set_deployments_target() if not provided

create_deployment() parameters:

Name Type Required Description
name str Yes Unique name for the deployment
model_uri str Yes URI of the model to deploy (e.g., runs:/<run_id>/model, models:/<name>/<version>)
flavor str No Model flavor to deploy; if unspecified, a default flavor is chosen
config dict No Target-specific deployment configuration
endpoint str No Endpoint to create the deployment under (may not be supported by all targets)

Outputs

Name Type Description
client BaseDeploymentClient A deployment client instance with CRUD methods: create_deployment(), update_deployment(), delete_deployment(), list_deployments(), get_deployment(), predict()

Usage Examples

Basic Usage

from mlflow.deployments import get_deploy_client
import pandas as pd

# Get a deployment client for the target platform
client = get_deploy_client("sagemaker")

# Create a new deployment
client.create_deployment(
    name="my-model-endpoint",
    model_uri="runs:/abc123/my-model",
    config={"instance_type": "ml.m5.large"},
)

# List all deployments
deployments = client.list_deployments()
print(deployments)

# Get details of a specific deployment
details = client.get_deployment("my-model-endpoint")
print(details)

# Run predictions against the deployment
input_df = pd.DataFrame({"feature_a": [1, 2], "feature_b": [3, 4]})
predictions = client.predict("my-model-endpoint", input_df)
print(predictions)

# Update deployment with a new model version
client.update_deployment(
    name="my-model-endpoint",
    model_uri="runs:/def456/my-model-v2",
)

# Delete the deployment
client.delete_deployment("my-model-endpoint")

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment