An industrialized ML pipeline that transforms a ML model into a scalable, tested, and containerized microservice.
- ⚡ Quick Start
- 🎯 Project Purpose
- 📁 Project Structure
- 🛠️ Technical Documentation
- 🔄 CI/CD & Quality Control
- 🚀 Future & Tech Stack
If you have Docker installed, you can spin up the entire ecosystem with a single command:
docker compose -f config/docker-compose.yml up --build- API:
http://localhost:5000 - UI:
http://localhost:8501
This project demonstrates production-ready MLOps practices rather than focusing solely on achieving state-of-the-art model performance. The Wisconsin Breast Cancer dataset is used as a proof-of-concept to validate the MLOps infrastructure.
The goal is to showcase best practices in:
- Reproducible ML Pipelines: Using scikit-learn pipelines for consistent preprocessing and inference
- API Design: Building robust REST APIs with proper validation and error handling
- Containerization: Multi-service architecture with Docker Compose
- CI/CD: Automated quality gates, testing, and deployment pipelines
- Code Quality: Type checking, linting, and comprehensive testing
The real question this project answers:
"How do I ensure my ML model works the same way in production as it does in development?"
This project solves this through container immutability and environment parity.
production-ready-mlops-workflow/
├── .github/workflows/ # 🔄 CI/CD: Quality gates & automated deployment
├── config/ # 🐳 Docker: Multi-container orchestration
├── data/ # 📊 Dataset storage (raw & processed)
├── models/ # 🧠 Trained model artifacts (joblib)
├── notebooks/ # 📓 EDA and experimentation
├── reports/ # 📈 Generated metrics and figures
├── src/ # 🛠️ Source code
│ ├── app.py # 🌐 Inference API (Flask)
│ ├── schemas.py # ✅ Data validation (Pydantic)
│ └── model/ # 🚂 Training and inference logic
├── tests/ # 🧪 Unit & Integration test suite
└── pyproject.toml # 📦 Dependency management (uv)
- Python 3.12+
- Docker and Docker Compose (for containerized deployment)
uv(recommended) orpipfor dependency management
uv is a fast Python package installer written in Rust, offering faster dependency resolution and installation.
-
Clone the repository:
git clone https://github.com/anibalrojosan/production-ready-mlops-workflow cd production-ready-mlops-workflow -
Install
uvglobally (if needed):# On macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh # Or via pip: pip install uv
-
Install dependencies:
uv sync --all-groups
-
Activate the virtual env (optional):
source .venv/bin/activateNote: you can run commands using
uv runif you don't want to activate the virtual env.
Using pip (Alternative)
-
Create and activate virtual environment:
python -m venv .venv # On Windows: .\.venv\Scripts\Activate.ps1 # On Linux/macOS: source .venv/bin/activate
-
Upgrade pip:
pip install --upgrade pip
-
Install dependencies:
Option A: using the requirements.txt (recommended for production).
pip install -r requirements.txt
Option B: using the pyproject.toml (recommended for development).
pip install .
The project includes comprehensive tests with a coverage requirement of 80%+.
Run all tests:
uv run pytestRun with verbose output:
uv run pytest -vRun with coverage report:
uv run pytest --cov=src --cov-report=term-missingTrain the ML pipeline and save the model artifact:
uv run python -m src.model.model_trainingThis will:
- Load and preprocess the data
- Train a Random Forest classifier within a scikit-learn pipeline
- Evaluate the pipeline
- Save the complete trained pipeline to
models/model.joblib
Note: The model must be trained before running the API.
Start the Flask API locally:
uv run python -m src.appThe API will be accessible at http://127.0.0.1:5000/
The API exposes a POST /predict endpoint that accepts features as JSON and returns the prediction with probabilities. It also includes a GET / health check endpoint to verify service and model status.
For full validation details and data structures, refer to the Pydantic schemas in src/schemas.py.
Example using test scripts:
- Linux/macOS:
./tests/integration/bash_test.sh - Windows PowerShell:
.\tests\integration\powershell_test.ps1
The Streamlit application provides an interactive web interface for making predictions:
streamlit run src/streamlit_app.pyEnsure the Flask API is running first. The UI will open at http://localhost:8501.
The project uses Docker Compose to orchestrate both the Flask API and Streamlit UI services.
docker compose -f config/docker-compose.yml up --build -dThis will:
- Build optimized images using multi-stage Docker builds
- Start both API and Streamlit services
- Make API available at
http://localhost:5000/ - Make Streamlit UI available at
http://localhost:8501/
docker compose -f config/docker-compose.yml downThe project implements a continuous integration pipeline that acts as a quality filter (Quality Gates):
- Static Analysis:
rufffor linting andmypyfor strict typing. - Automated Testing:
pytestwith a minimum coverage requirement of 80%. - Container Security: Multi-stage Docker builds for lightweight and secure images.
- Integration Tests: Endpoint validation in isolated containers before deployment.
The workflow defined in .github/workflows/main.yml includes:
- Linting:
rufffor code style and quality - Type Checking:
mypyfor static type analysis - Testing:
pytestwith coverage reporting - Coverage Requirement: 80% minimum (pipeline fails if below)
- Train Model: Train and save model artifact
- Build Docker Images: Create optimized container images
- Push to Docker Hub: Store images in registry
- Integration Testing: Test services in isolated containers
- Health Checks: Verify API and UI endpoints
- Cleanup: Remove test containers
This ensures that only tested and validated code reaches production.
🔮 Future Improvements
Potential enhancements to further strengthen the MLOps workflow:
- Model Versioning: Implement MLFlow for experiment tracking and model registry.
- Monitoring: Add model performance monitoring and drift detection.
- A/B Testing: Framework for comparing model versions in production.
- Feature Store: Centralized feature management for multiple models.
- Automated Retraining: Scheduled retraining based on data drift or performance degradation.
📚 Technologies Used
- ML Stack:
scikit-learn(Pipeline & Models),pandas,joblib. - Backend & UI:
Flask(Inference API),Streamlit(Interactive Dashboard). - Modern Tooling:
uv(Package Manager),ruff(Linter),mypy(Type Checking),pydantic(Validation). - Testing:
pytest,pytest-mock,pytest-cov. - Infrastructure:
Docker,Docker Compose,GitHub Actions.
This project was developed with ❤️ by Anibal Rojo as a proof of concept for a real-world MLOps pipeline.
Remember: The value of this project is in the engineering practices, not the model metrics. These practices ensure your ML models work reliably in production, regardless of the problem domain or dataset complexity.