Back to Blog
MLOps March 22, 2025 11 min read

MLOps Pipeline from Scratch: CI/CD for ML Models

How to build a complete MLOps pipeline — data versioning with DVC, experiment tracking with MLflow, model registry, automated retraining, and deployment gates.

The Full MLOps Stack

Git + DVC (code + data versioning)
      ↓
GitHub Actions (CI: tests, linting)
      ↓
MLflow (experiment tracking)
      ↓
MLflow Model Registry (staging → production)
      ↓
FastAPI + Docker (serving)
      ↓
Prometheus + Grafana (monitoring)

DVC Data Versioning

dvc init
dvc add data/train.csv
dvc push  # to S3/GCS
git add data/train.csv.dvc
git commit -m "add training data v2"

MLflow Experiment Tracking

import mlflow

with mlflow.start_run():
    mlflow.log_params(params)
    mlflow.log_metrics({'auc': auc, 'f1': f1})
    mlflow.sklearn.log_model(model, 'model')

Automated Retraining Gate

If production AUC drops >2% → trigger retraining pipeline automatically.

MLOpsDVCMLflowCI/CDDocker
O

Ossama Elhakki

AI Engineer & ML Systems Builder — Morocco