Technical Documentation: DataTalksClub/mlops-zoomcamp
ℹ️ Provenance: Multi-Tier Ingestion · CodeWiki Reference
Overview (`README.md`)
MLOps Zoomcamp: A Free 9-Week Course on Productionizing ML Services
Quick Links
| Resource | Link |
|---|---|
| Course materials | GitHub repository |
| Video lectures | YouTube playlist |
| Documentation | Zoomcamp Logistics · MLOps Zoomcamp |
| Course platform (deadlines, homework) | courses.datatalks.club |
| Slack channel | #course-mlops-zoomcamp |
| Announcements | Telegram |
| FAQ | FAQ document |
About the Course
MLOps (machine learning operations) is a must-know skill for many data professionals. This free 9-week course teaches the fundamentals of MLOps, from training and experimentation to deployment and monitoring, through structured modules, hands-on workshops, and a final project. Each module introduces core MLOps concepts and tools.
Who Should Join
This course is for data scientists, ML engineers, and software engineers who want to learn how to put machine learning models into production and operate them reliably.
Prerequisites
To get the most out of this course, you should have prior experience with:
- Python
- Docker
- Command line basics
- Machine learning (e.g., through ML Zoomcamp)
- 1+ year of programming experience
How to Take the Course
There are two ways to follow the course: live and self-paced.
| Live Cohort | Self-Paced | |
|---|---|---|
| Start | Not currently scheduled | Anytime |
| Lectures | Pre-recorded | Pre-recorded |
| Homework | Graded | Available but not scored |
| Leaderboard | ✅ Yes | ❌ No |
| Peer Review | ✅ Yes | ❌ No |
| Certificate | ✅ Yes | ❌ No |
| Cost | Free | Free |
| Register | Get updates | Just start learning! |
[!NOTE]
We don't plan to run a live cohort in 2026. The course is fully available for self-paced study now. Register here to be notified if we run a live cohort again.
Self-paced steps:
- Follow the materials on GitHub
- Ask questions and share progress in Slack
- Do the homework (self-checked) and build a project for your portfolio
Syllabus
[Module 1: Introduction](01-intro)
- What is MLOps?
- MLOps maturity model
- NY Taxi dataset (our running example)
- Why MLOps is essential
- Course structure & environment setup
- Homework
[Module 2: Experiment Tracking & Model Management](02-experiment-tracking)
- Introduction to experiment tracking
- MLflow basics
- Model saving and loading
- Model registry
- Hands-on MLflow exercises
- Homework
[Module 3: Orchestration & ML Pipelines](03-orchestration)
- Workflow orchestration
- Homework
[Module 4: Model Deployment](04-deployment)
- Deployment strategies: online (web, streaming) vs. offline (batch)
- Deploying with Flask (web service)
- Streaming deployment with AWS Kinesis & Lambda
- Batch scoring for offline processing
- Homework
[Module 5: Model Monitoring](05-monitoring)
- Monitoring ML-based services
- Web service monitoring with Prometheus, Evidently, and Grafana
- Batch job monitoring with Prefect, MongoDB, and Evidently
- Homework
[Module 6: Best Practices](06-best-practices)
- Unit and integration testing
- Linting, formatting, and pre-commit hooks
- CI/CD with GitHub Actions
- Infrastructure as Code (Terraform)
- Homework
Final Project
The final project integrates everything covered in the course into an end-to-end MLOps pipeline.
Certificate
Certificates are awarded to learners who complete the final project during a live cohort. After the project is graded, the certificate appears on your course platform dashboard once the instructors issue it, and the release is announced in Slack and Telegram. See the certificate guide for how to get it and add it to LinkedIn.
Instructors
Community & Support
Getting Help on Slack
Join the #course-mlops-zoomcamp channel on DataTalks.Club Slack for discussions, troubleshooting, and networking.
To keep discussions organized:
- Follow our guidelines when posting questions.
- Review the community guidelines.
Learning in Public
Share your progress as you go — see the learning in public guide.
Sponsors
Interested in supporting our community? Reach out to [email protected].
FAQ
A few common questions. For everything else, see the full MLOps Zoomcamp FAQ.
Q: Is this course really free?
A: Yes. All videos, materials, and homework are free and open-source.
Q: Do I need prior experience?
A: Yes, some. You should know Python, Docker basics, and the machine learning workflow (for example from ML Zoomcamp), plus about a year of programming experience.
Q: Is there a live cohort?
A: Not currently. The course is fully available for self-paced study. Register on the signup form to be notified if we run a live cohort again.
Q: What does "live cohort" mean? Are there live classes?
A: No mandatory live classes. All lectures are pre-recorded. "Live" means deadlines, scored homework, peer review, and certificate eligibility.
About DataTalks.Club
All the activity at DataTalks.Club mainly happens on Slack. We post updates there and discuss different aspects of data, career questions, and more.
At DataTalks.Club, we organize online events, community activities, and free courses. You can learn more about what we do at DataTalks.Club docs.
Overview (`01-intro/README.md`)
Module 1: Introduction
In this module, we introduce the taxi ride duration example and prepare a Linux-based development environment. We also build the baseline notebook that the rest of the course improves.
1.1 [Introduction](01-introduction.md)
MLOps connects design, training, deployment, and operation around a production ML problem.
1.2 [GitHub Codespaces](02-codespaces.md)
Set up a cloud development workspace with a repository, terminal, Docker, and Jupyter access.
1.3 [VM in AWS](03-aws-vm.md)
Create an optional Ubuntu VM and install the tools used by the course.
1.4 [Reading Parquet Data](04-read-parquet.md)
Read the current NYC taxi data format and install the Parquet engine required by pandas.
1.5 [Training a Ride Duration Prediction Model](05-train-duration-model.md)
Build and evaluate a first baseline for taxi ride duration.
1.6 [Course Overview](06-course-overview.md)
See how the modules turn a notebook into a tracked, deployed, monitored ML service.
1.7 [MLOps Maturity Model](07-maturity-model.md)
Choose an appropriate level of automation for a model and its operating context.
Homework
More information is available in the Module 1 homework.
Optional resources
Use these links when you want to explore the setup or the baseline notebook further.
Community Notes
Share community notes and resources below.
- Local MacOS envprep by Adetbekov
- Environment Setup by Ayoub
- Intro, Environment Setup, and MLOps Maturity Models by Bala
- GCP Environment Setup by Piyush
- Microsoft Azure Environment Setup by Olaide
- Environment Preparation using GCP and pyenv by Dani
- Useful links by Zioalex
- Notes by Alvaro Navas
- Cloud server setup using Deploifai by 98sean98
- Notes from first lesson by Neimv
- Course preliminaries by particle1331
- Notes by Francisco Delca
- MLOps primer by Lorenz
- Notes for Week 1 by Bhagabat
- MLOps introduction by Pathik Ghugare
- Module 1 Notes by Stephen Barrie
- Module 1 Notes by Hongfan
- Comprehensive MLOps guide by Nithish Prabhu
- Environment setup troubleshooting by thatwonguy
- Chapter 1 notes by Marcus
- GCP setup instructions by Marcus
- Machine Learning Essentials by Niting
- GCP Environment Setup with Terraform by Artem
- Week 1 local setup hints by hannarud
- Week 1 detailed notes by Muhammad Shifa
- Send a PR, add your notes above this line
Overview (`02-experiment-tracking/README.md`)
Module 2: Experiment Tracking and Model Management
We record experiments from the taxi duration notebook and follow a model from its first run to a shared registry. We use MLflow for local tracking and model management. We also set up a remote AWS server.
2.1 [Experiment Tracking Intro](01-experiment-tracking-intro.md)
Define the tracking concepts and understand why we keep them together.
2.2 [Getting Started with MLflow](02-mlflow-getting-started.md)
Install MLflow, start the local UI, configure SQLite, and connect the notebook to an experiment.
2.3 [Experiment Tracking with MLflow](03-experiment-tracking.md)
Track hyperparameter search runs, then compare their parameters and metrics.
2.4 [Model Management](04-model-management.md)
Keep selected model artifacts and their lineage after the experiment ends.
2.5 [Model Registry](05-model-registry.md)
Register model versions, review lineage, and coordinate promotion with the deployment process.
2.6 [MLflow in Practice](06-mlflow-in-practice.md)
Choose between local tracking and a shared server with database-backed metadata and S3 artifacts.
2.7 [MLflow: Benefits, Limitations and Alternatives](07-mlflow-alternatives.md)
Evaluate the trade-offs of MLflow and compare the requirements that matter when choosing a tracking platform.
Homework
More information is available in the Module 2 homework.
Optional resources
Use these links to explore the presentation, AWS setup, and current MLflow documentation.
Use search_experiments in current MLflow versions instead of list_experiments, and follow the MLflow issue when you update older notebooks.
Community Notes
Share community notes and resources below.
- Notes and general MLflow documentation by Ayoub
- Minimalist MLflow code reference by Anna V
- Notes from the second lesson by Neimv
- Experiment tracking notes by Ayoub B
- Experiment tracking by particle1331
- Week 2 experiment tracking notes by Bengsoon Chuah
- Model management notes by Alvaro Pena
- Notes by Alvaro Navas
- Notebook by froukje and notes
- MLflow on GCP by Isaac Kargar
- Week 2 experiment tracking notes by Bhagabat
- MLflow notes by Jaime Cabrera-Salcedo
- Experiment tracking with MLflow by Hongfan
- Running MLflow with Docker and Minikube
- Chapter 2 notes by Marcus
- Experiment tracking by Annaliese Tech
- Hyperparameter tuning with MLflow by Annaliese Tech
- MLflow setup and tracking by Hokfu
- 2025 notes on MLflow and Hyperopt by Gabi Fonseca
- Homework 2 article by Srikanth Ganji
- Week 2 detailed notes by Muhammad Shifa
- Send a PR, add your notes above this line
Overview (`03-orchestration/README.md`)
Module 3: Orchestration and ML Pipelines
We turn the duration prediction notebook into a repeatable, parameterized training script and then connect it to the concepts of workflow orchestration.
3.1 [Introduction to ML Pipelines](01-ml-pipelines.md)
Define a training pipeline, make its dependencies explicit, and distinguish pipeline logic from orchestration.
3.2 [Turning the Notebook into a Python Script](02-notebook-to-script.md)
Refactor the notebook into functions, expose the training period as command-line parameters, and preserve MLflow metadata.
3.3 [Using an Orchestrator](03-orchestrator.md)
Schedule, parameterize, backfill, and optionally deploy the training workflow with an orchestrator.
Homework
More information is available in the Module 3 homework.
Optional resources
MLflow
To run MLflow with Docker, create an mlflow.dockerfile:
FROM python:3.10-slim
RUN pip install mlflow==2.12.1
EXPOSE 5000
CMD [ \
"mlflow", "server", \
"--backend-store-uri", "sqlite:///home/mlflow_data/mlflow.db", \
"--host", "0.0.0.0", \
"--port", "5000" \
]Add it to docker-compose.yaml and persist the MLflow data directory:
mlflow:
build:
context: .
dockerfile: mlflow.dockerfile
ports:
- "5000:5000"
volumes:
- "${PWD}/mlflow_data:/home/mlflow_data/"Use the same MLflow version in the training environment. The service should then be reachable at http://localhost:5000 from the host or at http://mlflow:5000 from another Compose service.
Community Notes
Share community notes and resources below.
Previous-edition notes:
2025 notes:
- Running Airflow + MLflow using Docker by André Calatré
- Week 3 workflow orchestration and Prefect by hannarud
- Orchestration with Prefect notes and code by Muhammad Shifa
- Send a PR, add your notes above this line
Overview (`04-deployment/README.md`)
Module 4: Model Deployment
We package the duration model as a web service and connect serving to the model registry. We also compare online, streaming, and batch deployment modes.
4.1 [Three Ways of Deploying a Model](01-deployment-modes.md)
Compare batch, online, and event-driven streaming deployment and choose the boundary that fits the prediction requirement.
4.2 [Web Services: Deploying Models with Flask and Docker](02-flask-docker.md)
Build a Flask prediction endpoint, test it, and package it with its model artifacts in Docker.
4.3 [Web Services: Getting Models from the Model Registry](03-model-registry-serving.md)
Load a selected MLflow model version at serving time instead of bundling a fixed artifact into the image.
4.4 [Streaming: Deploying Models with Kinesis and Lambda](04-streaming-kinesis-lambda.md)
Optionally consume Kinesis events with a containerized Lambda function and produce predictions.
4.5 [Batch: Preparing a Scoring Script](05-batch-scoring.md)
Turn a scoring notebook into a parameterized script that can run scheduled batches and backfills.
4.6 [Batch Scoring with Mage](06-mage-batch-scoring.md)
Use a Mage transformation block to retrieve a model from MLflow and apply it to a batch.
Homework
More information is available in the Module 4 homework.
Code and resources
The main code examples are:
The streaming exercise can create AWS charges. Treat it as optional and remove test resources when finished. Use the local tests in Module 6 when you don't want to deploy cloud resources.
Community Notes
Share community notes and resources below.
- Notes on model deployment and creating a modeling package by Ron M.
- Model deployment on Google Cloud Platform by M. Ayoub C.
- Week 4 deployment notes by Bhagabat
- Week 4 deployment notes by Ayoub B.
- Week 4 deployment notes by Waleed
- Offline, online, and streaming deployment notes by Hongfan
- Week 4 notes by Marcus
- 2025 model deployment notes by Nitin Gupta
- Week 4 detailed notes by Muhammad Shifa
- Send a PR, add your notes above this line
Overview (`05-monitoring/README.md`)
Module 5: Model Monitoring
We define production monitoring metrics and calculate Evidently results. We store them in PostgreSQL, then expose them through Grafana dashboards and debugging reports.
5.1 [Intro to ML Monitoring](01-ml-monitoring.md)
Separate service health, model performance, data quality, and drift indicators.
5.2 [Environment Setup](02-monitoring-environment.md)
Create the Python and Docker Compose environment for metric calculation, PostgreSQL, Adminer, and Grafana.
5.3 [Prepare Reference and Model](03-reference-model.md)
Train a baseline model and save the reference dataset used for later comparisons.
5.4 [Evidently Metrics Calculation](04-evidently-metrics.md)
Compare reference and current batches, then persist selected metrics for time-series monitoring.
5.5 [Evidently Monitoring Dashboard](05-evidently-dashboard.md)
Create a workspace for reports and model/data behavior.
5.6 [Dummy Monitoring](06-dummy-monitoring.md)
Test the database and dashboard path with repeatable synthetic values before adding model metrics.
5.7 [Data Quality Monitoring](07-data-quality.md)
Add data-quality checks, schedule metric calculations, and choose thresholds with model owners.
5.8 [Save Grafana Dashboard](08-save-grafana-dashboard.md)
Provision a saved Grafana dashboard from versioned JSON and configuration files.
5.9 [Debugging with Test Suites and Reports](09-debugging-tests-reports.md)
Use Evidently reports and test suites to investigate a monitoring metric.
5.10 [Monitoring Example](10-monitoring-example.md)
Run the local end-to-end monitoring stack with Docker Compose, PostgreSQL, and Grafana.
Homework
More information is available in the Module 5 homework.
Code and resources
The current requirements set Evidently to 0.6.7. Compare this code with the Evidently 0.7 example when updating the API.
- Monitoring services
- Metric calculation
- Dummy metric calculation
- Baseline model notebook
- Debugging notebook
Community Notes
Share community notes and resources below.
- Week 5 notes by M. Ayoub C.
- Week 5 monitoring notes by Ayoub B.
- Week 5 notes from 2023
- Why monitor models after deployment? by Hongfan
- Week 5 detailed notes by Muhammad Shifa
- Send a PR, add your notes above this line
Overview (`06-best-practices/README.md`)
Module 6: Best Practices
We make the deployed model easier to test, review, provision, and deliver. We move from Python tests through Terraform and GitHub Actions.
6.1 [Testing Python Code with pytest](01-pytest.md)
Separate model logic from cloud clients and cover the service with fast unit tests.
6.2 [Integration Tests with docker-compose](02-docker-compose-tests.md)
Start the service in Docker and verify its HTTP API with a deterministic test event.
6.3 [Testing Cloud Services with LocalStack](03-localstack.md)
Exercise Kinesis-compatible behavior locally without creating real AWS resources.
6.4 [Code Quality: Linting and Formatting](04-linting-formatting.md)
Use isort, Black, and Pylint to keep code consistent and catch common problems.
6.5 [Git Pre-commit Hooks](05-pre-commit.md)
Run project checks automatically before creating a commit.
6.6 [Makefiles and make](06-makefiles.md)
Give tests, quality checks, builds, and deployment steps stable command names.
6.7 [Terraform: Introduction](07-terraform-introduction.md)
Describe the AWS stream-based prediction infrastructure as version-controlled code.
6.8 [Terraform: Modules and Output Variables](08-terraform-modules.md)
Extract reusable infrastructure and pass resource identifiers between modules.
6.9 [Build an End-to-end Ride Prediction Workflow](09-terraform-pipeline.md)
Connect Kinesis, Lambda, S3, and ECR into a deployable prediction workflow.
6.10 [Test the Pipeline End to End](10-terraform-testing.md)
Send a ride event through the deployed pipeline and review the prediction output.
6.11 [CI/CD: Introduction](11-cicd-introduction.md)
Map pull-request checks and delivery jobs onto the ride-prediction architecture.
6.12 [Continuous Integration](12-continuous-integration.md)
Run tests and Terraform plan automatically for proposed changes.
6.13 [Continuous Delivery](13-continuous-delivery.md)
Build, publish, and deploy the service after an approved change.
Homework
More information is available in the Module 6 homework.
Code and resources
Resources:
- Best-practices code
- Terraform concepts and references
- AWS stream-pipeline source diagram
- CI/CD source diagram
Cloud resources can incur charges. Destroy temporary infrastructure after testing and keep credentials out of the repository.
Community Notes
Share community notes and resources below.
- Week 6a notes by M. Ayoub C.
- Unit tests, integration tests, LocalStack, code quality, pre-commit, and Makefile notes by Hongfan
- Week 6 notes from 2023
- 2025 best-practices notes and FAQ by Nitin Gupta
- Week 6 detailed notes by Muhammad Shifa
- Send a PR, add your notes above this line
Overview (`07-project/README.md`)
Course Project
Watch the course project video
Objective
The goal of this project is to apply everything we have learned
in this course to build an end-to-end machine learning project.
Problem statement
For the project, we will ask you to build an end-to-end ML project.
For that, you will need:
- Select a dataset that you're interested in (see Datasets)
- Train a model on that dataset tracking your experiments
- Create a model training pipeline
- Deploy the model in batch, web service or streaming
- Monitor the performance of your model
- Follow the best practices
Datasets you cannot use
The NYC taxi dataset is used throughout the course modules and homework. It cannot be used for the project. Pick any other dataset.
Technologies
You don't have to limit yourself to technologies covered in the course. You can use alternatives as well:
- Cloud: AWS, GCP, Azure, ...
- Experiment tracking tools: MLFlow, Weights & Biases, ...
- Workflow orchestration: Prefect, Airflow, Flyte, Kubeflow, Argo, ...
- Monitoring: Evidently, WhyLabs/whylogs, ...
- CI/CD: Github actions, Gitlab CI/CD, ...
- Infrastructure as code (IaC): Terraform, Pulumi, Cloud Formation, ...
If you use a tool that wasn't covered in the course, be sure to explain what that tool does.
If you're not certain about some tools, ask in Slack.
Peer reviewing
[!IMPORTANT]
To evaluate the projects, we'll use peer reviewing. This is a great opportunity for you to learn from each other.
- To get points for your project, you need to evaluate 3 projects of your peers
- You get 3 extra points for each evaluation
Evaluation Criteria
- Problem description
- 0 points: The problem is not described
- 1 point: The problem is described but shortly or not clearly
- 2 points: The problem is well described and it's clear what the problem the project solves
- Cloud
- 0 points: Cloud is not used, things run only locally
- 2 points: The project is developed on the cloud OR uses localstack (or similar tool) OR the project is deployed to Kubernetes or similar container management platforms
- 4 points: The project is developed on the cloud and IaC tools are used for provisioning the infrastructure
- Experiment tracking and model registry
- 0 points: No experiment tracking or model registry
- 2 points: Experiments are tracked or models are registered in the registry
- 4 points: Both experiment tracking and model registry are used
- Workflow orchestration
- 0 points: No workflow orchestration
- 2 points: Basic workflow orchestration
- 4 points: Fully deployed workflow
- Model deployment
- 0 points: Model is not deployed
- 2 points: Model is deployed but only locally
- 4 points: The model deployment code is containerized and could be deployed to cloud or special tools for model deployment are used
- Model monitoring
- 0 points: No model monitoring
- 2 points: Basic model monitoring that calculates and reports metrics
- 4 points: Comprehensive model monitoring that sends alerts or runs a conditional workflow (e.g. retraining, generating debugging dashboard, switching to a different model) if the defined metrics threshold is violated
- Reproducibility
- 0 points: No instructions on how to run the code at all, the data is missing
- 2 points: Some instructions are there, but they are not complete OR instructions are clear and complete, the code works, but the data is missing
- 4 points: Instructions are clear, it's easy to run the code, and it works. The versions for all the dependencies are specified.
- Best practices
- There are unit tests (1 point)
- There is an integration test (1 point)
- Linter and/or code formatter are used (1 point)
- There's a Makefile (1 point)
- There are pre-commit hooks (1 point)
- There's a CI/CD pipeline (2 points)
[!NOTE]
It's highly recommended to create a new repository for your project (not inside an existing repo) with a meaningful title, such as
"Car Price Prediction" or "Music Genre Classification" and include as many details as possible in the README file. ChatGPT can assist you with this. Doing so will not only make it easier to showcase your project for potential job opportunities but also have it featured on the Projects Gallery App.
If you leave the README file empty or with minimal details, there may be point deductions as per the Evaluation Criteria.
Resources
Datasets
Refer to the provided datasets for possible selection.
Projects Gallery
Explore a collection of projects completed by members of our community. The projects cover a wide range of topics and utilize different tools and techniques. Feel free to delve into any project and see how others have tackled real-world problems with data, structured their code, and presented their findings. It's a great resource to learn and get ideas for your own projects.
MLOps Zoomcamp 2023
MLOps Zoomcamp 2022
Overview (`cohorts/README.md`)
Cohorts
Each cohorts/<year>/ directory here is a frozen, self-contained copy of one
past live delivery of the course: 2022, 2023, 2024, 2025. Every one of
them has a cohort.yaml (curriculum: github_archive) recording its dates
and pointing at a notice file — added after the fact, since none of these
years originally shipped with any manifest at all. Their interior (module
directories, differing content per year) is untouched pre-migration content,
not reshaped to match any newer convention.
cohorts/2022/ has no README.md — its cohort.yaml points itsarchive.notice_path at leaderboard.md instead, the closest thing it has
to a cohort-identifying document. That's a gap worth a human decision on
whether to add a real README there; it hasn't been treated as blocking.
The current cohort is `self-paced`, not a year
There is no live cohort scheduled for this course — see the rootREADME.md: "We don't plan to run a live cohort in
2026... fully available for self-paced study now." Root
(01-intro/ through 07-project/) holds
that actively-maintained self-paced material, and is what content: root
means in course.yaml.
cohorts/self-paced/cohort.yaml represents that: identifier: "self-paced",delivery: self_paced, curriculum: current, start_date/end_date: null
(a self-paced delivery has no cohort-wide deadline), homework: [] (nothing
is currently graded or tracked). course.yaml:current_cohort names it the
same way a year would for a live delivery.
What's still deferred: each root module is presently a single long-formREADME.md, not the module.yaml + numbered NN-kebab.md lesson files the
shared-root v2 contract expects. The checker (scripts/check-zoomcamp) knows
about this and reports it (numbered_module_required,current_module_missing) — those are expected, not a sign something broke.
Restructuring each module's content into that shape is separate, real
editorial work, not done here.
The conventions themselves
DataTalksClub/zoomcamp-ops is the authority: STRUCTURE.md for the
repository layout and docs/shared-curriculum-v2.md for the shared-root
schema this repository's course.yaml now follows, plus the curriculum
contract documented beside it for the YAML schemas and the unit page rules.
The website's ingestion parser is the final authority and fails loudly on
push.
Overview (`04-deployment/batch/README.md`)
Batch deployment
- Turn the notebook for training a model into a notebook for applying the model
- Turn the notebook into a script
- Clean it and parametrize
Overview (`04-deployment/streaming/README.md`)
Machine Learning for Streaming
- Scenario
- Creating the role
- Create a Lambda function, test it
- Create a Kinesis stream
- Connect the function to the stream
- Send the records
Links
Code snippets
Sending data
KINESIS_STREAM_INPUT=ride_events
aws kinesis put-record \
--stream-name ${KINESIS_STREAM_INPUT} \
--partition-key 1 \
--data "Hello, this is a test."Decoding base64
base64.b64decode(data_encoded).decode('utf-8')Record example
{
"ride": {
"PULocationID": 130,
"DOLocationID": 205,
"trip_distance": 3.66
},
"ride_id": 123
}Sending this record
aws kinesis put-record \
--stream-name ${KINESIS_STREAM_INPUT} \
--partition-key 1 \
--data '{
"ride": {
"PULocationID": 130,
"DOLocationID": 205,
"trip_distance": 3.66
},
"ride_id": 156
}'Test event
{
"Records": [
{
"kinesis": {
"kinesisSchemaVersion": "1.0",
"partitionKey": "1",
"sequenceNumber": "49630081666084879290581185630324770398608704880802529282",
"data": "ewogICAgICAgICJyaWRlIjogewogICAgICAgICAgICAiUFVMb2NhdGlvbklEIjogMTMwLAogICAgICAgICAgICAiRE9Mb2NhdGlvbklEIjogMjA1LAogICAgICAgICAgICAidHJpcF9kaXN0YW5jZSI6IDMuNjYKICAgICAgICB9LCAKICAgICAgICAicmlkZV9pZCI6IDI1NgogICAgfQ==",
"approximateArrivalTimestamp": 1654161514.132
},
"eventSource": "aws:kinesis",
"eventVersion": "1.0",
"eventID": "shardId-000000000000:49630081666084879290581185630324770398608704880802529282",
"eventName": "aws:kinesis:record",
"invokeIdentityArn": "arn:aws:iam::XXXXXXXXX:role/lambda-kinesis-role",
"awsRegion": "eu-west-1",
"eventSourceARN": "arn:aws:kinesis:eu-west-1:XXXXXXXXX:stream/ride_events"
}
]
}Reading from the stream
KINESIS_STREAM_OUTPUT='ride_predictions'
SHARD='shardId-000000000000'
SHARD_ITERATOR=$(aws kinesis \
get-shard-iterator \
--shard-id ${SHARD} \
--shard-iterator-type TRIM_HORIZON \
--stream-name ${KINESIS_STREAM_OUTPUT} \
--query 'ShardIterator' \
)
RESULT=$(aws kinesis get-records --shard-iterator $SHARD_ITERATOR)
echo ${RESULT} | jq -r '.Records[0].Data' | base64 --decodeRunning the test
export PREDICTIONS_STREAM_NAME="ride_predictions"
export RUN_ID="e1efc53e9bd149078b0c12aeaa6365df"
export TEST_RUN="True"
python test.pyPutting everything to Docker
docker build -t stream-model-duration:v1 .
docker run -it --rm \
-p 8080:8080 \
-e PREDICTIONS_STREAM_NAME="ride_predictions" \
-e RUN_ID="e1efc53e9bd149078b0c12aeaa6365df" \
-e TEST_RUN="True" \
-e AWS_DEFAULT_REGION="eu-west-1" \
stream-model-duration:v1URL for testing:
Configuring AWS CLI to run in Docker
To use AWS CLI, you may need to set the env variables:
docker run -it --rm \
-p 8080:8080 \
-e PREDICTIONS_STREAM_NAME="ride_predictions" \
-e RUN_ID="e1efc53e9bd149078b0c12aeaa6365df" \
-e TEST_RUN="True" \
-e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
-e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
-e AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" \
stream-model-duration:v1Alternatively, you can mount the .aws folder with your credentials to the .aws folder in the container:
docker run -it --rm \
-p 8080:8080 \
-e PREDICTIONS_STREAM_NAME="ride_predictions" \
-e RUN_ID="e1efc53e9bd149078b0c12aeaa6365df" \
-e TEST_RUN="True" \
-v c:/Users/alexe/.aws:/root/.aws \
stream-model-duration:v1Publishing Docker images
Creating an ECR repo
aws ecr create-repository --repository-name duration-modelLogging in
$(aws ecr get-login --no-include-email)Pushing
REMOTE_URI="387546586013.dkr.ecr.eu-west-1.amazonaws.com/duration-model"
REMOTE_TAG="v1"
REMOTE_IMAGE=${REMOTE_URI}:${REMOTE_TAG}
LOCAL_IMAGE="stream-model-duration:v1"
docker tag ${LOCAL_IMAGE} ${REMOTE_IMAGE}
docker push ${REMOTE_IMAGE}Overview (`04-deployment/web-service-mlflow/README.md`)
Getting the model for deployment from MLflow
- Take the code from the previous video
- Train another model, register with MLflow
- Put the model into a scikit-learn pipeline
- Model deployment with tracking server
- Model deployment without the tracking server
Starting the MLflow server with S3:
mlflow server \
--backend-store-uri=sqlite:///mlflow.db \
--default-artifact-root=s3://mlflow-models-alexey/Downloading the artifact
export MLFLOW_TRACKING_URI="http://127.0.0.1:5000"
export MODEL_RUN_ID="6dd459b11b4e48dc862f4e1019d166f6"
mlflow artifacts download \
--run-id ${MODEL_RUN_ID} \
--artifact-path model \
--dst-path .Overview (`04-deployment/web-service/README.md`)
Deploying a model as a web-service
- Creating a virtual environment with Pipenv
- Creating a script for predictiong
- Putting the script into a Flask app
- Packaging the app to Docker
docker build -t ride-duration-prediction-service:v1 .docker run -it --rm -p 9696:9696 ride-duration-prediction-service:v1Overview (`05-monitoring/post-evidently-0.7/README.md`)
5. Model Monitoring
5.1 Intro to ML monitoring
Watch the monitoring introduction
5.2 Environment setup
Watch the monitoring environment setup
5.3 Prepare reference and model
Watch the reference and model preparation video
5.4 Evidently metrics calculation
Watch the Evidently metrics video
5.5 Evidently Monitoring Dashboard
Watch the Evidently dashboard video
5.6 Dummy monitoring
Watch the dummy monitoring video
5.7 Data quality monitoring
Watch the data quality monitoring video
Note: in this video we use Prefect (07:33-11:21). Feel free to skip this part. Also note that Prefect
is not officially supported in the 2024 edition of the course.
5.8 Save Grafana Dashboard
Watch the dashboard saving video
5.9 Debugging with test suites and reports
Watch the debugging and reports video
Homework
More information here
Notes
Did you take notes? Add them here:
- Week 5 notes by M. Ayoub C.
- week 5: Monitoring notes Ayoub.B
- Week 5: 2023
- Week5: Why we need to monitor models after deployment? by Hongfan (Amber)
- Send a PR, add your notes above this line
Monitoring example
Prerequisites
You need following tools installed:
dockerdocker-compose(included to Docker Desktop for Mac and Docker Desktop for Windows )
Preparation
Note: all actions expected to be executed in repo folder.
- Create virtual environment and activate it (eg.
python -m venv venv && source ./venv/bin/activateorconda create -n venv python=3.11 && conda activate venv) - Install required packages
pip install -r requirements.txt - Run
baseline_model_nyc_taxi_data.ipynbfor downloading datasets, training model and creating reference dataset
Monitoring Example
Starting services
To start all required services, execute:
docker-compose upIt will start following services:
db- PostgreSQL, for storing metrics dataadminer- database management toolgrafana- Visual dashboarding tool
Sending data
To calculate evidently metrics with prefect and send them to database, execute:
python evidently_metrics_calculation.pyThis script will simulate batch monitoring. Every 10 seconds it will collect data for a daily batch, calculate metrics and insert them into database. This metrics will be available in Grafana in preconfigured dashboard.
Accsess dashboard
In your browser go to a
localhost:3000
The default username and password areadminThen navigate to
General/Homemenu and click onHome.In the folder
Generalyou will seeNew Dashboard. Click on it to access preconfigured dashboard.
Ad-hoc debugging
Run debugging_nyc_taxi_data.ipynb to see how you can perform a debugging with help of Evidently TestSuites and Reports
Stopping services
To stop all services, execute:
docker-compose downOverview (`06-best-practices/code/README.md`)
Code snippets
Building and running Docker images
docker build -t stream-model-duration:v2 .docker run -it --rm \
-p 8080:8080 \
-e PREDICTIONS_STREAM_NAME="ride_predictions" \
-e RUN_ID="e1efc53e9bd149078b0c12aeaa6365df" \
-e TEST_RUN="True" \
-e AWS_DEFAULT_REGION="eu-west-1" \
stream-model-duration:v2Mounting the model folder:
docker run -it --rm \
-p 8080:8080 \
-e PREDICTIONS_STREAM_NAME="ride_predictions" \
-e RUN_ID="Test123" \
-e MODEL_LOCATION="/app/model" \
-e TEST_RUN="True" \
-e AWS_DEFAULT_REGION="eu-west-1" \
-v $(pwd)/model:/app/model \
stream-model-duration:v2Specifying endpoint URL
aws --endpoint-url=http://localhost:4566 \
kinesis list-streamsaws --endpoint-url=http://localhost:4566 \
kinesis create-stream \
--stream-name ride_predictions \
--shard-count 1aws --endpoint-url=http://localhost:4566 \
kinesis get-shard-iterator \
--shard-id ${SHARD} \
--shard-iterator-type TRIM_HORIZON \
--stream-name ${PREDICTIONS_STREAM_NAME} \
--query 'ShardIterator'Unable to locate credentials
If you get 'Unable to locate credentials' error, add these
env variables to the docker-compose.yaml file:
- AWS_ACCESS_KEY_ID=abc
- AWS_SECRET_ACCESS_KEY=xyzMake
Without make:
isort .
black .
pylint --recursive=y .
pytest tests/With make:
make quality_checks
make testTo prepare the project, run
make setupIaC
w/ Terraform
Setup
Installation:
- aws-cli (both versions are fine)
- terraform client
Configuration:
If you've already created an AWS account, head to the IAM section, generate your secret-key, and download it locally.
InstructionsConfigure
aws-cliwith your downloaded AWS secret keys:shell$ aws configure AWS Access Key ID [None]: xxx AWS Secret Access Key [None]: xxx Default region name [None]: eu-west-1 Default output format [None]:Verify aws config:
shell$ aws sts get-caller-identity
Execution
To create infra (manually, in order to test on staging env)
shell# Initialize state file (.tfstate) terraform init # Check changes to new infra plan terraform plan -var-file=vars/stg.tfvarsshell# Create new infra terraform apply -var-file=vars/stg.tfvarsTo prepare aws env (copy model artifacts, set env-vars for lambda etc.):
text. ./scripts/deploy_manual.shTo test the pipeline end-to-end with our new cloud infra:
text. ./scripts/test_cloud_e2e.shAnd then check on CloudWatch logs. Or try
get-recordson theoutput_kinesis_stream(refer tointegration_test)Destroy infra after use:
shell# Delete infra after your work, to avoid costs on any running services terraform destroy
CI/CD
- Create a PR (feature branch):
.github/workflows/ci-tests.yml- Env setup, Unit test, Integration test, Terraform plan
- Merge PR to
develop:.github/workflows/cd-deploy.yml- Terraform plan, Terraform apply, Docker build & ECR push, Update Lambda config
Notes
- Unfortunately, the
RUN_ID(if set via theENVorARGinDockerfile), disappears during lambda invocation.
We'll set it viaaws lambda update-function-configurationCLI command (refer todeploy_manual.shor.github/workflows/cd-deploy.yml)
Overview (`cohorts/2023/README.md`)
MLOps Zoomcamp 2023 Cohort
- Pre-Course Live Q&A
- Technical FAQ
- Course Playlist: Only 2023 Live videos & homeworks
- Leaderboard
- Deadline calendar
Module 3: Orchestration and ML pipelines
Overview (`cohorts/2024/README.md`)
MLOps Zoomcamp 2024 Cohort
- Pre-Course Live Q&A
- Course Launch video and Slides
- Technical FAQ
- TODO: Course Playlist: Only 2024 Live videos & homeworks
- Course management platform
Module 3: Orchestration and ML pipelines
Overview (`cohorts/2025/README.md`)
MLOps Zoomcamp 2025 Cohort
Module 3: Orchestration and ML pipelines
Overview (`cohorts/self-paced/README.md`)
MLOps Zoomcamp — self-paced
There is no live cohort currently scheduled for this course. The curriculum
at the repository root is fully available for self-paced study: work through
the modules at your own pace, using the code and notebooks in each module
directory.
- Register here to
be notified if a live cohort runs again. - FAQ
No homework or deadlines are tracked for self-paced study.
Overview (`cohorts/2022/03-orchestration/README.md`)
3. Orchestration and ML Pipelines
Note: orchestration.py is a ready final version. The rest of the files were worked on together during the video tutorials.
Note With Prefect version 2.2.1 or later DeploymentSpec's are now just Deployment's.
3.1 Negative engineering and workflow orchestration
3.2 Introduction to Prefect 2.0
3.3 First Prefect flow and basics
3.4 Remote Prefect Orion deployment
3.5 Deployment of Prefect flow
Note: There are several changes to deployment in Prefect 2.3.1 since 2.0b8:
DeploymentSpecin 2.0b8 now becomesDeployment.work_queue_nameis used instead oftagsto submit the deployment to the a specific work queue.- You don't need to create a work queue before using the work queue. A work queue will be created if it doesn't exist.
from prefect.deployments import Deployment
from prefect.orion.schemas.schedules import IntervalSchedule
from datetime import timedelta
deployment = Deployment.build_from_flow(
flow=main,
name="model_training",
schedule=IntervalSchedule(interval=timedelta(minutes=5)),
work_queue_name="ml"
)
deployment.apply()Links:
3.6 MLOps Zoomcamp 3.6 - (Optional) Work queues and agents
3.7 Homework
More information here: TBD
Notes
Did you take notes? Add them here:
- Week 3, Prefect Introduction and S3 Bucket configuration with Prefect by M. Ayoub C.
- Notes from froukje
- Minimalist code notes from Anna V
- Getting Started on Prefect 2.0 + Deploying worfklows for MLflow Staging by Ron Medina (Jupyter Book)
- Quickstart your homework by Zioalex
- Notes from Maxime M
- Week3: Prefect introduction and homework notes by Bhagabat
- Week 3: Orchestration notes by Ayoub.B
- Send a PR, add your notes above this line
Overview (`cohorts/2022/05-monitoring/README.md`)
5. Model Monitoring
5.1 Monitoring for ML-based services
Watch the monitoring introduction
5.2 Setting up the environment
Watch the monitoring environment setup
5.3 Creating a prediction service and simulating traffic
Watch the prediction service and traffic simulation video
5.4 Realtime monitoring walktrough (Prometheus, Evidently, Grafana)
Watch the realtime monitoring walkthrough
5.5 Batch monitoring walktrough (Prefect, MongoDB, Evidently)
Watch the batch monitoring walkthrough
5.6 Homework
More information here: TBD
Notes
Did you take notes? Add them here:
- Week 5 notes by M. Ayoub C.
- week 5: Monitoring notes Ayoub.B
- Send a PR, add your notes above this line
Monitoring example
Prerequisites
You need following tools installed:
dockerdocker-compose(included to Docker Desktop for Mac and Docker Desktop for Windows )
Preparation
Note: all actions expected to be executed in repo folder.
- Create virtual environment and activate it (eg.
python -m venv venv && source ./venv/bin/activate) - Install required packages
pip install -r requirements.txt - Run
python prepare.pyfor downloading datasets
Monitoring Example
Starting services
To start all required services, execute:
docker-compose upIt will start following services:
prometheus- TSDB for metricsgrafana- Visual tool for metricsmongo- MongoDB, for storing raw data, predictions, targets and profile reportsevidently_service- Evindently RT-monitoring service (draft example)prediction_service- main service, which makes predictions
Sending data
To start sending data to service, execute:
python send_data.pyThis script will send every second single row from dataset to prediction service along with creating file target.csv with actual results (so it can be loaded after)
Batch Monitoring Example
After you stop sending data to service, you can run batch monitoring pipeline (using Prefect) by running script:
python prefect_example.pyThis script will:
- load
target.csvto MongoDB - download dataset from MongoDB
- Run Evidently Model Profile and Evidently Report on this data
- Save Profile data back to MongoDB
- Save Report to
evidently_report_example.html
You can look at Prefect steps in Prefect Orion UI
(to start it execute prefect orion start)
Overview (`cohorts/2022/07-project/README.md`)
Course Project
The goal of this project is to apply everything we learned
in this course and build an end-to-end machine learning project.
Remember that to pass the project, you must evaluate 3 peers. If you don't do that, your project can't be considered compelete.
Submitting
Project Cohort #2
Project:
- Form: https://forms.gle/aj8LHkY7PrWG9XzW6
- Deadline: 12 September, 23:00 CEST
Peer reviewing:
- Peer review assignments: link ("project 2" tab)
- Form: https://forms.gle/BeQ2HCohrM3puKf26
- Deadline: 19 September, 23:00 CEST
Project feedback: link ("feedback-02" tab)
Project Cohort #1
Project:
- Form: https://forms.gle/7UmQkK4BBxqdgMDp9
- Deadline: 22 August, 23:00 CEST
Peer reviewing:
- Peer review assignments: link ("project 1" tab)
- Form: https://forms.gle/KaBMoYhmfeEFmiWb7
- Deadline: 29 August, 23:00 CEST
Project feedback: link ("feedback-02" tab)
Evaluation criteria
See here
Misc
To get the hash for your project, use this function to hash your email:
from hashlib import sha1
def compute_hash(email):
return sha1(email.lower().encode('utf-8')).hexdigest()Or use this website.
Overview (`cohorts/2023/07-project/README.md`)
Course Project
The goal of this project is to apply everything we learned
in this course and build an end-to-end machine learning project.
Remember that to pass the project, you must evaluate 3 peers. If you don't do that, your project can't be considered compelete.
Submitting
Project Cohort #1
Project:
- Form: https://forms.gle/mRRoDtqDXBytvsoD9
- Deadline: 31 July, 23:00 CEST
Peer reviewing:
- Peer review assignments: link ("project 1" tab)
- Form: https://forms.gle/MRMHDuFiP6DFShaj7
- Deadline: 10 August, 23:00 CEST
Project feedback: link ("feedback-01" tab)
Project Cohort #2
Project:
- Form: https://forms.gle/o1s3NmYE4UmFSMVD7
- Deadline: 21 August (Monday), 23:00 CEST
Peer reviewing:
- Peer review assignments: link ("project 2" tab)
- Form: https://forms.gle/R4Y58WSxGDWsDBFv7
- Deadline: 29 August (Tuesday), 23:00 CEST
Project feedback: link ("feedback-02" tab)
Evaluation criteria
See here
Misc
To get the hash for your project, use this function to hash your email:
from hashlib import sha1
def compute_hash(email):
return sha1(email.lower().encode('utf-8')).hexdigest()Or use this website.
Overview (`cohorts/2024/03-orchestration/README.md`)
3. Orchestration and ML Pipelines
[3.0 Introduction: ML pipelines and Mage](3.0/README.md)
[3.1 Data preparation: ETL and feature engineering](3.1/README.md)
[3.2 Training: sklearn models and XGBoost](3.2/README.md)
[3.3 Observability: Monitoring and alerting](3.3/README.md)
[3.4 Triggering: Inference and retraining](3.4/README.md)
[3.5 Deploying: Running operations in production](3.5/README.md)
[3.6 Homework](../cohorts/2024/03-orchestration/homework.md).
Quickstart
See the Unit 3.0 for a Quick Start guide
Need help?
- Developer documentation
- AI chat bot
- Live chat with the Mage team directly
Notes
Did you take notes? Add them here:
- Marcus' Notes for Ch3
- Send a PR, add your notes above this line
Notes previous editions
Overview (`cohorts/2025/competition/README.md`)
MLOps Zoomcamp 2025 Competition
Welcome to the MLOps Zoomcamp 2025 Competition!
We're hosting this competition to help you practice everything you learn in the course.
Unlike traditional Kaggle competitions that focus only on model accuracy, this competition emphasizes the complete MLOps lifecycle, from model development to deployment and monitoring.
Quick Links
- Competition Platform: https://youare.bot/
- Register your classifier in the "Register your API" section
- View leaderboards and track your performance
- Detailed Overview (Slides)
- Competition Overview Video
Competition Overview
What You'll Build
Classifier: Build an ML model that detects whether a chat participant is a bot or human
Scoring
Classifiers: Evaluated on both:
- ML metrics: accuracy, ROC, precision, recall, F-score
- Technical metrics: latency, uptime, response rate
Timeline
- Competition period: June 2025-August 2025
- Final submission deadline: September 1st, 2025
- Evaluation: Best consecutive 7-day performance
- Deploy anytime during the competition period
- No need to keep your service running the entire time
Benefits
- Practical MLOps experience in a real-world scenario
- Portfolio-worthy project showcasing end-to-end ML system
- Course points for participation
- $500 of AWS vouchers divided equally among top 10 participants
Implementation Guide
Start with these core components:
- FastAPI/Flask for serving your model
- PostgreSQL for message history (optional)
- MLflow for experiment tracking
- Prometheus/Grafana for monitoring
As you advance, consider adding:
- CI/CD pipeline for automated deployment
- Evidently for model quality monitoring
- Airflow for automated retraining
- Cloud deployment (AWS, Fly.io, etc.)
Getting Started
Example Implementations:
- YouAreBot Quickstart Template: Simple Echo Bot with FastAPI endpoint
- YouAreBot Bot Example: Advanced GPT-based bot (requires OpenAI/DeepSeek API key and additional setup)
- YouAreBot Classifier Example: FastAPI service with PostgreSQL storage and random classifier (baseline for you to improve)
Deployment Options:
- Testing: Use quickstart repo with SSH tunneling
- Production: Deploy to any cloud provider
- AWS (recommended, covered in course)
- Fly.io
- Your preferred cloud platform
Support
For technical questions, contact Misha:
- Telegram: https://t.me/bearcolonel
- Email: [email protected]
Overview (`cohorts/2023/03-orchestration/prefect/README.md`)
3. Orchestration and ML Pipelines
This section of the repo contains Python code to accompany the videos that show how to use Prefect for MLOps. We will create workflows that you can orchestrate and observe.
3.1 Introdution to Workflow Orchestration
3.2 Introduction to Prefect
3.3 Prefect Workflow
3.4 Deploying Your Workflow
3.5 Working with Deployments
3.6 Prefect Cloud (optional)
3.7 Homework
More information here.
Quick setup
Install packages
In a conda environment with Python 3.10.12 or similar, install all package dependencies with
pip install -r requirements.txtStart the Prefect server locally
Create another window and activate your conda environment. Start the Prefect API server locally with
prefect server startAlternative to self-hosted server use Prefect Cloud for added capabilties
Signup and use for free at https://app.prefect.cloud
Authenticate through the terminal with
prefect cloud loginUse your Prefect profile to switch between a self-hosted server and Cloud.
Notes
Did you take notes? Add them here:
- Prefect local deployment using Google Cloud Storage as data storage
- Notes/Blog posts by Sagar Thacker
- Send a PR, add your notes above this line
Notes 2022 Edition
To read the notes from the previous edition, see here
Overview (`cohorts/2024/03-orchestration/3.0/README.md`)
3.0 Introduction: ML pipelines and Mage
3.0.1 ML Pipelines
3.0.2 Running Mage
In Codespaces
On Windows with Docker-Compose
What is MLOps
Operationalizing ML models involves moving them from development to production to drive business value.
Step 1
Preparing the model for deployment involves optimizing performance, ensuring it handles real-world data, and packaging it for integration into existing systems.
Step 2
Deploying the model involves moving it from development to production, making it accessible to users and applications.
Step 3
Once deployed, models must be continuously monitored for accuracy and reliability, and may need retraining on new data and updates to maintain effectiveness.
Step 4
The operationalized model must be integrated into existing workflows, applications, and decision-making processes to drive business impact.
Effective operationalization enables organizations to move beyond experimentation and drive tangible value from ML at scale, powering intelligent applications that personalize the customer experience and creates real business value.
Why we need to operationalize ML
1. Productivity
MLOps fosters collaboration between data scientists, ML engineers, and DevOps teams by providing a unified environment for experiment tracking, feature engineering, model management, and deployment. This breaks down silos and accelerates the entire machine learning lifecycle.
2. Reliability
MLOps ensures high-quality, reliable models in production through clean datasets, proper testing, validation, CI/CD practices, monitoring, and governance.
3. Reproducibility
MLOps enables reproducibility and compliance by versioning datasets, code, and models, providing transparency and auditability to ensure adherence to policies and regulations.
4. Time-to-value
MLOps streamlines the ML lifecycle, enabling organizations to successfully deploy more projects to production and derive tangible business value and ROI from AI/ML investments at scale.
How Mage helps MLOps
1. Data preparation
Mage offers features to build, run, and manage data pipelines for data transformation and integration, including pipeline orchestration, notebook environments, data integrations, and streaming pipelines for real-time data.
2. Training and deployment
Mage helps prepare data, train machine learning models, and deploy them with accessible API endpoints.
3. Standardize complex processes
Mage simplifies MLOps by providing a unified platform for data pipelining, model development, deployment, versioning, CI/CD, and maintenance, allowing developers to focus on model creation while improving efficiency and collaboration.
Example data pipeline: Quick Start
Clone the following respository containing the complete code for this module:
bashgit clone https://github.com/mage-ai/mlops.git cd mlopsLaunch Mage and the database service (PostgreSQL):
bash./scripts/start.shIf don't have bash in your enviroment, modify the following command and run it:
bashPROJECT_NAME=mlops \ MAGE_CODE_PATH=/home/src \ SMTP_EMAIL=$SMTP_EMAIL \ SMTP_PASSWORD=$SMTP_PASSWORD \ docker compose upIt is ok if you get this warning, you can ignore it
The "PYTHONPATH" variable is not set. Defaulting to a blank string.The subproject that contains all the pipelines and code is named
unit_3_observability
Run example pipeline
Open
http://localhost:6789in your browser.In the top left corner of the screen next to the Mage logo and
mlopsproject name,
click the project selector dropdown and choose theunit_0_setupoption.Click on the pipeline named
example_pipeline.Click on the button labeled
Run @once.
Resources
- Code for example data pipeline
- The definitive end-to-end machine learning (ML lifecycle) guide and tutorial for data engineers.
Overview (`cohorts/2024/03-orchestration/3.1/README.md`)
3.1 Data preparation: ETL and feature engineering
Ingestion
3.1.1 Creating a new project
In order to create a new project, firstly, you need to right-click on a folder in Text editor, and choose New Mage project. Secondly, you need to open Settings and click on Register project.
Opening a text editor:
- Go to the command center (At the top)
- Type "text editor"
3.1.2 Data preparation - Ingestion
The project unit_1_data_preparation now has an empty pipeline, and it can be developed further using blocks. The first one we'll create is an ingestion block, which uses Python code to download the parquet files from January to March of the green taxi datasets and concatenate them. Done that, generate a series of graphs and charts useful for data profiling.
- Note: If the time chart isn't displayed, insert the following snippet
df['lpep_pickup_datetime_cleaned'] = df['lpep_pickup_datetime'].astype(np.int64) // 10**9just above thedfs.append(df)line iningest.py
Code:
3.1.3 Utility helper functions
Utility functions are already created in the utils folder. They will be then imported into the transformer block.
Code
2. Data Preparation
Videos
To see the correct histogram, change last two lines of the default code to:
col = 'trip_distance'
x = df_1[df_1[col] <= 20][col]Code
3. Build training sets
Videos
Code
4. Data validations using built-in testing framework
Videos
Code
Code
Resources
Overview (`cohorts/2024/03-orchestration/3.2/README.md`)
3.2 Training: sklearn models and XGBoost
1. Training pipeline for sklearn models
Videos
- GDP training set
- Sklearn training GDP
- Load models
- Utility helper functions for loading models
- Hyperparameter tuning
- Train sklearn model
Code
utils/models/sklearn.pycustom/load_models.pyblock: load sklearn models dynamicallytransformers/hyperparameter_tuning/sklearn.pydata_exporters/sklearn.pyhyperparameters/shared.py
2. Training pipeline for XGBoost model
Videos
Code
utils/models/xgboost.pytransformers/hyperparameter_tuning/xgboost.pydata_exporters/xgboost.pyhyperparameters/shared.py
Code
- Complete code solution
- sklearn training pipeline configuration
- XGBoost training pipeline configuration
Resources
Overview (`cohorts/2024/03-orchestration/3.3/README.md`)
3.3 Observability: Monitoring and alerting
1. Pipeline health monitoring
2. Explainability
Videos
Code
custom/dashboard_data_source.py:
this is used to produce the output needed to generate the SHAP values and chart them.- SHAP values
- SHAP values bar chart
- SHAP values force plot
3. Model performance dashboard
Videos
- Overview dashboard for entire project
- RMSE and MSE using time series chart
- RMSE distribution using a histogram
- Training runs by model using bar chart
- Training runs by model using pie chart
Code
4. Alerting
Videos
Code
Code
- sklearn training pipeline health
- XGBoost explainability dashboard
- Model performance dashboard configuration
Resources
Set up alerts for pipeline run statuses:
Overview (`cohorts/2024/03-orchestration/3.4/README.md`)
3.4 Triggering: Inference and retraining
1. Retraining pipeline
Videos
Code
detect_new_data.pycustom/retrain/sklearn.pyblock: trigger training pipeline for sklearn modelscustom/retrain/xgboost.pyblock: trigger training pipeline for XGBoost model
2. Inference pipeline
Videos
- Make a prediction
- Build pipeline
- Model inference playground part 1
- Model inference playground part 2
- Get prediction via API
Code
Code
- Retraining pipeline
metadata.yaml - Inference pipeline
metadata.yaml - Playground configuration settings
Resources
Overview (`cohorts/2024/03-orchestration/3.5/README.md`)
3.5 Deploying: Running operations in production
1. Permissions
Videos
Code
2. Deploy
Videos
Code
custom/infrastructure_setup.pyblockcustom/deploy.pyblockcustom/teardown_deployed_resources.pyblock
3. Continuous deployment and integration
Videos
Code
Code
Resources
AWS IAM policy permissions
02 Experiment Tracking Docs Mlflow On Aws (`02-experiment-tracking/docs/mlflow_on_aws.md`)
Basic AWS setup
This tutorials explains how to configure a remote tracking server on AWS. We will use an RDS database as the backend store and an s3 bucket as the artifact store.
First, you need to create an AWS account. If you open a new account, AWS allows you to use some of their products for free but take into account that you may be charged for using the AWS services. More information here and here.
Launch a new EC2 instance.
For this, you can select one of the instance types that are free tier eligible. For example, we will select an Amazon Linux OS (Amazon Linux 2 AMI (HVM) - Kernel 5.10, SSD Volume Type) and a t2.micro instance type, which are free tier eligible.
You'll also need to create a new key pair so later you can connect to the new instance using SSH. Click on "Create new key pair" and complete the details like in the image below:
Select the new key pair and then click on "Launch Instance".
Finally, you have to edit the security group so the EC2 instance accepts SSH (port 22) and HTTP connections (port 5000):
- Create an s3 bucket to be used as the artifact store.
Go to s3 and click on "Create bucket". Fill in the bucket name as in the image below and let all the other configurations with their default values.
Note: s3 bucket names must be unique across all AWS account in all the AWS Regions within a partition, that means that once a bucket is created, the name of that bucket cannot be used by another AWS account within the same region. If you get an error saying that the bucket name was already taken you can fix it easily by just changing the name to something like mlflow-artifacts-remote-2 or another name.
- Create a new PostgreSQL database to be used as the backend store
Go to the RDS Console and click on "Create database". Make sure to select "PostgreSQL" engine type and the "Free tier" template.
Select a name for your DB instance, set the master username as "mlflow" and tick the option "Auto generate a password" so Amazon RDS generate a password automatically.
Finally, on the section "Additional configuration" specify a database name so RDS automatically creates an initial database for you.
After clicking on "launch database" you will be able to check the newly generated password, but take into account that the automatically generated password will be shown only once!
The password value is intentionally redacted in this documentation image. In the AWS console, copy the generated password immediately and keep it private.
You can use the default values for all the other configurations.
Take note of the following information:
- master username
- password
- initial database name
- endpoint
Once the DB instance is created, go to the RDS console, select the new db and under "Connectivity & security" select the VPC security group. Modify the security group by adding a new inbound rule that allows postgreSQL connections on the port 5432 from the security group of the EC2 instance. This way, the server will be able to connect to the postgres database.
Note that the database name might be set to "postgres" by default.
- Connect to the EC2 instance and launch the tracking server.
Go to the EC2 Console and find the instance launched on the step 2. Click on "Connect" and then follow the steps described in the tab "SSH".
Run the following commands to install the dependencies, configure the environment and launch the server:
sudo yum updatepip3 install mlflow boto3 psycopg2-binaryaws configure# you'll need to input your AWS credentials heremlflow server -h 0.0.0.0 -p 5000 --backend-store-uri postgresql://DB_USER:DB_PASSWORD@DB_ENDPOINT:5432/DB_NAME --default-artifact-root s3://S3_BUCKET_NAME
Note: before launching the server, check that the instance can access the s3 bucket created in the step number 3. To do that, just run this command from the EC2 instance: aws s3 ls. You should see the bucket listed in the result.
- Access the remote tracking server from your local machine.
Open a new tab on your web browser and go to this address: http://<EC2_PUBLIC_DNS>:5000 (you can find the instance's public DNS by checking the details of your instance in the EC2 Console).
06 Best Practices Docs Extra Material (`06-best-practices/docs/extra-material.md`)
Extra Material
Concepts of IaC and Terraform
Summary
Infrastructure-as-Code (IaC):
- Define and automate operations around you application's infrastructure.
- Can use version control to track changes made to infrastructure
- Easy to replicate the configuration across different environments such as development, staging, and production.
Reference Material
We have already covered Terraform concepts at a deeper level in the Data Engineering Zoomcamp, and will not be repeating some of those basic concepts again. You can find the content here for your reference:
Notes:
Videos:
For an introduction to Terraform and IaC concepts, please refer to this video
(from the DE Zoomcamp), especially the sections in the time-codes:- 00:00 Introduction
- 00:35 What is Terraform?
- 01:10 What is IaC?
- 01:43 Advantages of IaC
- 14:48 Installing Terraform
- 02:28 More on Installing Terraform
For a quickstart tutorial, and understanding the main components of a basic Terraform script, please refer to this video
(from the DE Zoomcamp). Please note that this example uses GCP as a cloud provider, while for MLOps Zoomcamp we are using AWS.- 00:00 Introduction
- 00:20 .terraform-version
- 01:04 main.tf
- 01:23 terraform declaration
- 03:25 provider plugins
- 04:00 resource example - google_storage_bucket
- 05:42 provider credentials
- 06:34 variables.tf
- 10:54 overview of terraform commands
- 13:35 running terraform commands
- 18:08 recap
In case you're using GCP instead of AWS, following is some setup material:
References
- Terraform with AWS: Getting Started and AWS provider library
- Terraform Modules: Define and Call
Concepts of CI/CD and GitHub Actions
Summary
- Using GitHub Actions to create workflows to automatically test a pull request,
build and push a Docker image, and deploy the updated lambda service to production. - Creating specific YAML files in GitHub repo, to automatically kick off a series of automation steps.
- Motivation on automating your further tasks with GitHub Actions:
- Orchestrating a continuous training pipeline (CT) to retrain your model and generate updated model artifacts in production
- Integrating the model registry (MLflow, DVC etc.) to fetch the latest model version or experiment ID
- and many more...
Reference Material
--- METRICS ---
- Files Extracted: 34
- Estimated Token Budget: ~25993 tokens
- Canonical Reference: https://codewiki.google/github.com/DataTalksClub/mlops-zoomcamp