generated from MicrosoftLearning/mslearn-mlops
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (85 loc) · 2.48 KB
/
train-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
name: Train Model
on:
workflow_dispatch:
branches:
- main
env:
workspace-name: aml-ws-mlops
resource-group: rg-mlops
permissions:
id-token: write
contents: read
jobs:
linting:
name: linting
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Use Python version 3.8
uses: actions/setup-python@v3
with:
python-version: '3.8'
- name: Install Flake8
run: |
python -m pip install flake8
- name: Run linting tests
run: |
flake8 src/model/
unit-test:
name: unit-test
runs-on: ubuntu-latest
needs: [linting]
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Use Python version 3.8
uses: actions/setup-python@v3
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run unit tests
run: |
pytest tests/test_train.py
train-dev:
name: train-model-dev
runs-on: ubuntu-latest
needs: [unit-test]
environment:
name: dev
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Install az ml extension
run: az extension add -n ml -y
- name: "Az CLI login"
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Trigger Azure ML job
run: az ml job create --file src/job.yml --workspace-name ${{ env.workspace-name }} --resource-group ${{ env.resource-group }}
train-prod:
name: train-model-prod
runs-on: ubuntu-latest
needs: [train-dev]
environment:
name: prod
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Install az ml extension
run: az extension add -n ml -y
- name: "Az CLI login"
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Trigger Azure ML job
run: az ml job create --file src/job-prod.yml --workspace-name ${{ env.workspace-name }} --resource-group ${{ env.resource-group }} --stream