-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathdeploy-moe-minimal-single-model-registered.sh
More file actions
80 lines (66 loc) · 2.14 KB
/
deploy-moe-minimal-single-model-registered.sh
File metadata and controls
80 lines (66 loc) · 2.14 KB
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
#!/bin/bash
set -e
# <set_variables>
RAND=`echo $RANDOM`
ENDPOINT_NAME="endpt-moe-$RAND"
MODEL_VERSION=$RAND
ASSET_PATH=endpoints/online/model-1
# </set_variables>
BASE_PATH=endpoints/online/managed/minimal/single-model-registered
# Helper function to change parameters in yaml files
change_vars() {
for FILE in "$@"; do
TMP="${FILE}_"
cp $FILE $TMP
readarray -t VARS < <(cat $TMP | grep -oP '{{.*?}}' | sed -e 's/[}{]//g');
for VAR in "${VARS[@]}"; do
sed -i "s/{{${VAR}}}/${!VAR}/g" $TMP
done
done
}
# <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>
change_vars $BASE_PATH/model.yml
az ml model create -f $BASE_PATH/model.yml_
# </register_model>
rm $BASE_PATH/model.yml_
# <create_deployment>
change_vars $BASE_PATH/deployment.yml
az ml online-deployment create -f $BASE_PATH/deployment.yml_ --all-traffic
# </create-deployment>
rm $BASE_PATH/deployment.yml_
# Check if deployment was successful
deploy_status=`az ml online-deployment show --name smr --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"
# <test_deployment_conda_in_dockerfile>
curl -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d @$ASSET_PATH/sample-request.json $SCORING_URL
# </test_deployment_conda_in_dockerfile>
# <delete_online_endpoint>
az ml online-endpoint delete -y -n $ENDPOINT_NAME --no-wait
# </delete_online_endpoint>