Skip to content

Commit 188fdcb

Browse files
authored
Remove datasets for foundation models online inference samples (#2294)
* cli samples * remove dataset * change text-class dataset * fix dataset path * sdk samples * resolving comments
1 parent 7a7ad56 commit 188fdcb

40 files changed

+3454
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
set -x
2+
# the commands in this file map to steps in this notebook: https://aka.ms/azureml-infer-online-sdk-asr
3+
# the sample scoring file available in the same folder as the above notebook
4+
5+
# script inputs
6+
registry_name="azureml"
7+
subscription_id="<SUBSCRIPTION_ID>"
8+
resource_group_name="<RESOURCE_GROUP>"
9+
workspace_name="<WORKSPACE_NAME>"
10+
11+
# This is the model from system registry that needs to be deployed
12+
model_name="openai-whisper-large"
13+
14+
# Validate the existence of the model in the registry and get the latest version
15+
model_list=$(az ml model list --name ${model_name} --registry-name ${registry_name} 2>&1)
16+
if [[ ${model_list} == *"[]"* ]]; then
17+
echo "Model doesn't exist in registry. Check the model list and try again."; exit 1;
18+
fi
19+
version_temp=${model_list#*\"version\": \"}
20+
model_version=${version_temp%%\"*}
21+
22+
version=$(date +%s)
23+
endpoint_name="asr-$version"
24+
25+
# todo: fetch deployment_sku from the min_inference_sku tag of the model
26+
deployment_sku="Standard_DS4_v2"
27+
28+
# scoring_file
29+
scoring_file="../../../../../sdk/python/foundation-models/system/inference/automatic-speech-recognition/sample-request/sample_score.json"
30+
31+
# 1. Setup pre-requisites
32+
if [ "$subscription_id" = "<SUBSCRIPTION_ID>" ] || \
33+
["$resource_group_name" = "<RESOURCE_GROUP>" ] || \
34+
[ "$workspace_name" = "<WORKSPACE_NAME>" ]; then
35+
echo "Please update the script with the subscription_id, resource_group_name and workspace_name"
36+
exit 1
37+
fi
38+
39+
az account set -s $subscription_id
40+
workspace_info="--resource-group $resource_group_name --workspace-name $workspace_name"
41+
42+
# 2. Check if the model exists in the registry
43+
# need to confirm model show command works for registries outside the tenant (aka system registry)
44+
if ! az ml model show --name $model_name --version $model_version --registry-name $registry_name
45+
then
46+
echo "Model $model_name:$model_version does not exist in registry $registry_name"
47+
exit 1
48+
fi
49+
50+
# 3. Deploy the model to an endpoint
51+
# create online endpoint
52+
az ml online-endpoint create --name $endpoint_name $workspace_info || {
53+
echo "endpoint create failed"; exit 1;
54+
}
55+
56+
# deploy model from registry to endpoint in workspace
57+
az ml online-deployment create --file deploy.yml $workspace_info --all-traffic --set \
58+
endpoint_name=$endpoint_name model=azureml://registries/$registry_name/models/$model_name/versions/$model_version \
59+
instance_type=$deployment_sku || {
60+
echo "deployment create failed"; exit 1;
61+
}
62+
63+
# 4. Try a sample scoring request
64+
65+
# Check if scoring data file exists
66+
if [ -f $scoring_file ]; then
67+
echo "Invoking endpoint $endpoint_name with following input:\n\n"
68+
cat $scoring_file
69+
echo "\n\n"
70+
else
71+
echo "Scoring file $scoring_file does not exist"
72+
exit 1
73+
fi
74+
75+
az ml online-endpoint invoke --name $endpoint_name --request-file $scoring_file $workspace_info || {
76+
echo "endpoint invoke failed"; exit 1;
77+
}
78+
79+
# 6. Delete the endpoint
80+
az ml online-endpoint delete --name $endpoint_name $workspace_info --yes || {
81+
echo "endpoint delete failed"; exit 1;
82+
}
83+
84+
85+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json
2+
name: demo
3+
instance_type: Standard_DS4_v2
4+
instance_count: 1
5+
request_settings:
6+
request_timeout_ms: 60000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json
2+
name: demo
3+
instance_type: Standard_DS3_v2
4+
instance_count: 1
5+
request_settings:
6+
request_timeout_ms: 60000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
set -x
2+
# the commands in this file map to steps in this notebook: https://aka.ms/azureml-infer-online-sdk-fill-mask
3+
# the sample scoring file available in the same folder as the above notebook
4+
5+
# script inputs
6+
registry_name="azureml"
7+
subscription_id="<SUBSCRIPTION_ID>"
8+
resource_group_name="<RESOURCE_GROUP>"
9+
workspace_name="<WORKSPACE_NAME>"
10+
11+
# This is the model from system registry that needs to be deployed
12+
model_name="bert-base-uncased"
13+
14+
# Validate the existence of the model in the registry and get the latest version
15+
model_list=$(az ml model list --name ${model_name} --registry-name ${registry_name} 2>&1)
16+
if [[ ${model_list} == *"[]"* ]]; then
17+
echo "Model doesn't exist in registry. Check the model list and try again."; exit 1;
18+
fi
19+
version_temp=${model_list#*\"version\": \"}
20+
model_version=${version_temp%%\"*}
21+
22+
version=$(date +%s)
23+
endpoint_name="fill-mask-$version"
24+
25+
# todo: fetch deployment_sku from the min_inference_sku tag of the model
26+
deployment_sku="Standard_DS2_v2"
27+
28+
# scoring_file
29+
scoring_file="../../../../../sdk/python/foundation-models/system/inference/fill-mask/book-corpus-dataset/sample_score.json"
30+
31+
# 1. Setup pre-requisites
32+
if [ "$subscription_id" = "<SUBSCRIPTION_ID>" ] || \
33+
["$resource_group_name" = "<RESOURCE_GROUP>" ] || \
34+
[ "$workspace_name" = "<WORKSPACE_NAME>" ]; then
35+
echo "Please update the script with the subscription_id, resource_group_name and workspace_name"
36+
exit 1
37+
fi
38+
39+
az account set -s $subscription_id
40+
workspace_info="--resource-group $resource_group_name --workspace-name $workspace_name"
41+
42+
# 2. Check if the model exists in the registry
43+
# need to confirm model show command works for registries outside the tenant (aka system registry)
44+
if ! az ml model show --name $model_name --version $model_version --registry-name $registry_name
45+
then
46+
echo "Model $model_name:$model_version does not exist in registry $registry_name"
47+
exit 1
48+
fi
49+
50+
# 3. Deploy the model to an endpoint
51+
# create online endpoint
52+
az ml online-endpoint create --name $endpoint_name $workspace_info || {
53+
echo "endpoint create failed"; exit 1;
54+
}
55+
56+
# deploy model from registry to endpoint in workspace
57+
az ml online-deployment create --file deploy.yml $workspace_info --all-traffic --set \
58+
endpoint_name=$endpoint_name model=azureml://registries/$registry_name/models/$model_name/versions/$model_version \
59+
instance_type=$deployment_sku || {
60+
echo "deployment create failed"; exit 1;
61+
}
62+
63+
# 4. Try a sample scoring request
64+
65+
# Check if scoring data file exists
66+
if [ -f $scoring_file ]; then
67+
echo "Invoking endpoint $endpoint_name with following input:\n\n"
68+
cat $scoring_file
69+
echo "\n\n"
70+
else
71+
echo "Scoring file $scoring_file does not exist"
72+
exit 1
73+
fi
74+
75+
az ml online-endpoint invoke --name $endpoint_name --request-file $scoring_file $workspace_info || {
76+
echo "endpoint invoke failed"; exit 1;
77+
}
78+
79+
# 6. Delete the endpoint
80+
az ml online-endpoint delete --name $endpoint_name $workspace_info --yes || {
81+
echo "endpoint delete failed"; exit 1;
82+
}
83+
84+
85+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json
2+
name: demo
3+
instance_type: Standard_DS3_v2
4+
instance_count: 1
5+
request_settings:
6+
request_timeout_ms: 60000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
set -x
2+
# the commands in this file map to steps in this notebook: https://aka.ms/azureml-infer-online-sdk-question-answering
3+
# the sample scoring file available in the same folder as the above notebook
4+
5+
# script inputs
6+
registry_name="azureml"
7+
subscription_id="<SUBSCRIPTION_ID>"
8+
resource_group_name="<RESOURCE_GROUP>"
9+
workspace_name="<WORKSPACE_NAME>"
10+
11+
# This is the model from system registry that needs to be deployed
12+
model_name="deepset-minilm-uncased-squad2"
13+
14+
# Validate the existence of the model in the registry and get the latest version
15+
model_list=$(az ml model list --name ${model_name} --registry-name ${registry_name} 2>&1)
16+
if [[ ${model_list} == *"[]"* ]]; then
17+
echo "Model doesn't exist in registry. Check the model list and try again."; exit 1;
18+
fi
19+
version_temp=${model_list#*\"version\": \"}
20+
model_version=${version_temp%%\"*}
21+
22+
version=$(date +%s)
23+
endpoint_name="question-answering-$version"
24+
25+
# todo: fetch deployment_sku from the min_inference_sku tag of the model
26+
deployment_sku="Standard_DS2_v2"
27+
28+
# scoring_file
29+
scoring_file="../../../../../sdk/python/foundation-models/system/inference/question-answering/squad-dataset/sample_score.json"
30+
31+
# 1. Setup pre-requisites
32+
if [ "$subscription_id" = "<SUBSCRIPTION_ID>" ] || \
33+
["$resource_group_name" = "<RESOURCE_GROUP>" ] || \
34+
[ "$workspace_name" = "<WORKSPACE_NAME>" ]; then
35+
echo "Please update the script with the subscription_id, resource_group_name and workspace_name"
36+
exit 1
37+
fi
38+
39+
az account set -s $subscription_id
40+
workspace_info="--resource-group $resource_group_name --workspace-name $workspace_name"
41+
42+
# 2. Check if the model exists in the registry
43+
# need to confirm model show command works for registries outside the tenant (aka system registry)
44+
if ! az ml model show --name $model_name --version $model_version --registry-name $registry_name
45+
then
46+
echo "Model $model_name:$model_version does not exist in registry $registry_name"
47+
exit 1
48+
fi
49+
50+
# 3. Deploy the model to an endpoint
51+
# create online endpoint
52+
az ml online-endpoint create --name $endpoint_name $workspace_info || {
53+
echo "endpoint create failed"; exit 1;
54+
}
55+
56+
# deploy model from registry to endpoint in workspace
57+
az ml online-deployment create --file deploy.yml $workspace_info --all-traffic --set \
58+
endpoint_name=$endpoint_name model=azureml://registries/$registry_name/models/$model_name/versions/$model_version \
59+
instance_type=$deployment_sku || {
60+
echo "deployment create failed"; exit 1;
61+
}
62+
63+
# 4. Try a sample scoring request
64+
65+
# Check if scoring data file exists
66+
if [ -f $scoring_file ]; then
67+
echo "Invoking endpoint $endpoint_name with following input:\n\n"
68+
cat $scoring_file
69+
echo "\n\n"
70+
else
71+
echo "Scoring file $scoring_file does not exist"
72+
exit 1
73+
fi
74+
75+
az ml online-endpoint invoke --name $endpoint_name --request-file $scoring_file $workspace_info || {
76+
echo "endpoint invoke failed"; exit 1;
77+
}
78+
79+
# 6. Delete the endpoint
80+
az ml online-endpoint delete --name $endpoint_name $workspace_info --yes || {
81+
echo "endpoint delete failed"; exit 1;
82+
}
83+
84+
85+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json
2+
name: demo
3+
instance_type: Standard_DS3_v2
4+
instance_count: 1
5+
request_settings:
6+
request_timeout_ms: 60000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
set -x
2+
# the commands in this file map to steps in this notebook: https://aka.ms/azureml-infer-online-sdk-summarization
3+
# the sample scoring file available in the same folder as the above notebook
4+
5+
# script inputs
6+
registry_name="azureml"
7+
subscription_id="<SUBSCRIPTION_ID>"
8+
resource_group_name="<RESOURCE_GROUP>"
9+
workspace_name="<WORKSPACE_NAME>"
10+
11+
# This is the model from system registry that needs to be deployed
12+
model_name="sshleifer-distilbart-cnn-12-6"
13+
14+
# Validate the existence of the model in the registry and get the latest version
15+
model_list=$(az ml model list --name ${model_name} --registry-name ${registry_name} 2>&1)
16+
if [[ ${model_list} == *"[]"* ]]; then
17+
echo "Model doesn't exist in registry. Check the model list and try again."; exit 1;
18+
fi
19+
version_temp=${model_list#*\"version\": \"}
20+
model_version=${version_temp%%\"*}
21+
22+
version=$(date +%s)
23+
endpoint_name="summarization-$version"
24+
25+
# todo: fetch deployment_sku from the min_inference_sku tag of the model
26+
deployment_sku="Standard_DS3_v2"
27+
28+
# scoring_file
29+
scoring_file="../../../../../sdk/python/foundation-models/system/inference/summarization/news-summary-dataset/sample_score.json"
30+
31+
# 1. Setup pre-requisites
32+
if [ "$subscription_id" = "<SUBSCRIPTION_ID>" ] || \
33+
["$resource_group_name" = "<RESOURCE_GROUP>" ] || \
34+
[ "$workspace_name" = "<WORKSPACE_NAME>" ]; then
35+
echo "Please update the script with the subscription_id, resource_group_name and workspace_name"
36+
exit 1
37+
fi
38+
39+
az account set -s $subscription_id
40+
workspace_info="--resource-group $resource_group_name --workspace-name $workspace_name"
41+
42+
# 2. Check if the model exists in the registry
43+
# need to confirm model show command works for registries outside the tenant (aka system registry)
44+
if ! az ml model show --name $model_name --version $model_version --registry-name $registry_name
45+
then
46+
echo "Model $model_name:$model_version does not exist in registry $registry_name"
47+
exit 1
48+
fi
49+
50+
# 3. Deploy the model to an endpoint
51+
# create online endpoint
52+
az ml online-endpoint create --name $endpoint_name $workspace_info || {
53+
echo "endpoint create failed"; exit 1;
54+
}
55+
56+
# deploy model from registry to endpoint in workspace
57+
az ml online-deployment create --file deploy.yml $workspace_info --all-traffic --set \
58+
endpoint_name=$endpoint_name model=azureml://registries/$registry_name/models/$model_name/versions/$model_version \
59+
instance_type=$deployment_sku || {
60+
echo "deployment create failed"; exit 1;
61+
}
62+
63+
# 4. Try a sample scoring request
64+
65+
# Check if scoring data file exists
66+
if [ -f $scoring_file ]; then
67+
echo "Invoking endpoint $endpoint_name with following input:\n\n"
68+
cat $scoring_file
69+
echo "\n\n"
70+
else
71+
echo "Scoring file $scoring_file does not exist"
72+
exit 1
73+
fi
74+
75+
az ml online-endpoint invoke --name $endpoint_name --request-file $scoring_file $workspace_info || {
76+
echo "endpoint invoke failed"; exit 1;
77+
}
78+
79+
# 6. Delete the endpoint
80+
az ml online-endpoint delete --name $endpoint_name $workspace_info --yes || {
81+
echo "endpoint delete failed"; exit 1;
82+
}
83+
84+
85+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json
2+
name: demo
3+
instance_type: Standard_DS3_v2
4+
instance_count: 1
5+
request_settings:
6+
request_timeout_ms: 60000

0 commit comments

Comments
 (0)