Skip to content

Commit d42419d

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/DevOpsForAI into develop
2 parents 2a881a1 + 0b4eba1 commit d42419d

23 files changed

+903
-840
lines changed

.azureml/sklearn.runconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"script": "train.py",
3+
"framework": "Python",
4+
"communicator": "None",
5+
"target": "cpu",
6+
"environment": {
7+
"python": {
8+
"interpreterPath": "python",
9+
"userManagedDependencies": false,
10+
"condaDependencies": {
11+
"dependencies":[
12+
"python=3.6.2",
13+
"scikit-learn",
14+
{
15+
"pip":[
16+
"azureml-defaults"
17+
]
18+
}
19+
]
20+
}
21+
},
22+
"docker": {
23+
"baseImage": "mcr.microsoft.com/azureml/base:0.2.4",
24+
"enabled": true,
25+
"gpuSupport": true
26+
}
27+
}
28+
}

README.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
### Author: | Praneet Singh Solanki | Richin Jain |
2-
3-
# DevOps for AI
1+
# MLOps with Azure ML
42

53
[![Build Status](https://dev.azure.com/customai/DevopsForAI-AML/_apis/build/status/Microsoft.DevOpsForAI?branchName=master)](https://dev.azure.com/customai/DevopsForAI-AML/_build/latest?definitionId=1&branchName=master)
64

5+
MLOps 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/deployment pipelines along with Azure ML services for model retraining pipeline, model management and operationalization.
76

7+
![ML lifecycle](/docs/images/ml-lifecycle.png)
88

9-
DevOps for AI 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/deployment pipelines along with Azure ML services for model retraining pipeline, model management and operationalization.
10-
11-
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 and integration testing.
9+
This template contains code and pipeline definition for a machine learning project demonstrating how to automate an end to end ML/AI workflow. 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 and integration testing.
1210

1311

1412
## Prerequisite
@@ -30,43 +28,41 @@ This reference architecture shows how to implement continuous integration (CI),
3028
## Architecture Flow
3129

3230
1. Data Scientist writes/updates the code and push it to git repo. This triggers the Azure DevOps build pipeline (continuous integration).
33-
2. Once the Azure DevOps build pipeline is triggered, it runs following type of tasks:
34-
- Run for new code: Every time new code is committed to the repo, build pipeline performs data sanity test and unit tests the new code.
31+
2. Once the Azure DevOps build pipeline is triggered, it runs following types of tasks:
32+
- Run for new code: Every time new code is committed to the repo, the build pipeline performs data sanity tests and unit tests on the new code.
33+
- One-time run: These tasks runs only for the first time the build pipeline runs. It will programatically create an [Azure ML Service Workspace](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#workspace), provision [Azure ML Compute](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-set-up-training-targets#amlcompute) (used for model training compute), and publish an [Azure ML Pipeline](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-ml-pipelines). This published Azure ML pipeline is the model training/retraining pipeline.
3534

36-
- One-time run: These tasks runs only for the first time build pipeline run, they create [Azure ML Service Workspace](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#workspace), [Azure ML Compute](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-set-up-training-targets#amlcompute) used as model training compute and publish a [Azure ML Pipeline](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-ml-pipelines) with code. This published Azure ML pipeline is the model training/retraining pipeline.
37-
38-
`Note: The task Publish Azure ML pipeline currently runs for every code change`
35+
> Note: The Publish Azure ML pipeline task currently runs for every code change
3936
4037
3. The Azure ML Retraining pipeline is triggered once the Azure DevOps build pipeline completes. All the tasks in this pipeline runs on Azure ML Compute created earlier. Following are the tasks in this pipeline:
4138

42-
- **Train Model** task executes model training script on Azure ML Compute. It outputs a [model](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#model) file which is stored in the [run history](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#run)
39+
- **Train Model** task executes model training script on Azure ML Compute. It outputs a [model](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#model) file which is stored in the [run history](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#run).
4340

44-
- **Evaluate Model** task evaluates the performance of newly trained model with the model in production. If new trained model performs better than the production model, next steps are executed. Else next steps are skipped.
41+
- **Evaluate Model** task evaluates the performance of newly trained model with the model in production. If the new model performs better than the production model, the following steps are executed. If not, they will be skipped.
4542

46-
- **Register Model** task takes the new trained better performing model and registers it with the [Azure ML Model registry](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#model-registry) to version control it.
43+
- **Register Model** task takes the improved model and registers it with the [Azure ML Model registry](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#model-registry). This allows us to version control it.
4744

48-
- **Package Model** task packages the new trained model along with scoring file and python dependencies into a docker [image](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#image) and pushes it to [Azure Container Registry](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-intro). This image is used to deploy model as [web service](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#web-service).
45+
- **Package Model** task packages the new model along with the scoring file and its python dependencies into a [docker image](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#image) and pushes it to [Azure Container Registry](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-intro). This image is used to deploy the model as [web service](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#web-service).
4946

50-
4. Once a new model scoring image is pushed to Azure Container Registry, Azure DevOps Release/Deployment pipeline is triggered. This pipeline deploys the model scoring image into Staging/QA and PROD environments.
47+
4. Once a new model scoring image is pushed to Azure Container Registry, the Azure DevOps Release/Deployment pipeline is triggered. This pipeline deploys the model scoring image into Staging/QA and PROD environments.
5148

52-
- In the Staging/QA, one task creates [Azure Container Instance](https://docs.microsoft.com/en-us/azure/container-instances/container-instances-overview) and deploy scoring image as [web service](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#web-service) on it.
49+
- In the Staging/QA environment, one task creates an [Azure Container Instance](https://docs.microsoft.com/en-us/azure/container-instances/container-instances-overview) and deploys the scoring image as a [web service](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-azure-machine-learning-architecture#web-service) on it.
5350

54-
- The second task test this web service by calling its REST endpoint with dummy data.
51+
- The second task tests this web service by calling its REST endpoint with dummy data.
5552

5653

57-
5. The deployment in production is a [gated release](https://docs.microsoft.com/en-us/azure/devops/pipelines/release/approvals/gates?view=azure-devops). Which means, once the model web service deployment in Staging/QA environment is successful, a notification is sent to approvers to manually review and approve the release. Once the release is approved, the model scoring web service is deployed to [Azure Kubernetes Service(AKS)](https://docs.microsoft.com/en-us/azure/aks/intro-kubernetes) and the deployment is tested.
54+
5. The deployment in production is a [gated release](https://docs.microsoft.com/en-us/azure/devops/pipelines/release/approvals/gates?view=azure-devops). This means that once the model web service deployment in the Staging/QA environment is successful, a notification is sent to approvers to manually review and approve the release. Once the release is approved, the model scoring web service is deployed to [Azure Kubernetes Service(AKS)](https://docs.microsoft.com/en-us/azure/aks/intro-kubernetes) and the deployment is tested.
5855

5956
### Repo Details
6057

6158
You can find the details of the code and scripts in the repository [here](/docs/code_description.md)
6259

6360
### References
6461
- [Azure Machine Learning(Azure ML) Service Workspace](https://docs.microsoft.com/en-us/azure/machine-learning/service/overview-what-is-azure-ml)
65-
62+
- [Azure ML CLI](https://docs.microsoft.com/en-us/azure/machine-learning/service/reference-azure-machine-learning-cli)
6663
- [Azure ML Samples](https://docs.microsoft.com/en-us/azure/machine-learning/service/samples-notebooks)
6764
- [Azure ML Python SDK Quickstart](https://docs.microsoft.com/en-us/azure/machine-learning/service/quickstart-create-workspace-with-python)
6865
- [Azure DevOps](https://docs.microsoft.com/en-us/azure/devops/?view=vsts)
69-
- [DevOps for AI template (Old Version)](https://azuredevopsdemogenerator.azurewebsites.net/?name=azure%20machine%20learning)
7066

7167
# Contributing
7268

azure-pipelines.yml

Lines changed: 68 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +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-
variables:
9-
- group: AzureKeyVaultSecrets
10-
11-
trigger:
12-
- master
13-
- releases/*
14-
- develop
15-
16-
steps:
17-
- task: UsePythonVersion@0
18-
inputs:
19-
versionSpec: '3.6'
20-
architecture: 'x64'
21-
22-
- task: Bash@3
23-
displayName: 'Install Requirements'
24-
inputs:
25-
targetType: filePath
26-
filePath: 'environment_setup/install_requirements.sh'
27-
workingDirectory: 'environment_setup'
28-
29-
- script: |
30-
az login --service-principal -u $(spidentity) -p $(spsecret) --tenant $(sptenant)
31-
32-
displayName: 'Login to Azure'
33-
34-
- script: |
35-
sed -i 's#"subscription_id": "<>"#"subscription_id": "$(subscription_id)"#g' aml_config/config.json
36-
37-
displayName: 'replace subscription value'
38-
39-
- script: 'pytest tests/unit/data_test.py'
40-
displayName: 'Data Quality Check'
41-
42-
- script: 'python aml_service/00-WorkSpace.py'
43-
displayName: 'Get or Create Workspace'
44-
45-
- script: 'python aml_service/03-AttachAmlCluster.py'
46-
displayName: 'Create AML Compute Cluster'
47-
48-
- script: 'python aml_service/04-AmlPipelines.py'
49-
displayName: 'Create and Test AML Pipeline'
50-
51-
- script: 'python aml_service/04-AmlPipelines.py --pipeline_action publish'
52-
displayName: 'Publish AML Pipeline as Endpoint'
53-
54-
- task: CopyFiles@2
55-
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
56-
inputs:
57-
SourceFolder: '$(Build.SourcesDirectory)'
58-
TargetFolder: '$(Build.ArtifactStagingDirectory)'
59-
Contents: '**'
60-
61-
- task: PublishBuildArtifacts@1
62-
displayName: 'Publish Artifact: devops-for-ai'
63-
inputs:
64-
ArtifactName: 'devops-for-ai'
65-
publishLocation: 'container'
66-
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
67-
TargetPath: '$(Build.ArtifactStagingDirectory)'
68-
69-
- task: PublishBuildArtifacts@1
70-
displayName: 'Publish Artifact: AML Pipeline Config'
71-
inputs:
72-
ArtifactName: 'devops-for-ai-aml-pipeline'
73-
publishLocation: 'container'
74-
pathtoPublish: '$(Build.ArtifactStagingDirectory)/aml_config/pipeline_config.json'
75-
TargetPath: '$(Build.ArtifactStagingDirectory)/aml_config/pipeline_config.json'
76-
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+
variables:
9+
- group: AzureKeyVaultSecrets
10+
11+
trigger:
12+
- master
13+
- releases/*
14+
- develop
15+
16+
steps:
17+
- task: UsePythonVersion@0
18+
inputs:
19+
versionSpec: '3.6'
20+
architecture: 'x64'
21+
22+
- task: Bash@3
23+
displayName: 'Install Requirements'
24+
inputs:
25+
targetType: filePath
26+
filePath: 'environment_setup/install_requirements.sh'
27+
workingDirectory: 'environment_setup'
28+
29+
- script: |
30+
az login --service-principal -u $(spidentity) -p $(spsecret) --tenant $(sptenant)
31+
32+
displayName: 'Login to Azure'
33+
34+
- script: |
35+
sed -i 's#"subscription_id": "<>"#"subscription_id": "$(subscriptionid)"#g' aml_config/config.json
36+
37+
displayName: 'replace subscription value'
38+
39+
- script: 'pytest tests/unit/data_test.py'
40+
displayName: 'Data Quality Check'
41+
42+
- script: 'python aml_service/00-WorkSpace.py'
43+
displayName: 'Get or Create Workspace'
44+
45+
- script: 'python aml_service/03-AttachAmlCluster.py'
46+
displayName: 'Create AML Compute Cluster'
47+
48+
- script: 'python aml_service/04-AmlPipelines.py'
49+
displayName: 'Create and Test AML Pipeline'
50+
51+
- script: 'python aml_service/04-AmlPipelines.py --pipeline_action publish'
52+
displayName: 'Publish AML Pipeline as Endpoint'
53+
54+
- task: CopyFiles@2
55+
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
56+
inputs:
57+
SourceFolder: '$(Build.SourcesDirectory)'
58+
TargetFolder: '$(Build.ArtifactStagingDirectory)'
59+
Contents: '**'
60+
61+
- task: PublishBuildArtifacts@1
62+
displayName: 'Publish Artifact: devops-for-ai'
63+
inputs:
64+
ArtifactName: 'devops-for-ai'
65+
publishLocation: 'container'
66+
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
67+
TargetPath: '$(Build.ArtifactStagingDirectory)'
68+

0 commit comments

Comments
 (0)