Skip to content

Commit df988f2

Browse files
authored
Merge pull request #2 from Microsoft/buildpipeline
Buildpipeline
2 parents a88ab43 + bc1d432 commit df988f2

File tree

7 files changed

+90
-7
lines changed

7 files changed

+90
-7
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# DevOps For AI
44

5+
[![Build Status](https://teamdanielletrialcicd.visualstudio.com/MLAKSDeployAML/_apis/build/status/DevopsforAI-AML?branchName=master)](https://teamdanielletrialcicd.visualstudio.com/MLAKSDeployAML/_build/latest?definitionId=9&branchName=buildpipeline)
6+
57
[DevOps for AI template](https://azuredevopsdemogenerator.azurewebsites.net/?name=azure%20machine%20learning) will help you to understand how to build the Continuous Integration and Continuous Delivery pipeline for a ML/AI project. We will be using the Azure DevOps Project for build and release pipelines along with Azure ML services for ML/AI model management and operationalization.
68

79
This template contains code and pipeline definition for a machine learning project demonstrating how to automate the end to end ML/AI project. The build pipelines include DevOps tasks for data sanity test, unit test, model training on different compute targets, model version management, model evaluation/model selection, model deployment as realtime web service, staged deployment to QA/prod, integration testing and functional testing.

aml_service/00-WorkSpace.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
POSSIBILITY OF SUCH DAMAGE.
2525
"""
2626
from azureml.core import Workspace
27-
import os, json
27+
import os, json, sys
2828
import azureml.core
29+
from azureml.core.authentication import AzureCliAuthentication
2930

3031
print("SDK Version:", azureml.core.VERSION)
3132
# print('current dir is ' +os.curdir)
@@ -36,12 +37,15 @@
3637
resource_group = config["resource_group"]
3738
subscription_id = config["subscription_id"]
3839
location = config["location"]
39-
# location = 'southcentralus'
40+
41+
cli_auth = AzureCliAuthentication()
42+
4043
try:
4144
ws = Workspace.get(
4245
name=workspace_name,
4346
subscription_id=subscription_id,
4447
resource_group=resource_group,
48+
auth=cli_auth
4549
)
4650

4751
except:
@@ -53,6 +57,8 @@
5357
resource_group=resource_group,
5458
# create_resource_group=True,
5559
location=location,
60+
auth=cli_auth
61+
5662
)
5763

5864
# print Workspace details

aml_service/10-TrainOnLocal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
from azureml.core import Experiment
3030
from azureml.core import ScriptRunConfig
3131
import json
32+
from azureml.core.authentication import AzureCliAuthentication
33+
cli_auth = AzureCliAuthentication()
3234

3335
# Get workspace
34-
ws = Workspace.from_config()
36+
ws = Workspace.from_config(auth=cli_auth)
3537

3638
# Attach Experiment
3739
experiment_name = "devops-ai-demo"

aml_service/15-EvaluateModel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
from azureml.core.model import Model
3030
import azureml.core
3131
from azureml.core import Run
32-
32+
from azureml.core.authentication import AzureCliAuthentication
33+
cli_auth = AzureCliAuthentication()
3334

3435
# Get workspace
35-
ws = Workspace.from_config()
36+
ws = Workspace.from_config(auth=cli_auth)
3637

3738
# Paramaterize the matrics on which the models should be compared
3839

aml_service/20-RegisterModel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
from azureml.core.model import Model
3131

3232
from azureml.core.runconfig import RunConfiguration
33+
from azureml.core.authentication import AzureCliAuthentication
34+
cli_auth = AzureCliAuthentication()
3335

3436
# Get workspace
35-
ws = Workspace.from_config()
37+
ws = Workspace.from_config(auth=cli_auth)
3638

3739
# Get the latest evaluation result
3840
try:

aml_service/30-CreateScoringImage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
from azureml.core import Workspace
2828
from azureml.core.image import ContainerImage, Image
2929
from azureml.core.model import Model
30+
from azureml.core.authentication import AzureCliAuthentication
31+
cli_auth = AzureCliAuthentication()
3032

3133
# Get workspace
32-
ws = Workspace.from_config()
34+
ws = Workspace.from_config(auth=cli_auth)
3335

3436
# Get the latest model details
3537

azure-pipelines.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
pool:
2+
vmImage: 'Ubuntu 16.04'
3+
#Your build pipeline references a secret variable named ‘sp_username’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972
4+
#Your build pipeline references a secret variable named ‘sp_password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972
5+
#Your build pipeline references a secret variable named ‘sp_tenantid’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972
6+
#Your build pipeline references a secret variable named ‘subscription_id’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972
7+
8+
steps:
9+
- task: CondaEnvironment@1
10+
displayName: 'Create Conda Environment '
11+
inputs:
12+
createCustomEnvironment: true
13+
environmentName: azuremlsdk
14+
packageSpecs: 'python=3.6'
15+
updateConda: false
16+
createOptions: 'cython numpy'
17+
18+
- task: Bash@3
19+
displayName: 'Install Requirements'
20+
inputs:
21+
targetType: filePath
22+
filePath: 'environment_setup/install_requirements.sh'
23+
workingDirectory: 'environment_setup'
24+
25+
- script: |
26+
az login --service-principal -u $(sp_username) -p $(sp_password) --tenant $(sp_tenantid)
27+
28+
displayName: 'Login to Azure'
29+
30+
- script: |
31+
sed -i 's#"subscription_id": "<>"#"subscription_id": "$(subscription_id)"#g' aml_config/config.json
32+
33+
displayName: 'replace subscription value'
34+
35+
- script: 'python code/testing/data_test.py data/diabetes.csv && python code/testing/data_test.py data/diabetes_bad_dist.csv && python code/testing/data_test.py data/diabetes_bad_schema.csv && python code/testing/data_test.py data/diabetes_missing_values.csv'
36+
displayName: 'Data Quality Check'
37+
38+
- script: 'python aml_service/00-WorkSpace.py'
39+
displayName: 'Get or Create workspace copy'
40+
41+
- script: 'python aml_service/10-TrainOnLocal.py'
42+
displayName: 'Train on Local'
43+
44+
- script: 'python aml_service/15-EvaluateModel.py'
45+
displayName: 'Evaluate Model'
46+
47+
- script: 'python aml_service/20-RegisterModel.py'
48+
displayName: 'Register Model'
49+
50+
- script: 'python aml_service/30-CreateScoringImage.py'
51+
displayName: 'Creating scoring image'
52+
53+
- task: CopyFiles@2
54+
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
55+
inputs:
56+
SourceFolder: '$(Build.SourcesDirectory)'
57+
TargetFolder: '$(Build.ArtifactStagingDirectory)'
58+
Contents: '**'
59+
60+
- task: PublishBuildArtifacts@1
61+
displayName: 'Publish Artifact: devops-for-ai'
62+
inputs:
63+
ArtifactName: 'devops-for-ai'
64+
publishLocation: 'container'
65+
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
66+
TargetPath: '$(Build.ArtifactStagingDirectory)'
67+
68+

0 commit comments

Comments
 (0)