This project is a Django application for continuous integration of a machine learning workflow. It uses the wine quality dataset as the sample model target, Celery for asynchronous training jobs, and GitHub Actions to test the Django app and retrain the model whenever application code, training code, dependencies, or datasets change.
mysite/- Django project settings, URLs, WSGI, and Celery application setup.blog/- Existing educational UI pages for the CI/ML introduction.ml_pipeline/- ML workflow app with training run models, Celery tasks, training services, tests, views, and templates.train.py- Command-line entry point used by CI to train the model.wine_quality.csv- Sample dataset used by the model training workflow..github/workflows/ci.yml- GitHub Actions pipeline for Django and model tests.
Install dependencies:
pip install -r requirements.txtRun migrations:
python manage.py migrateStart Django:
python manage.py runserverOpen the training UI at:
http://127.0.0.1:8000/ml/
Celery uses RabbitMQ by default:
celery -A mysite worker --loglevel=infoThe broker can be changed with:
CELERY_BROKER_URL=amqp://guest:guest@localhost:5672//For local development without manual setup, run the full stack:
docker compose up --buildThis starts Django, a Celery worker, and RabbitMQ.
Run the model training workflow directly:
python train.py --dataset wine_quality.csv --output-dir artifacts/localThe command writes:
metrics.txtfeature_importance.pngresiduals.png
The Django app stores queued training runs in ml_pipeline.TrainingRun,
including status, Git SHA, metrics, errors, and artifact paths.
GitHub Actions runs on pushes and pull requests to main when relevant files
change:
- Python source files
requirements.txtwine_quality.csv- files under
data/ordatasets/ - the CI workflow itself
The CI pipeline runs:
python manage.py check
python manage.py test
python train.py --dataset wine_quality.csv --output-dir artifacts/ciModel metrics and generated plots are uploaded as workflow artifacts.