generated from MicrosoftLearning/mslearn-mlops
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (108 loc) · 4.16 KB
/
06-deploy-model.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
name: Deploy latest model on PRs to main
on:
pull_request:
branches:
- main
jobs:
dev-model:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Install az ml extension
run: az extension add -n ml -y
- name: Azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Set default workspace and resource group
run: az configure --defaults group=rg-redi-dev workspace=amlws-redi-dev
- name: Submit dev training job
run: az ml job create -f src/job.yml --stream
prod-model:
runs-on: ubuntu-latest
needs: dev-model
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Install az ml extension
run: az extension add -n ml -y
- name: Azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Set default workspace and resource group
run: az configure --defaults group=rg-redi-dev workspace=amlws-redi-dev
- name: Submit prod training job
run: az ml job create -f src/job.yml --set inputs.training_data.path=../production/data --set experiment_name=mslearn-mlops-tutorial-experiment-prod
register-model:
runs-on: ubuntu-latest
needs: prod-model
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Install az ml extension
run: az extension add -n ml -y
- name: Azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Set default workspace and resource group
run: az configure --defaults group=rg-redi-dev workspace=amlws-redi-dev
- name: Get name of last successful job
run: echo "LAST_SUCCESSFUL_JOB=$(az ml job list --output tsv --query "[?experiment_name=='mslearn-mlops-tutorial-experiment-prod' && status=='Completed'].name | [0]")" >> "$GITHUB_ENV"
- name: Register model
run: az ml model create --name mslearn-mlops-tutorial --type mlflow_model --path azureml://jobs/${{env.LAST_SUCCESSFUL_JOB}}/outputs/artifacts/paths/model/
# create-endpoint:
# runs-on: ubuntu-latest
# steps:
# - name: Check out repo
# uses: actions/checkout@main
# - name: Install az ml extension
# run: az extension add -n ml -y
# - name: Azure login
# uses: azure/login@v1
# with:
# creds: ${{secrets.AZURE_CREDENTIALS}}
# - name: Set default workspace and resource group
# run: az configure --defaults group=rg-redi-dev workspace=amlws-redi-dev
# - name: Create endpoint if doesn't exist
# run: |
# ENDPOINT_EXISTS=$(az ml online-endpoint list -o tsv --query "[?name=='mslearn-mlops-tutorial-endpoint'][name]" | wc -l)
# if [[ ENDPOINT_EXISTS -ne 1 ]]; then
# az ml online-endpoint create -f ./src/endpoint.yml
# else
# echo "Endpoint exists already"
# fi
deploy-model:
runs-on: ubuntu-latest
needs: register-model
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Install az ml extension
run: az extension add -n ml -y
- name: Azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Set default workspace and resource group
run: az configure --defaults group=rg-redi-dev workspace=amlws-redi-dev
- name: Deploy latest model
run: az ml online-deployment update -f ./src/deployment.yml
test-endpoint:
runs-on: ubuntu-latest
needs: deploy-model
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Install az ml extension
run: az extension add -n ml -y
- name: Azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Set default workspace and resource group
run: az configure --defaults group=rg-redi-dev workspace=amlws-redi-dev
- name: Test latest model
run: az ml online-endpoint invoke -n mslearn-mlops-tutorial-endpoint --request-file ./src/sample-data.json