Skip to content

Commit 71665da

Browse files
authored
Merge pull request #5 from MLOPsStudyGroup/scripts_master
Scripts master
2 parents 92fdeee + 99787a8 commit 71665da

File tree

6 files changed

+73
-2
lines changed

6 files changed

+73
-2
lines changed
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: model-deploy-on-release
2+
on:
3+
release:
4+
types:
5+
- 'published'
6+
7+
jobs:
8+
run:
9+
runs-on: [ubuntu-latest]
10+
container: docker://dvcorg/cml-py3:latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: 'Deploy/Update on new release'
14+
shell: bash
15+
16+
env:
17+
repo_token: ${{ secrets.GITHUB_TOKEN }}
18+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
19+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
20+
CRED_SECRET: ${{ secrets.IBM_CREDENTIALS_PASS }}
21+
22+
run: |
23+
# Install requirements
24+
pip install -r requirements.txt
25+
26+
# Pull data & run-cache from S3 and reproduce pipeline
27+
dvc pull --run-cache
28+
dvc repro
29+
30+
# Decrypt credentials file
31+
gpg --quiet --batch --yes --decrypt --passphrase="$CRED_SECRET" --output credentials.yaml credentials.yaml.gpg
32+
33+
# Check if there is a deployment already, if positive update it, otherwise deploys it for the first time
34+
./src/scripts/Scripts/git_release_pipeline.sh
35+
36+

credentials.yaml.gpg

250 Bytes
Binary file not shown.

metadata.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
author: guipleite
22
datetime_creted: 29/03/2021_13:46:23:802394723
3-
deployment_uid: 59562979-4bb8-4cc4-85f0-fb7a280b8b3c
3+
deployment_uid: 9e70e6bf-49d9-418c-8c7a-cf7c876e9fc9
44
model_type: scikit-learn_0.23
5-
model_uid: 3d5e76dc-a4a3-43a9-ab54-debbdbdc8673
5+
model_uid: 12439c9c-4999-463d-8c66-57e4927caf70
66
project_name: Rain_aus
77
project_version: v0.3

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ seaborn
44
matplotlib
55
joblib
66
numpy
7+
ibm_watson_machine_learning
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import os
2+
import sys
3+
import yaml
4+
5+
"""
6+
Usage:
7+
python3 model_deploy_pipeline.py ./pickle_model ../path/to/project/ ../credentials.yaml
8+
9+
"""
10+
11+
PROJ_PATH = os.path.abspath(sys.argv[1])
12+
META_PATH = PROJ_PATH + "/metadata.yaml"
13+
14+
with open(META_PATH) as stream:
15+
try:
16+
metadata = yaml.safe_load(stream)
17+
except yaml.YAMLError as exc:
18+
print(exc)
19+
20+
if "deployment_uid" in metadata.keys():
21+
sys.exit(1)
22+
23+
else:
24+
sys.exit(0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
if python3 ./src/scripts/Pipelines/git_release_pipeline.py ./
4+
then
5+
echo " Model already has been deployed, updating it"
6+
python3 ./src/scripts/Pipelines/model_update_pipeline.py ./models/model.joblib ./ ./credentials.yaml
7+
else
8+
echo " Deploying model for the first time"
9+
python3 ./src/scripts/Pipelines/model_deploy_pipeline.py ./models/model.joblib ./ ./credentials.yaml
10+
fi

0 commit comments

Comments
 (0)