Databricks - Machine Learning Professional Study Guide

    2: MLOps

    This chapter moves the Databricks ML lifecycle into production by walking through deploy-code architectures, validation testing across environment tiers, automated retraining triggers, and Lakehouse Monitoring for drift and endpoint health. It maps every lifecycle activity to a concrete Databricks asset and code surface so that an MLflow run becomes a serving endpoint with a monitor and an alert behind it.

    Learning Objectives

    By the end of this chapter, you will be able to:

    • Describe and implement the architecture components of model lifecycle pipelines used to manage environment transitions in the deploy code strategy.
    • Map Databricks features to activities of the model lifecycle management process.
    • Implement unit tests for individual functions in Databricks notebooks to verify they produce expected outputs when given specific inputs.
    • Identify types of testing performed (unit and integration) in various environment stages (dev, test, prod, etc.).
    • Design an integration test for machine learning systems that incorporates common pipelines: feature engineering, training, evaluation, deployment, and inference.
    • Compare the benefits and challenges of approaches for organizing functions and unit tests.

    Executive Summary

    • The deploy-code strategy promotes a Git repository through dev, staging, and prod workspaces using Databricks Asset Bundles, while models are trained inside each environment against environment-scoped Unity Catalog assets and promoted by alias rather than by binary copy.
    • Validation testing on Databricks splits into unit tests on pure Python helpers using pytest plus the workspace-side databricks.connect driver, and integration tests that exercise feature engineering, training, evaluation, deployment, and inference together against a scaled-down dataset in a staging workspace.
    • Automated retraining is event driven: Lakehouse Monitoring writes drift and quality metrics into profile and drift tables, Databricks SQL alerts fire on threshold violations, and a Lakeflow Job kicks off the retraining bundle that re-registers a model version and rolls it forward through the champion alias if it beats the holdout.
    • Lakehouse Monitoring profiles (Snapshot, TimeSeries, InferenceLog) each tie to a different data shape, with InferenceLog being the one designed for inference tables joined to ground truth, custom metrics extending the metrics tables, and endpoint health surfaced through Mosaic AI Model Serving infrastructure metrics for latency, request rate, error rate, CPU, and memory.

    Assumptions

    • The reader has working knowledge of MLflow, Unity Catalog, and Feature Engineering in Unity Catalog as covered in the prior chapter, including model aliases, FeatureLookup, FeatureFunction, point-in-time correctness, online tables, and PyFunc models.
    • All Unity Catalog references use three-level naming <catalog>.<schema>.<object>. Region-specific limits are quoted from the published service limits page, and any number not in a 📊 Limit callout should be treated as configurable per workspace.
    • Code samples are written for a workspace with Unity Catalog as the default MLflow registry, Mosaic AI Model Serving enabled, and Databricks CLI version 0.205 or later for Asset Bundles.

    Sections in this chapter

    1. Free
    2. Free with account
    3. Free with account
    4. Free with account
    5. Free with account
    6. Free with account
    7. Free with account
    8. Free with account
    9. Free with account