forked from liupeirong/MLOpsManufacturing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-model-template.yml
43 lines (39 loc) · 1.39 KB
/
package-model-template.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
# Pipeline template that creates a model package and adds the package location to the environment for subsequent tasks to use.
parameters:
- name: modelId
type: string
default: ''
- name: scoringScriptPath
type: string
default: ''
- name: condaFilePath
type: string
default: ''
- name: imageName
type: string
default: ''
- name: workingDirectory
displayName: Working Directory for sample
type: string
steps:
- task: AzureCLI@1
displayName: 'Create model package and set IMAGE_LOCATION variable'
inputs:
azureSubscription: '$(WORKSPACE_SVC_CONNECTION)'
scriptLocation: inlineScript
workingDirectory: ${{ parameters.workingDirectory }}
inlineScript: |
set -e # fail on error
# Create model package using CLI
az ml model package --workspace-name $(WORKSPACE_NAME) -g $(RESOURCE_GROUP) \
--model '${{ parameters.modelId }}' \
--entry-script '${{ parameters.scoringScriptPath }}' \
--cf '${{ parameters.condaFilePath }}' \
--image-name '${{ parameters.imageName }}' \
-v \
--rt python --query 'location' -o tsv > image_logs.txt
# Show logs
cat image_logs.txt
# Set environment variable using the last line of logs that has the package location
IMAGE_LOCATION=$(tail -n 1 image_logs.txt)
echo "##vso[task.setvariable variable=IMAGE_LOCATION]$IMAGE_LOCATION"