Skip to content

Commit 144b8fd

Browse files
updated the function
1 parent 3b70968 commit 144b8fd

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

scripts/validate_model_quota.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CAPACITY=0
77
RECOMMENDED_TOKENS=200
88
TABLE_SHOWN=false
99
RECOMMENDATIONS_SHOWN=false
10+
INITIAL_LOCATION="" # NEW: track the original region
1011

1112
ALL_REGIONS=('australiaeast' 'eastus' 'eastus2' 'francecentral' 'japaneast' 'norwayeast' 'southindia' 'swedencentral' 'uksouth' 'westus' 'westus3')
1213

@@ -142,11 +143,12 @@ ask_for_location() {
142143
echo "✅ Proceeding with deployment in '$LOCATION'."
143144
exit 0
144145
else
145-
check_fallback_regions
146+
check_fallback_regions false
146147
fi
147148
}
148149

149150
check_fallback_regions() {
151+
local is_first_check="${1:-true}"
150152
for region in "${ALL_REGIONS[@]}"; do
151153
[[ "$region" == "$LOCATION" ]] && continue
152154
check_quota "$region" && FALLBACK_RESULTS+=("$region")
@@ -165,9 +167,15 @@ check_fallback_regions() {
165167
echo " - $region"
166168
done
167169
fi
168-
echo -e "\n❗ The originally selected region '$LOCATION' does not have enough quota."
169-
echo -e "👉 You can manually choose one of the recommended fallback regions for deployment."
170170
RECOMMENDATIONS_SHOWN=true
171+
if [[ "$is_first_check" == true ]]; then
172+
echo -e "\n❗ The originally selected region '$INITIAL_LOCATION' does not have enough quota."
173+
else
174+
echo -e "\n⚠️ Region '$LOCATION' does not have enough quota."
175+
RECOMMENDATIONS_SHOWN=false
176+
fi
177+
echo -e "👉 You can manually choose one of the recommended fallback regions for deployment."
178+
171179
else
172180
echo -e "\n❌ ERROR: No region has sufficient quota."
173181
fi
@@ -197,10 +205,12 @@ if [[ -z "$LOCATION" || -z "$MODEL" || -z "$CAPACITY" || "$CAPACITY" -le 0 ]]; t
197205
fi
198206

199207
# ---------- Start Process ----------
208+
INITIAL_LOCATION="$LOCATION" # Set initial region
209+
200210
echo -e "\n🔍 Checking quota in the requested region '$LOCATION'..."
201211
if check_quota "$LOCATION"; then
202212
if (( CAPACITY < RECOMMENDED_TOKENS )); then
203-
check_fallback_regions
213+
check_fallback_regions true
204214
print_recommended_warning "$CAPACITY"
205215
prompt_yes_no "❓ Proceed anyway? (y/n): " || {
206216
ask_for_location
@@ -214,5 +224,5 @@ else
214224
primary_entry="${ALL_RESULTS[0]}"
215225
IFS='|' read -r _ limit used available <<< "$primary_entry"
216226
echo "❌ Quota insufficient in '$LOCATION' (Available: $available, Required: $CAPACITY). Checking fallback regions..."
217-
check_fallback_regions
227+
check_fallback_regions true
218228
fi

0 commit comments

Comments
 (0)