-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.yml
159 lines (156 loc) · 4.62 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
version: 2
defaults: &defaults
docker:
- image: circleci/python:3.7.2
working_directory: ~/project
prepare_venv: &prepare_venv
run:
name: Create venv
command: |
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
fetch_data: &fetch_data
run:
name: Set script permissions and fetch data
command: |
source venv/bin/activate
chmod +x ./scripts/fetch_kaggle_dataset.sh
./scripts/fetch_kaggle_dataset.sh
jobs:
test_regression_model:
<<: *defaults
steps:
- checkout
- *prepare_venv
- run:
name: Install requirements
command: |
. venv/bin/activate
pip install -r packages/regression_model/requirements.txt
- *fetch_data
- run:
name: Train model
command: |
. venv/bin/activate
PYTHONPATH=./packages/regression_model python3 packages/regression_model/regression_model/train_pipeline.py
- run:
name: Run tests
command: |
. venv/bin/activate
py.test -vv packages/regression_model/tests
test_ml_api:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- py-deps-{{ checksum "packages/ml_api/requirements.txt" }}
- run:
name: Runnning tests
command: |
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install -r packages/ml_api/requirements.txt
py.test -vv packages/ml_api/tests -m "not differential"
- save_cache:
key: py-deps-{{ checksum "packages/ml_api/requirements.txt" }}
paths:
- "/venv"
train_and_upload_regression_model:
<<: *defaults
steps:
- checkout
- *prepare_venv
- run:
name: Install requirements
command: |
. venv/bin/activate
pip install -r packages/regression_model/requirements.txt
- *fetch_data
- run:
name: Train model
command: |
. venv/bin/activate
PYTHONPATH=./packages/regression_model python3 packages/regression_model/regression_model/train_pipeline.py
- run:
name: Publish model to Gemfury
command: |
. venv/bin/activate
chmod +x ./scripts/publish_model.sh
./scripts/publish_model.sh ./packages/regression_model/
test_model_differentials:
<<: *defaults
steps:
- checkout
- *prepare_venv
- run:
name: Capturing previous model predictions
command: |
. venv/bin/activate
pip install -r packages/ml_api/diff_test_requirements.txt
PYTHONPATH=./packages/ml_api python3 packages/ml_api/tests/capture_model_predictions.py
- run:
name: Running differential tests
command: |
. venv/bin/activate
pip install -r packages/ml_api/requirements.txt
py.test -vv packages/ml_api/tests -m differential
deploy_to_heroku:
<<: *defaults
steps:
- checkout
- run:
name: Deploy to Heroku
command: |
git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
build_and_push_to_heroku_docker:
<<: *defaults
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- run: docker login --username=$HEROKU_EMAIL --password=$HEROKU_API_KEY registry.heroku.com
- run:
name: Setup Heroku CLI
command: |
wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
- run:
name: Build and Push Image
command: |
make build-ml-api-heroku push-ml-api-heroku
- run:
name: Release to Heroku
command: |
heroku container:release web --app $HEROKU_APP_NAME
workflows:
version: 2
test-all:
jobs:
- test_regression_model
- test_ml_api
- test_model_differentials
- train_and_upload_regression_model:
requires:
- test_regression_model
- test_ml_api
- test_model_differentials
filters:
branches:
only:
- master
- deploy_to_heroku:
requires:
- train_and_upload_regression_model
filters:
branches:
only:
- master
# - build_and_push_to_heroku_docker:
# requires:
# - train_and_upload_regression_model
# filters:
# branches:
# only:
# - master