Skip to content

Commit 3233da8

Browse files
Replace standard with globalstandard and updated quota check document
1 parent 4c92ba7 commit 3233da8

File tree

3 files changed

+30
-61
lines changed

3 files changed

+30
-61
lines changed

docs/quota_check.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,16 @@ The final table lists regions with available quota. You can select any of these
6363
1. Open the terminal in VS Code or Codespaces.
6464
2. If you're using VS Code, click the dropdown on the right side of the terminal window, and select `Git Bash`.
6565
![git_bash](images/git_bash.png)
66-
3. Navigate to the `scripts` folder where the script files are located and make the script as executable:
66+
3. Log in to your Azure account (if not already logged in):
67+
```sh
68+
az login
69+
```
70+
4. Navigate to the `scripts` folder where the script files are located and make the script as executable:
6771
```sh
6872
cd infra/scripts
6973
chmod +x quota_check_params.sh
7074
```
71-
4. Run the appropriate script based on your requirement:
75+
5. Run the appropriate script based on your requirement:
7276
7377
**To check quota for the deployment**
7478
@@ -77,10 +81,10 @@ The final table lists regions with available quota. You can select any of these
7781
```
7882
- Refer to [Input Formats](#input-formats) for detailed commands.
7983
80-
5. If you see the error `_bash: az: command not found_`, install Azure CLI:
84+
6. If you see the error `_bash: az: command not found_`, install Azure CLI:
8185
8286
```sh
8387
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
8488
az login
8589
```
86-
6. Rerun the script after installing Azure CLI.
90+
7. Rerun the script after installing Azure CLI.

infra/scripts/checkquota_km.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ echo "✅ Azure subscription set successfully."
3232

3333
# Define models and their minimum required capacities
3434
declare -A MIN_CAPACITY=(
35-
["OpenAI.Standard.gpt-4o-mini"]=$GPT_MIN_CAPACITY #km generic
36-
["OpenAI.Standard.text-embedding-ada-002"]=$TEXT_EMBEDDING_MIN_CAPACITY #km generic
35+
["OpenAI.GlobalStandard.gpt-4o-mini"]=$GPT_MIN_CAPACITY #km generic
36+
["OpenAI.GlobalStandard.text-embedding-ada-002"]=$TEXT_EMBEDDING_MIN_CAPACITY #km generic
3737
)
3838

3939
VALID_REGION=""

infra/scripts/quota_check_params.sh

Lines changed: 20 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,21 @@ echo "✅ Retrieved Azure regions. Checking availability..."
9999
INDEX=1
100100

101101
VALID_REGIONS=()
102-
for REGION in "${REGIONS[@]}"; do
103-
echo "----------------------------------------"
104-
echo "🔍 Checking region: $REGION"
102+
TABLE_ROWS=()
105103

104+
for REGION in "${REGIONS[@]}"; do
106105
QUOTA_INFO=$(az cognitiveservices usage list --location "$REGION" --output json | tr '[:upper:]' '[:lower:]')
107106
if [ -z "$QUOTA_INFO" ]; then
108-
echo "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping."
109107
continue
110108
fi
111109

110+
TEMP_TABLE_ROWS=()
112111
TEXT_EMBEDDING_AVAILABLE=false
113112
AT_LEAST_ONE_MODEL_AVAILABLE=false
114-
TEMP_TABLE_ROWS=()
115113

116114
for index in "${!FINAL_MODEL_NAMES[@]}"; do
117115
MODEL_NAME="${FINAL_MODEL_NAMES[$index]}"
118116
REQUIRED_CAPACITY="${FINAL_CAPACITIES[$index]}"
119-
FOUND=false
120-
INSUFFICIENT_QUOTA=false
121117

122118
if [ "$MODEL_NAME" = "text-embedding-ada-002" ]; then
123119
MODEL_TYPES=("openai.standard.$MODEL_NAME")
@@ -126,65 +122,34 @@ for REGION in "${REGIONS[@]}"; do
126122
fi
127123

128124
for MODEL_TYPE in "${MODEL_TYPES[@]}"; do
129-
FOUND=false
130-
INSUFFICIENT_QUOTA=false
131-
echo "🔍 Checking model: $MODEL_NAME with required capacity: $REQUIRED_CAPACITY ($MODEL_TYPE)"
132-
133-
MODEL_INFO=$(echo "$QUOTA_INFO" | awk -v model="\"value\": \"$MODEL_TYPE\"" '
134-
BEGIN { RS="},"; FS="," }
135-
$0 ~ model { print $0 }
136-
')
137-
138-
if [ -z "$MODEL_INFO" ]; then
139-
FOUND=false
140-
echo "⚠️ WARNING: No quota information found for model: $MODEL_NAME in region: $REGION for model type: $MODEL_TYPE."
141-
continue
142-
fi
125+
MODEL_INFO=$(echo "$QUOTA_INFO" | awk -v model="\"value\": \"$MODEL_TYPE\"" 'BEGIN { RS="},"; FS="," } $0 ~ model { print $0 }')
126+
if [ -z "$MODEL_INFO" ]; then continue; fi
143127

144-
if [ -n "$MODEL_INFO" ]; then
145-
FOUND=true
146-
CURRENT_VALUE=$(echo "$MODEL_INFO" | awk -F': ' '/"currentvalue"/ {print $2}' | tr -d ',' | tr -d ' ')
147-
LIMIT=$(echo "$MODEL_INFO" | awk -F': ' '/"limit"/ {print $2}' | tr -d ',' | tr -d ' ')
148-
149-
CURRENT_VALUE=${CURRENT_VALUE:-0}
150-
LIMIT=${LIMIT:-0}
151-
152-
CURRENT_VALUE=$(echo "$CURRENT_VALUE" | cut -d'.' -f1)
153-
LIMIT=$(echo "$LIMIT" | cut -d'.' -f1)
154-
155-
AVAILABLE=$((LIMIT - CURRENT_VALUE))
156-
echo "✅ Model: $MODEL_TYPE | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE"
157-
158-
if [ "$AVAILABLE" -ge "$REQUIRED_CAPACITY" ]; then
159-
FOUND=true
160-
if [ "$MODEL_NAME" = "text-embedding-ada-002" ]; then
161-
TEXT_EMBEDDING_AVAILABLE=true
162-
fi
163-
AT_LEAST_ONE_MODEL_AVAILABLE=true
164-
TEMP_TABLE_ROWS+=("$(printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |" "$INDEX" "$REGION" "$MODEL_TYPE" "$LIMIT" "$CURRENT_VALUE" "$AVAILABLE")")
165-
else
166-
INSUFFICIENT_QUOTA=true
128+
CURRENT_VALUE=$(echo "$MODEL_INFO" | awk -F': ' '/"currentvalue"/ {print $2}' | tr -d ', ' | cut -d'.' -f1)
129+
LIMIT=$(echo "$MODEL_INFO" | awk -F': ' '/"limit"/ {print $2}' | tr -d ', ' | cut -d'.' -f1)
130+
131+
CURRENT_VALUE=${CURRENT_VALUE:-0}
132+
LIMIT=${LIMIT:-0}
133+
AVAILABLE=$((LIMIT - CURRENT_VALUE))
134+
135+
if [ "$AVAILABLE" -ge "$REQUIRED_CAPACITY" ]; then
136+
if [ "$MODEL_NAME" = "text-embedding-ada-002" ]; then
137+
TEXT_EMBEDDING_AVAILABLE=true
167138
fi
168-
fi
169-
170-
if [ "$FOUND" = false ]; then
171-
echo "❌ No models found for model: $MODEL_NAME in region: $REGION (${MODEL_TYPES[*]})"
172-
elif [ "$INSUFFICIENT_QUOTA" = true ]; then
173-
echo "⚠️ Model $MODEL_NAME in region: $REGION has insufficient quota (${MODEL_TYPES[*]})."
139+
AT_LEAST_ONE_MODEL_AVAILABLE=true
140+
TEMP_TABLE_ROWS+=("$(printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |" "$INDEX" "$REGION" "$MODEL_TYPE" "$LIMIT" "$CURRENT_VALUE" "$AVAILABLE")")
174141
fi
175142
done
176143
done
177144

178-
if { [ "$IS_USER_PROVIDED_PAIRS" = true ] && [ "$INSUFFICIENT_QUOTA" = false ] && [ "$FOUND" = true ]; } || { [ "$TEXT_EMBEDDING_AVAILABLE" = true ] && { [ "$APPLY_OR_CONDITION" != true ] || [ "$AT_LEAST_ONE_MODEL_AVAILABLE" = true ]; }; }; then
145+
if { [ "$IS_USER_PROVIDED_PAIRS" = true ] && [ "$INSUFFICIENT_QUOTA" = false ]; } ||
146+
{ [ "$TEXT_EMBEDDING_AVAILABLE" = true ] && { [ "$APPLY_OR_CONDITION" != true ] || [ "$AT_LEAST_ONE_MODEL_AVAILABLE" = true ]; }; }; then
179147
VALID_REGIONS+=("$REGION")
180148
TABLE_ROWS+=("${TEMP_TABLE_ROWS[@]}")
181-
INDEX=$((INDEX + 1))
182-
elif [ ${#USER_PROVIDED_PAIRS[@]} -eq 0 ]; then
183-
echo "🚫 Skipping $REGION as it does not meet quota requirements."
184149
fi
185-
186150
done
187151

152+
188153
if [ ${#TABLE_ROWS[@]} -eq 0 ]; then
189154
echo "--------------------------------------------------------------------------------------------------------------------"
190155

0 commit comments

Comments
 (0)