A comprehensive, modular tutorial demonstrating all four core components of MLflow:
- MLflow Tracking - Experiment tracking and logging
- MLflow Projects - Reproducible runs
- MLflow Models - Model packaging and deployment
- MLflow Model Registry - Model versioning and lifecycle management
mlflow_complete_tutorial/
├── README.md # This file
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore file
├── MLproject # MLflow project configuration
├── utils.py # Utility functions
├── data/ # Data directory (auto-generated)
├── 1_tracking.py # Component 1: MLflow Tracking
├── 2_projects.py # Component 2: MLflow Projects
├── 3_models.py # Component 3: MLflow Models
├── 4_model_registry.py # Component 4: Model Registry
└── run_all.py # Run all tutorials in sequence
pip install -r requirements.txtOpen a separate terminal and run:
mlflow uiThen visit http://localhost:5000 to view the MLflow UI.
python run_all.pyRun each component separately to understand them better:
# Component 1: MLflow Tracking
python 1_tracking.py
# Component 2: MLflow Projects
python 2_projects.py
# Component 3: MLflow Models
python 3_models.py
# Component 4: Model Registry
python 4_model_registry.pyDemonstrates:
- Creating and managing experiments
- Logging parameters, metrics, and tags
- Logging artifacts (files, plots, models)
- Nested runs for hyperparameter tuning
- Comparing runs
Demonstrates:
- Project structure with MLproject file
- Parameterized runs
- Reproducible execution environments
- Running projects with different parameters
Demonstrates:
- Saving models in different flavors (sklearn, pytorch, etc.)
- Loading and using saved models
- Model signatures and input examples
- Serving models locally
- Batch and real-time inference
Demonstrates:
- Registering models
- Model versioning
- Stage transitions (Staging, Production, Archived)
- Model annotations and descriptions
- Loading models from registry
- Backend Store: Stores experiment and run metadata
- Artifact Store: Stores artifacts like models, plots, data files
- Logical grouping of related runs
- Each run belongs to an experiment
- Individual execution of ML code
- Records parameters, metrics, artifacts, and metadata
- Packaged ML models with metadata
- Supports multiple flavors for different frameworks
- Centralized model store
- Version control for models
- Lifecycle stage management
- Use Experiments to organize related runs
- Log Everything - parameters, metrics, artifacts
- Use Tags for better organization and filtering
- Version Your Models through the Model Registry
- Document Models with descriptions and tags
- Use Model Stages to manage deployment lifecycle
- Ensure MLflow is installed:
pip install mlflow - Check if port 5000 is available
- Try a different port:
mlflow ui --port 5001
- Check write permissions in the working directory
- Ensure
mlruns/andmlartifacts/directories are writable
- Ensure you've registered the model first
- Check the tracking URI is correctly configured
- Verify the model name is correct
This tutorial is provided for educational purposes.