How fbarulli/mlflow works
Project Type and Purpose
• This is a machine-learning project built around MLflow.
• It trains two models (RandomForest, LogisticRegression) on wine data (wine_work.py, df.ipynb) and tracks experiments/artifacts with MLflow.
• It’s containerized: one container runs the MLflow tracking server, another hosts a prediction service (“app”), both orchestrated via docker-compose.
File Structure
Top-level artifacts:
• Dockerfile.server – builds the MLflow Tracking Server container
• Dockerfile.app – builds the Model Serving App container
• docker-compose.yml – orchestrates both containers + volume mounts
• MLproject – MLflow project definition for reproducible runs
• run.sh – script to launch MLflow runs (wine_work.py) against the tracking server
• mlruns/ – the local artifact store (metrics, model.pkl, environment specs)
• outputs/ – prediction CSVs generated by the training jobs
• wine_work.py & df.ipynb – data processing & model training code
• requirements.txt – Python dependencies
Major Components
A. Developer Workstation
• Codebase: wine_work.py, df.ipynb, MLproject, run.sh, requirements.txt
• Invokes “run.sh” which runs mlflow run . pointing at the MLflow server
B. Docker Compose Orchestrator
• Defines and connects two services: “mlflow-server” and “mlflow-app”
• Mounts host directories (mlruns/, outputs/) into the containers
C. MLflow Tracking Server Container
• Built from Dockerfile.server
• Exposes:
• REST API for logging experiments (port 5000)
• Web UI for viewing runs/artifacts
• Persists data to a volume (host’s mlruns/ directory)
D. Model Serving App Container
• Built from Dockerfile.app
• Loads the trained model artifact (model.pkl) from the MLflow server or local mount
• Exposes a REST endpoint for inference requests
• Writes prediction outputs back to outputs/ or returns them in HTTP responses
E. Artifact Store (mlruns Volume)
• Stores models, metrics, artifacts under /mlruns inside the server container
• Shared read-only into the app container for loading models
F. Outputs Volume
• Receives CSVs of predictions produced by training jobs or by the app
Interactions & Data Flow
1. Developer runs ./run.sh → MLflow client on workstation
2. MLflow client → (HTTP) → Tracking Server API
• Sends training parameters, logs metrics, stores artifacts under mlruns/
3. Tracking Server writes to mlruns/ volume
4. Developer inspects runs via Tracking Server Web UI
5. App Container fetches model artifact (via MLflow API or direct volume mount)
6. Client (or testing script) → (HTTP) → App Container inference endpoint
7. App returns predictions (and/or writes to outputs/ volume)
Highlighted Architectural Patterns & Principles
• Micro-service separation: one service for experiment tracking (stateful), one for model serving (stateless)
• Reproducibility: MLproject file + conda/python_env yaml ensures consistent environments
• Volume mounting for persistent artifact storage & sharing between containers
• Clear separation of training (batch/script) vs serving (API)