diff --git a/docs/quota_check.md b/docs/quota_check.md index 6647943c..8ce292da 100644 --- a/docs/quota_check.md +++ b/docs/quota_check.md @@ -1,6 +1,9 @@ ## Check Quota Availability Before Deployment -Before deploying the accelerator, **ensure sufficient quota availability** for the required model. +Before deploying the accelerator, **ensure sufficient quota availability** for the required model. +> **For Global Standard | GPT-4o - the capacity to at least 150k tokens post-deployment for optimal performance.** + +> **For Standard | GPT-4 - ensure a minimum of 30k–40k tokens for best results.** ### Login if you have not done so already ``` @@ -21,27 +24,34 @@ eastus, uksouth, eastus2, northcentralus, swedencentral, westus, westus2, southc - Only model(s) provided → The script will check for those models in the default regions. - Only region(s) provided → The script will check default models in the specified regions. - Both models and regions provided → The script will check those models in the specified regions. +- `--verbose` passed → Enables detailed logging output for debugging and traceability. ### **Input Formats** -✔️ Run without parameters to check default models & regions: +> Use the --models, --regions, and --verbose options for parameter handling: + +✔️ Run without parameters to check default models & regions without verbose logging: ``` ./quota_check_params.sh ``` -✔️ Model name and required capacity in the format: +✔️ Enable verbose logging: + ``` + ./quota_check_params.sh --verbose + ``` +✔️ Check specific model(s) in default regions: ``` - ./quota_check_params.sh gpt-4o:30 + ./quota_check_params.sh --models gpt-4o:30,text-embedding-ada-002:80 ``` -✔️ Multiple models can be passed, separated by commas: +✔️ Check default models in specific region(s): ``` - ./quota_check_params.sh gpt-4o:30,text-embedding-ada-002:80 +./quota_check_params.sh --regions eastus,westus ``` ✔️ Passing Both models and regions: ``` - ./quota_check_params.sh gpt-4o:30 eastus,westus2 + ./quota_check_params.sh --models gpt-4o:30 --regions eastus,westus2 ``` -✔️ Check default models in specific regions: +✔️ All parameters combined: ``` - ./quota_check_params.sh "" eastus,westus2 + ./quota_check_params.sh --models gpt-4:30,text-embedding-ada-002:80 --regions eastus,westus --verbose ``` ### **Sample Output** diff --git a/scripts/quota_check_params.sh b/scripts/quota_check_params.sh index 1c0e97a2..c62ec7e2 100644 --- a/scripts/quota_check_params.sh +++ b/scripts/quota_check_params.sh @@ -1,4 +1,50 @@ #!/bin/bash +# VERBOSE=false + +MODELS="" +REGIONS="" +VERBOSE=false + +while [[ $# -gt 0 ]]; do + case "$1" in + --models) + MODELS="$2" + shift 2 + ;; + --regions) + REGIONS="$2" + shift 2 + ;; + --verbose) + VERBOSE=true + shift + ;; + *) + echo "Unknown option: $1" + exit 1 + ;; + esac +done + +# Fallback to defaults if not provided +[[ -z "$MODELS" ]] +[[ -z "$REGIONS" ]] + +echo "Models: $MODELS" +echo "Regions: $REGIONS" +echo "Verbose: $VERBOSE" + +for arg in "$@"; do + if [ "$arg" = "--verbose" ]; then + VERBOSE=true + fi +done + +log_verbose() { + if [ "$VERBOSE" = true ]; then + echo "$1" + fi +} # Default Models and Capacities (Comma-separated in "model:capacity" format) DEFAULT_MODEL_CAPACITY="gpt-4o:30,text-embedding-ada-002:80,gpt-4:30" @@ -41,6 +87,7 @@ else done fi + # Set the selected subscription az account set --subscription "$AZURE_SUBSCRIPTION_ID" echo "🎯 Active Subscription: $(az account show --query '[name, id]' --output tsv)" @@ -50,8 +97,8 @@ DEFAULT_REGIONS="eastus,uksouth,eastus2,northcentralus,swedencentral,westus,west IFS=',' read -r -a DEFAULT_REGION_ARRAY <<< "$DEFAULT_REGIONS" # Read parameters (if any) -IFS=',' read -r -a USER_PROVIDED_PAIRS <<< "$1" -USER_REGION="$2" +IFS=',' read -r -a USER_PROVIDED_PAIRS <<< "$MODELS" +USER_REGION="$REGIONS" IS_USER_PROVIDED_PAIRS=false @@ -99,12 +146,12 @@ INDEX=1 VALID_REGIONS=() for REGION in "${REGIONS[@]}"; do - echo "----------------------------------------" - echo "🔍 Checking region: $REGION" + log_verbose "----------------------------------------" + log_verbose "🔍 Checking region: $REGION" QUOTA_INFO=$(az cognitiveservices usage list --location "$REGION" --output json | tr '[:upper:]' '[:lower:]') if [ -z "$QUOTA_INFO" ]; then - echo "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping." + log_verbose "⚠️ WARNING: Failed to retrieve quota for region $REGION. Skipping." continue fi @@ -127,7 +174,7 @@ for REGION in "${REGIONS[@]}"; do for MODEL_TYPE in "${MODEL_TYPES[@]}"; do FOUND=false INSUFFICIENT_QUOTA=false - echo "🔍 Checking model: $MODEL_NAME with required capacity: $REQUIRED_CAPACITY ($MODEL_TYPE)" + log_verbose "🔍 Checking model: $MODEL_NAME with required capacity: $REQUIRED_CAPACITY ($MODEL_TYPE)" MODEL_INFO=$(echo "$QUOTA_INFO" | awk -v model="\"value\": \"$MODEL_TYPE\"" ' BEGIN { RS="},"; FS="," } @@ -136,7 +183,7 @@ for REGION in "${REGIONS[@]}"; do if [ -z "$MODEL_INFO" ]; then FOUND=false - echo "⚠️ WARNING: No quota information found for model: $MODEL_NAME in region: $REGION for model type: $MODEL_TYPE." + log_verbose "⚠️ WARNING: No quota information found for model: $MODEL_NAME in region: $REGION for model type: $MODEL_TYPE." continue fi @@ -152,7 +199,7 @@ for REGION in "${REGIONS[@]}"; do LIMIT=$(echo "$LIMIT" | cut -d'.' -f1) AVAILABLE=$((LIMIT - CURRENT_VALUE)) - echo "✅ Model: $MODEL_TYPE | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE" + log_verbose "✅ Model: $MODEL_TYPE | Used: $CURRENT_VALUE | Limit: $LIMIT | Available: $AVAILABLE" if [ "$AVAILABLE" -ge "$REQUIRED_CAPACITY" ]; then FOUND=true @@ -160,16 +207,17 @@ for REGION in "${REGIONS[@]}"; do TEXT_EMBEDDING_AVAILABLE=true fi AT_LEAST_ONE_MODEL_AVAILABLE=true - TEMP_TABLE_ROWS+=("$(printf "| %-4s | %-20s | %-45s | %-10s | %-10s | %-10s |" "$INDEX" "$REGION" "$MODEL_TYPE" "$LIMIT" "$CURRENT_VALUE" "$AVAILABLE")") + TEMP_TABLE_ROWS+=("$(printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |" "$INDEX" "$REGION" "$MODEL_TYPE" "$LIMIT" "$CURRENT_VALUE" "$AVAILABLE")") else INSUFFICIENT_QUOTA=true fi fi if [ "$FOUND" = false ]; then - echo "❌ No models found for model: $MODEL_NAME in region: $REGION (${MODEL_TYPES[*]})" + log_verbose "❌ No models found for model: $MODEL_NAME in region: $REGION (${MODEL_TYPES[*]})" + elif [ "$INSUFFICIENT_QUOTA" = true ]; then - echo "⚠️ Model $MODEL_NAME in region: $REGION has insufficient quota (${MODEL_TYPES[*]})." + log_verbose "⚠️ Model $MODEL_NAME in region: $REGION has insufficient quota (${MODEL_TYPES[*]})." fi done done @@ -185,18 +233,18 @@ if { [ "$IS_USER_PROVIDED_PAIRS" = true ] && [ "$INSUFFICIENT_QUOTA" = false ] & done if [ ${#TABLE_ROWS[@]} -eq 0 ]; then - echo "------------------------------------------------------------------------------------------------------------------" + echo "--------------------------------------------------------------------------------------------------------------------" echo "❌ No regions have sufficient quota for all required models. Please request a quota increase: https://aka.ms/oai/stuquotarequest" else - echo "----------------------------------------------------------------------------------------------------------------------" - printf "| %-4s | %-20s | %-45s | %-10s | %-10s | %-10s |\n" "No." "Region" "Model Name" "Limit" "Used" "Available" - echo "----------------------------------------------------------------------------------------------------------------------" + echo "---------------------------------------------------------------------------------------------------------------------" + printf "| %-4s | %-20s | %-43s | %-10s | %-10s | %-10s |\n" "No." "Region" "Model Name" "Limit" "Used" "Available" + echo "---------------------------------------------------------------------------------------------------------------------" for ROW in "${TABLE_ROWS[@]}"; do echo "$ROW" done - echo "----------------------------------------------------------------------------------------------------------------------" + echo "---------------------------------------------------------------------------------------------------------------------" echo "➡️ To request a quota increase, visit: https://aka.ms/oai/stuquotarequest" fi -echo "✅ Script completed." +echo "✅ Script completed." \ No newline at end of file