-
Notifications
You must be signed in to change notification settings - Fork 12
165 lines (141 loc) Β· 5.88 KB
/
deployment.yml
File metadata and controls
165 lines (141 loc) Β· 5.88 KB
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
160
161
162
163
164
165
name: Deployment workflow
on:
push:
# The following paths specify which files trigger the workflow. We only aim for these because this repo has many more examples.
paths:
- 'deployment/train.py'
- 'deployment/Giskard_test.py'
- '.github/workflows/deployment.yml'
- 'deployment/data.csv'
jobs:
Training:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: checkout repo content
uses: actions/checkout@v2 # checkout the repository content to github runner
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.7.15' # install the python version needed
- uses: syphar/restore-virtualenv@v1
id: cache-virtualenv
with:
requirement_files: deployment/requirements.txt # this is optional
- uses: syphar/restore-pip-download-cache@v1
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
# the package installation will only be executed when the
# requirements-files have changed.
- run: pip install -r requirements.txt
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
working-directory: deployment
- name: execute train script # run sj-gobierno.py to get the latest data
env:
EMAIL_ADDRESS: ${{ secrets.EMAIL_ADDRESS }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
EMAIL_RECIPIENT: ${{ secrets.EMAIL_RECIPIENT }}
GSK_TOKEN: ${{ secrets.GSK_TOKEN }}
GSK_URL: ${{ secrets.GSK_URL }}
GSK_PROJECT_KEY: "credit_scoring_deployment"
GSK_PROJECT_NAME: "German Credit Scoring"
GSK_PROJECT_DESCRIPTION: "Project to predict if user will default"
run: |
python train.py #echo "##[set-output name=model_name;]$(python train.py)"
tar -czvf trained_model.tar.gz trained_model --remove-files
id: train_output
working-directory: deployment
- uses: actions/upload-artifact@v3
with:
name: trained_model-artifact
path: deployment/trained_model.tar.gz
Giskard_Tests:
needs: Training
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: checkout repo content
uses: actions/checkout@v2 # checkout the repository content to github runner
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.7.15' # install the python version needed
- uses: syphar/restore-virtualenv@v1
id: cache-virtualenv
with:
requirement_files: deployment/requirements.txt # this is optional
- uses: syphar/restore-pip-download-cache@v1
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
# the package installation will only be executed when the
# requirements-files have changed.
- run: pip install -r requirements.txt
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
working-directory: deployment
- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: trained_model-artifact
- name: execute test script # run sj-gobierno.py to get the latest data
env:
EMAIL_ADDRESS: ${{ secrets.EMAIL_ADDRESS }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
EMAIL_RECIPIENT: ${{ secrets.EMAIL_RECIPIENT }}
GSK_TOKEN: ${{ secrets.GSK_TOKEN }}
GSK_URL: ${{ secrets.GSK_URL }}
GSK_PROJECT_KEY: "credit_scoring_deployment"
GSK_PROJECT_NAME: "German Credit Scoring"
GSK_PROJECT_DESCRIPTION: "Project to predict if user will default"
run: |
mv ../trained_model.tar.gz .
tar -xzvf trained_model.tar.gz
python Giskard_test.py #echo "##[set-output name=giskard_status;]$(python Giskard_test.py)"
mv trained_model verified_model
tar -czvf verified_model.tar.gz verified_model --remove-files
id: test_output
working-directory: deployment
- uses: actions/upload-artifact@v3
with:
name: verified_model-artifact
path: deployment/verified_model.tar.gz
Deployment:
needs: Giskard_Tests
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v2 # checkout the repository content to github runner
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: verified_model-artifact
- name: commit files
run: |
mv ../verified_model.tar.gz .
mkdir -p old_deployed_models
[ -d deployed_model ] && mv deployed_model/* old_deployed_models/.
[ -d deployed_model ] && rm -r deployed_model
rmdir --ignore-fail-on-non-empty old_deployed_models
tar -xzvf verified_model.tar.gz
mv verified_model deployed_model
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch
git checkout ${{ steps.extract_branch.outputs.branch }}
git add -A
git commit -m "model is deployed" -a
working-directory: deployment
- name: push changes
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.extract_branch.outputs.branch }}
force: 'true'