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-model
bin/get_data.sh scikit-nlp-model
bin/train.sh scikit-nlp-model
bin/evaluate.sh scikit-nlp-model
bin/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.sh
bin/deploy_to_prod.sh
bin/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-staging
branch (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_ID
inbin/common.sh
with your project name - Generate
client_secret.json
credentials (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