Skip to content

Ch 15: MLOps & Model Deployment - Introduction

Track: Practitioner | Try code in Playground | Back to chapter overview

Read online or run locally

You can read this content here on the web. To run the code interactively, either use the Playground or clone the repo and open chapters/chapter-15-mlops-and-model-deployment/notebooks/01_packaging_serving.ipynb in Jupyter.


Chapter 15: MLOps — Notebook 01 (Packaging & Serving)

This notebook walks through the MLOps lifecycle, serializes a sklearn model with joblib, defines Pydantic request/response schemas, builds a FastAPI service exercised with TestClient, then writes a minimal Dockerfile with health/readiness probes.

What you'll learn

Topic Section
MLOps lifecycle: package → serve → deploy → monitor → improve §1
joblib serialization and dependency freezing §2
Pydantic request/response schemas §3
FastAPI app with /predict, /health, /version §4
Batching and latency considerations §5
Dockerfile authoring and health/readiness probes §6

Time estimate: 2 hours


Key concepts

  • Packaging — A reproducible bundle: model artifact + version pins + I/O schema.
  • Pydantic schemas — Typed request/response that double as automatic API docs.
  • FastAPI + TestClient — Build and test the service in-process, no port binding required.
  • Health vs readiness — Health says "the process is alive"; readiness says "ready to serve traffic".
  • Dockerfile layers — Order from least- to most-changing for cache-friendly builds.

Run the full notebook in the chapter folder for code and outputs.


Generated by Berta AI