A demo continuous delivery pipeline for machine learning models.
Here's the sentiment analysis model which we've deployed using this pipeline: https://pycon-ml-demo.herokuapp.com/
- Clone repo:
git clone https://www.github.com/davified/ml-ci-cd-demo - Setup dev environment:
bin/setup.sh - To activate virtual environment:
source activate ml-ci-cd-demo(To deactivate virtual environment:source deactivate) - Commands that you can run locally:
jupyter notebook(start jupyter notebook for development)bin/run_unit_tests.sh scikit-nlp-modelbin/get_data.sh scikit-nlp-modelbin/train.sh scikit-nlp-modelbin/evaluate.sh scikit-nlp-modelbin/smoke_test.sh MODEL_VERSION(e.g.bin/smoke_test.sh v2)
- Commands that are meant to be run by CI
bin/deploy_to_staging.shbin/deploy_to_prod.shbin/upload_artifact.sh
All models are deployed to GCP ML Engine. As training and deployment are time-consuming steps which we may not want to run with every commit, we've made training and deployment manual steps in our CI pipelines.
As manual deployments is not a supported feature in TravisCI, we created a workaround to simulate manual deployments - by committing and push to 2 branches: deploy-to-staging and deploy-to-prod. To deploy to staging:
- merge all your changes onto the
deploy-to-stagingbranch (by runninggit checkout deploy-to-staging && git merge master) - push your changes (
git push origin deploy-to-staging, or simplygit push)
- generate credentials for GCP project here -> select 'Service Account Key' -> enter details, select JSON and download it, and move/rename it to
./client_secret.json(i.e.ml-ci-cd-demo/client_secret.json)
- Sign up/sign in to your Google Cloud Platform account
- Create a project on the GCP console, and replace
PROJECT_IDinbin/common.shwith your project name - Generate
client_secret.jsoncredentials (see instructions in previous section) - Encrypt client_secret.json:
travis encrypt-file ./client_secret.json --add - Click on these links and enable the following APIs:
- Tasks board
- CI
- GCP project dashboard
- Demo client app
- Server app