-
Notifications
You must be signed in to change notification settings - Fork 522
Expand file tree
/
Copy pathvalidate_model_deployment_quota.sh
More file actions
88 lines (73 loc) · 2.41 KB
/
Copy pathvalidate_model_deployment_quota.sh
File metadata and controls
88 lines (73 loc) · 2.41 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
81
82
83
84
85
86
87
88
#!/bin/bash
SUBSCRIPTION_ID=""
LOCATION=""
MODELS_PARAMETER=""
while [[ $# -gt 0 ]]; do
case "$1" in
--subscription)
SUBSCRIPTION_ID="$2"
shift 2
;;
--location)
LOCATION="$2"
shift 2
;;
--models-parameter)
MODELS_PARAMETER="$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Verify all required parameters are provided and echo missing ones
MISSING_PARAMS=()
if [[ -z "$SUBSCRIPTION_ID" ]]; then
MISSING_PARAMS+=("subscription")
fi
if [[ -z "$LOCATION" ]]; then
MISSING_PARAMS+=("location")
fi
if [[ -z "$MODELS_PARAMETER" ]]; then
MISSING_PARAMS+=("models-parameter")
fi
if [[ ${#MISSING_PARAMS[@]} -ne 0 ]]; then
echo "❌ ERROR: Missing required parameters: ${MISSING_PARAMS[*]}"
echo "Usage: $0 --subscription <SUBSCRIPTION_ID> --location <LOCATION> --models-parameter <MODELS_PARAMETER>"
exit 1
fi
aiModelDeployments=$(jq -c ".parameters.$MODELS_PARAMETER.value[]" ./infra/main.parameters.json)
if [ $? -ne 0 ]; then
echo "Error: Failed to parse main.parameters.json. Ensure jq is installed and the JSON file is valid."
exit 1
fi
az account set --subscription "$SUBSCRIPTION_ID"
echo "🎯 Active Subscription: $(az account show --query '[name, id]' --output tsv)"
quotaAvailable=true
while IFS= read -r deployment; do
name=${AZURE_ENV_MODEL_NAME:-$(echo "$deployment" | jq -r '.name')}
model=${AZURE_ENV_MODEL_NAME:-$(echo "$deployment" | jq -r '.model.name')}
type=${AZURE_ENV_MODEL_DEPLOYMENT_TYPE:-$(echo "$deployment" | jq -r '.sku.name')}
capacity=${AZURE_ENV_MODEL_CAPACITY:-$(echo "$deployment" | jq -r '.sku.capacity')}
echo "🔍 Validating model deployment: $name ..."
./scripts/validate_model_quota.sh --location "$LOCATION" --model "$model" --capacity $capacity --deployment-type $type
# Check if the script failed
exit_code=$?
if [ $exit_code -ne 0 ]; then
if [ $exit_code -eq 2 ]; then
# Skip printing any quota validation error — already handled inside the validation script
exit 1
fi
echo "❌ ERROR: Quota validation failed for model deployment: $name"
quotaAvailable=false
fi
done <<< "$(echo "$aiModelDeployments")"
if [ "$quotaAvailable" = false ]; then
echo "❌ ERROR: One or more model deployments failed validation."
exit 1
else
echo "✅ All model deployments passed quota validation successfully."
exit 0
fi