-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
deploy-moe-binary-payloads.sh
82 lines (68 loc) · 2.54 KB
/
deploy-moe-binary-payloads.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
set -e
# <set_variables>
ENDPOINT_NAME=endpt-moe-`echo $RANDOM`
ACR_NAME=$(az ml workspace show --query container_registry -o tsv | cut -d'/' -f9-)
# </set_variables>
BASE_PATH="endpoints/online/managed/binary-payloads"
# <download_sample_data>
wget https://aka.ms/peacock-pic -O endpoints/online/managed/binary-payloads/input.jpg
# </download_sample_data>
# <create_endpoint>
az ml online-endpoint create -n $ENDPOINT_NAME
# </create_endpoint>
# Check if endpoint was successful
endpoint_status=`az ml online-endpoint show --name $ENDPOINT_NAME --query "provisioning_state" -o tsv `
echo $endpoint_status
if [[ $endpoint_status == "Succeeded" ]]
then
echo "Endpoint created successfully"
else
echo "Endpoint creation failed"
exit 1
fi
# <create_deployment>
az ml online-deployment create -e $ENDPOINT_NAME -f $BASE_PATH/binary-payloads-deployment.yml \
--set code_configuration.scoring_script=single-file-to-file-score.py \
--all-traffic
# </create_deployment>
# <get_endpoint_details>
# Get key
echo "Getting access key..."
KEY=$(az ml online-endpoint get-credentials -n $ENDPOINT_NAME --query primaryKey -o tsv )
# Get scoring url
echo "Getting scoring url..."
SCORING_URL=$(az ml online-endpoint show -n $ENDPOINT_NAME --query scoring_uri -o tsv )
echo "Scoring url is $SCORING_URL"
# </get_endpoint_details>
# <get_logs>
az ml online-deployment get-logs -n binary-payload -e $ENDPOINT_NAME
# </get_logs>
# <check_deployment>
# Check if deployment was successful
deploy_status=`az ml online-deployment show --name binary-payload --endpoint $ENDPOINT_NAME --query "provisioning_state" -o tsv `
echo $deploy_status
if [[ $deploy_status == "Succeeded" ]]
then
echo "Deployment completed successfully"
else
echo "Deployment failed"
exit 1
fi
# </check_deployment>
# <test_online_endpoint_1>
curl -X POST -F "file=@endpoints/online/managed/binary-payloads/input.jpg" -H "Authorization: Bearer $KEY" $SCORING_URL \
-o endpoints/online/managed/binary-payloads/output.jpg
# <test_online_endpoint_1>
# <update_deployment2>
az ml online-deployment update -e $ENDPOINT_NAME -n binary-payload \
--set code_configuration.scoring_script="multi-file-to-json-score.py"
# </updat _deployment2>
# <test_online_endpoint_2>
curl -X POST -F "file[]=@endpoints/online/managed/binary-payloads/input.jpg" \
-F "file[]=@endpoints/online/managed/binary-payloads/output.jpg" \
-H "Authorization: Bearer $KEY" $SCORING_URL
# <test_online_endpoint_2>
# <delete_assets>
az ml online-endpoint delete -n $ENDPOINT_NAME --no-wait --yes
# </delete_assets>