Skip to main content

Upgrade

Pre-Upgrade Checklist

  • Backup database and artifacts

  • Test upgrade in staging environment

  • Schedule maintenance window

  • Notify ML teams

  • Prepare rollback plan

Upgrade Process

bash
#!/bin/bash
# upgrade_mlflow.sh
# Stop MLflow service
systemctl stop mlflow
# Backup current installation
cp -r /opt/mlflow /opt/mlflow_backup_$(date +%Y%m%d)
# Backup database
pg_dump -U mlflow_user mlflow_db > /backup/mlflow_pre_upgrade_$(date +%Y%m%d).sql
# Upgrade MLflow
source /opt/mlflow/mlflow-env/bin/activate
pip install --upgrade mlflow==3.0.1
# Run database migrations
mlflow db upgrade postgresql://mlflow_user:password@localhost:5432/mlflow_db
# Update configuration if needed
# (Review changelog for configuration changes)
# Start service
systemctl start mlflow
# Verify upgrade
mlflow --version
curl -f http://localhost:5000/health

Post-Upgrade Validation

bash


#!/bin/bash
# validate_upgrade.sh
# Test basic functionality
python3 << EOF
import mlflow
from mlflow.tracking import MlflowClient
# Test client connection
client = MlflowClient()
experiments = client.list_experiments()
print(f"Found {len(experiments)} experiments")
# Test experiment creation
experiment_id = mlflow.create_experiment("upgrade-test")
print(f"Created test experiment: {experiment_id}")
# Test run creation
with mlflow.start_run():
mlflow.log_param("test_param", "value")
mlflow.log_metric("test_metric", 1.0)
print("Successfully logged test run")
# Cleanup
mlflow.delete_experiment(experiment_id)
print("Upgrade validation completed successfully")
EOF

Rollback Procedure

bash


#!/bin/bash
# rollback_mlflow.sh
# Stop current version
systemctl stop mlflow
# Restore previous version
rm -rf /opt/mlflow
mv /opt/mlflow_backup_$(date +%Y%m%d) /opt/mlflow
# Restore database
psql -U mlflow_user -d mlflow_db -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
psql -U mlflow_user -d mlflow_db < /backup/mlflow_pre_upgrade_$(date +%Y%m%d).sql
# Start service
systemctl start mlflow
# Verify rollback
curl -f http://localhost:5000/health

Additional Configuration Examples

Authentication Setup


python

# auth_config.py
import mlflow
from mlflow.server.auth import create_default_admin_user
# Create admin user
create_default_admin_user()
# Configure authentication
mlflow.server.auth.create_user("data_scientist", "password123")
mlflow.server.auth.create_permission("data_scientist", "EDIT", "experiment", "production")

Model Serving Configuration


bash

# Serve model
mlflow models serve -m "models:/production-model/1" -p 5001 --no-conda
# Deploy to SageMaker
mlflow sagemaker deploy -m "models:/production-model/1" -a "mlflow-model" -e "ml.m5.lar