77 exclude :
88 - docs/
99 - environment_setup/
10- - charts/
11- - ml_service/util/create_scoring_image.py
10+ - ml_service/util/create_scoring_image.*
1211
1312variables :
1413- template : azdo-variables.yml
@@ -27,12 +26,15 @@ stages:
2726 timeoutInMinutes : 0
2827 steps :
2928 - 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 }}
3638 displayName : ' Publish Azure Machine Learning Pipeline'
3739- stage : ' Trigger_AML_Pipeline'
3840 displayName : ' Train, evaluate, register model via previously published AML pipeline'
@@ -45,30 +47,43 @@ stages:
4547 container : mcr.microsoft.com/mlops/python:latest
4648 timeoutInMinutes : 0
4749 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"
5461 name : ' getpipelineid'
5562 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'
5872 - job : " Run_ML_Pipeline"
5973 dependsOn : " Get_Pipeline_ID"
6074 displayName : " Trigger ML Training Pipeline"
6175 pool : server
6276 variables :
6377 AMLPIPELINE_ID : $[ dependencies.Get_Pipeline_ID.outputs['getpipelineid.AMLPIPELINEID'] ]
78+ ALPHA : $[ dependencies.Get_Pipeline_ID.outputs['getalpha.ALPHA'] ]
6479 steps :
6580 - task : ms-air-aiagility.vss-services-azureml.azureml-restApi-task.MLPublishedPipelineRestAPITask@0
6681 displayName : ' Invoke ML pipeline'
6782 inputs :
6883 azureSubscription : ' $(WORKSPACE_SVC_CONNECTION)'
6984 PipelineId : ' $(AMLPIPELINE_ID)'
7085 ExperimentName : ' $(EXPERIMENT_NAME)'
71- PipelineParameters : ' "model_name": "sklearn_regression_model.pkl" '
86+ PipelineParameters : ' "ParameterAssignments": {" model_name": "$(MODEL_NAME)", "hyperparameter_alpha": "$(ALPHA)"} '
7287 - job : " Training_Run_Report"
7388 dependsOn : " Run_ML_Pipeline"
7489 displayName : " Determine if evaluation succeeded and new model is registered"
@@ -77,22 +92,27 @@ stages:
7792 container : mcr.microsoft.com/mlops/python:latest
7893 timeoutInMinutes : 0
7994 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"
85104 - task : CopyFiles@2
86105 displayName : ' Copy Files to: $(Build.ArtifactStagingDirectory)'
87106 inputs :
88107 SourceFolder : ' $(Build.SourcesDirectory)'
89108 TargetFolder : ' $(Build.ArtifactStagingDirectory)'
90109 Contents : |
91110 code/scoring/**
111+ ml_service/util/**
92112 - task : PublishBuildArtifacts@1
93113 displayName : ' Publish Artifact'
94114 inputs :
95115 ArtifactName : ' mlops-pipelines'
96116 publishLocation : ' container'
97117 pathtoPublish : ' $(Build.ArtifactStagingDirectory)'
98- TargetPath : ' $(Build.ArtifactStagingDirectory)'
118+ TargetPath : ' $(Build.ArtifactStagingDirectory)'
0 commit comments