forked from Azure/azureml-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-moe-inference-schema.sh
executable file
·135 lines (112 loc) · 3.86 KB
/
deploy-moe-inference-schema.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
set -e
# <set_variables>
RAND=`echo $RANDOM`
ENDPOINT_NAME="endpt-moe-$RAND"
# </set_variables>
BASE_PATH=endpoints/online/managed/inference-schema
# <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
# <register_model>
az ml model create -f $BASE_PATH/model.yml --set version=$RAND
# </register_model>
echo "Creating \"standard\" deployment..."
# <create_standard_deployment>
az ml online-deployment create -f $BASE_PATH/deployment-standard.yml \
--set model="azureml:azureml-infschema:$RAND" \
--set endpoint_name=$ENDPOINT_NAME \
--all-traffic
# </create_standard_deployment>
# Check if deployment was successful
deploy_status=`az ml online-deployment show --name infsrv-standard --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
# 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 swagger url
echo "Getting scoring url..."
SWAGGER_URL=$(az ml online-endpoint show -n $ENDPOINT_NAME --query openapi_uri -o tsv )
echo "Testing scoring... "
# <test_standard_scoring>
curl -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d @$BASE_PATH/sample-inputs/standard.json $SCORING_URL
# </test_standard_scoring>
echo "Getting swagger..."
# <get_standard_swagger>
curl -H "Authorization: Bearer $KEY" $SWAGGER_URL
# </get_standard_swagger>
# <create_numpy_deployment>
az ml online-deployment create -f $BASE_PATH/deployment-numpy.yml \
--set model="azureml:azureml-infschema:$RAND" \
--set endpoint_name=$ENDPOINT_NAME \
--all-traffic
# </create_numpy_deployment>
# Check if deployment was successful
deploy_status=`az ml online-deployment show --name infsrv-numpy --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
echo "Testing scoring... "
# <test_numpy_scoring>
curl -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d @$BASE_PATH/sample-inputs/numpy.json $SCORING_URL
# </test_numpy_scoring>
echo "Getting swagger..."
# <get_numpy_swagger>
curl -H "Authorization: Bearer $KEY" $SWAGGER_URL
# </get_numpy_swagger>
# <create_pandas_deployment>
az ml online-deployment create -f $BASE_PATH/deployment-pandas.yml \
--set model="azureml:azureml-infschema:$RAND" \
--set endpoint_name=$ENDPOINT_NAME \
--all-traffic
# </create_pandas_deployment>
# Check if deployment was successful
deploy_status=`az ml online-deployment show --name infsrv-pandas --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
echo "Testing scoring... "
# <test_pandas_scoring>
curl -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d @$BASE_PATH/sample-inputs/pandas.json $SCORING_URL
# </test_pandas_scoring>
echo "Getting swagger..."
# <get_pandas_swagger>
curl -H "Authorization: Bearer $KEY" $SWAGGER_URL
# </get_pandas_swagger>
# <delete_online_endpoint>
az ml online-endpoint delete -y -n $ENDPOINT_NAME --no-wait
# </delete_online_endpoint>