7
7
exclude :
8
8
- docs/
9
9
- environment_setup/
10
- - charts/
11
- - ml_service/util/create_scoring_image.py
10
+ - ml_service/util/create_scoring_image.*
12
11
13
12
variables :
14
13
- template : azdo-variables.yml
@@ -27,12 +26,15 @@ stages:
27
26
timeoutInMinutes : 0
28
27
steps :
29
28
- template : azdo-base-pipeline.yml
30
- - script : |
31
- # Invoke the Python building and publishing a training pipeline
32
- python3 $(Build.SourcesDirectory)/ml_service/pipelines/${{ variables.BUILD_TRAIN_SCRIPT }}
33
- failOnStderr: 'false'
34
- env:
35
- SP_APP_SECRET: '$(SP_APP_SECRET)'
29
+ - task : AzureCLI@1
30
+ inputs :
31
+ azureSubscription : ' $(WORKSPACE_SVC_CONNECTION)'
32
+ scriptLocation : inlineScript
33
+ inlineScript : |
34
+ set -e # fail on error
35
+ export SUBSCRIPTION_ID=$(az account show --query id -o tsv)
36
+ # Invoke the Python building and publishing a training pipeline
37
+ python $(Build.SourcesDirectory)/ml_service/pipelines/${{ variables.BUILD_TRAIN_SCRIPT }}
36
38
displayName : ' Publish Azure Machine Learning Pipeline'
37
39
- stage : ' Trigger_AML_Pipeline'
38
40
displayName : ' Train, evaluate, register model via previously published AML pipeline'
@@ -45,30 +47,43 @@ stages:
45
47
container : mcr.microsoft.com/mlops/python:latest
46
48
timeoutInMinutes : 0
47
49
steps :
48
- - script : |
49
- python $(Build.SourcesDirectory)/ml_service/pipelines/run_train_pipeline.py
50
- # Set AMLPIPELINEID variable for next AML Pipeline task in next job
51
- source $(Build.SourcesDirectory)/tmp.sh
52
- echo "##vso[task.setvariable variable=AMLPIPELINEID;isOutput=true]$AMLPIPELINE_ID"
53
- rm $(Build.SourcesDirectory)/tmp.sh
50
+ - task : AzureCLI@1
51
+ inputs :
52
+ azureSubscription : ' $(WORKSPACE_SVC_CONNECTION)'
53
+ scriptLocation : inlineScript
54
+ inlineScript : |
55
+ set -e # fail on error
56
+ export SUBSCRIPTION_ID=$(az account show --query id -o tsv)
57
+ python $(Build.SourcesDirectory)/ml_service/pipelines/run_train_pipeline.py --output_pipeline_id_file "pipeline_id.txt" --skip_train_execution
58
+ # Set AMLPIPELINEID variable for next AML Pipeline task in next job
59
+ AMLPIPELINEID="$(cat pipeline_id.txt)"
60
+ echo "##vso[task.setvariable variable=AMLPIPELINEID;isOutput=true]$AMLPIPELINEID"
54
61
name : ' getpipelineid'
55
62
displayName : ' Get Pipeline ID'
56
- env:
57
- SP_APP_SECRET: '$(SP_APP_SECRET)'
63
+ - bash : |
64
+ # Generate a hyperparameter value as a random number between 0 and 1.
65
+ # A random value is used here to make the Azure ML dashboards "interesting" when testing
66
+ # the solution sample.
67
+ alpha=$(printf "0.%03d\n" $((($RANDOM*1000)/32767)))
68
+ echo "Alpha: $alpha"
69
+ echo "##vso[task.setvariable variable=ALPHA;isOutput=true]$alpha"
70
+ name: 'getalpha'
71
+ displayName: 'Generate random value for hyperparameter alpha'
58
72
- job : " Run_ML_Pipeline"
59
73
dependsOn : " Get_Pipeline_ID"
60
74
displayName : " Trigger ML Training Pipeline"
61
75
pool : server
62
76
variables :
63
77
AMLPIPELINE_ID : $[ dependencies.Get_Pipeline_ID.outputs['getpipelineid.AMLPIPELINEID'] ]
78
+ ALPHA : $[ dependencies.Get_Pipeline_ID.outputs['getalpha.ALPHA'] ]
64
79
steps :
65
80
- task : ms-air-aiagility.vss-services-azureml.azureml-restApi-task.MLPublishedPipelineRestAPITask@0
66
81
displayName : ' Invoke ML pipeline'
67
82
inputs :
68
83
azureSubscription : ' $(WORKSPACE_SVC_CONNECTION)'
69
84
PipelineId : ' $(AMLPIPELINE_ID)'
70
85
ExperimentName : ' $(EXPERIMENT_NAME)'
71
- PipelineParameters : ' "model_name": "sklearn_regression_model.pkl" '
86
+ PipelineParameters : ' "ParameterAssignments": {" model_name": "$(MODEL_NAME)", "hyperparameter_alpha": "$(ALPHA)"} '
72
87
- job : " Training_Run_Report"
73
88
dependsOn : " Run_ML_Pipeline"
74
89
displayName : " Determine if evaluation succeeded and new model is registered"
@@ -77,22 +92,27 @@ stages:
77
92
container : mcr.microsoft.com/mlops/python:latest
78
93
timeoutInMinutes : 0
79
94
steps :
80
- - script : |
81
- python $(Build.SourcesDirectory)/code/register/register_model.py --build_id $(Build.BuildId) --validate True
82
- displayName: 'Check if new model registered'
83
- env:
84
- SP_APP_SECRET: '$(SP_APP_SECRET)'
95
+ - task : AzureCLI@1
96
+ inputs :
97
+ azureSubscription : ' $(WORKSPACE_SVC_CONNECTION)'
98
+ scriptLocation : inlineScript
99
+ inlineScript : |
100
+ set -e # fail on error
101
+ export SUBSCRIPTION_ID=$(az account show --query id -o tsv)
102
+ python $(Build.SourcesDirectory)/ml_service/pipelines/verify_train_pipeline.py --build_id $(Build.BuildId)
103
+ displayName : " Determine if evaluation succeeded and new model is registered"
85
104
- task : CopyFiles@2
86
105
displayName : ' Copy Files to: $(Build.ArtifactStagingDirectory)'
87
106
inputs :
88
107
SourceFolder : ' $(Build.SourcesDirectory)'
89
108
TargetFolder : ' $(Build.ArtifactStagingDirectory)'
90
109
Contents : |
91
110
code/scoring/**
111
+ ml_service/util/**
92
112
- task : PublishBuildArtifacts@1
93
113
displayName : ' Publish Artifact'
94
114
inputs :
95
115
ArtifactName : ' mlops-pipelines'
96
116
publishLocation : ' container'
97
117
pathtoPublish : ' $(Build.ArtifactStagingDirectory)'
98
- TargetPath : ' $(Build.ArtifactStagingDirectory)'
118
+ TargetPath : ' $(Build.ArtifactStagingDirectory)'
0 commit comments