From 28f100fb5751894ec5d38900061d48a946972a11 Mon Sep 17 00:00:00 2001 From: "Priyanka Singhal (Persistent Systems Inc)" Date: Fri, 11 Apr 2025 20:11:25 +0530 Subject: [PATCH 1/4] Added the and parameters for dynamic model and region selection. - Integrated a flag to enable detailed logging for easier troubleshooting. --- infra/scripts/quota_check_params.sh | 81 +++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/infra/scripts/quota_check_params.sh b/infra/scripts/quota_check_params.sh index c6f1a16e..29e8981a 100644 --- a/infra/scripts/quota_check_params.sh +++ b/infra/scripts/quota_check_params.sh @@ -1,8 +1,53 @@ #!/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" - # Convert the comma-separated string into an array IFS=',' read -r -a MODEL_CAPACITY_PAIRS <<< "$DEFAULT_MODEL_CAPACITY" @@ -41,6 +86,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 +96,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 +145,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 +173,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 +182,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 +198,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 +206,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,17 +232,17 @@ 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 From 5161418e6ce01d2462ee396d0c923bf9e821ece0 Mon Sep 17 00:00:00 2001 From: "Priyanka Singhal (Persistent Systems Inc)" Date: Mon, 14 Apr 2025 17:20:59 +0530 Subject: [PATCH 2/4] updated Readme --- docs/quota_check.md | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/docs/quota_check.md b/docs/quota_check.md index c0a2ef5e..a9885457 100644 --- a/docs/quota_check.md +++ b/docs/quota_check.md @@ -1,12 +1,16 @@ ## 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 ``` azd auth login ``` + ### 📌 Default Models & Capacities: ``` gpt-4o:30 @@ -20,33 +24,40 @@ 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 ``` -✔️ 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 --regions eastus,westus --verbose ``` ### **Sample Output** The final table lists regions with available quota. You can select any of these regions for deployment. -![quota-check-ouput](Images/quota-check-output.png) +![quota-check-ouput](images/quota-check-output.png) --- ### **If using Azure Portal and Cloud Shell** @@ -67,7 +78,7 @@ The final table lists regions with available quota. You can select any of these ### **If using VS Code or Codespaces** 1. Open the terminal in VS Code or Codespaces. 2. If you're using VS Code, click the dropdown on the right side of the terminal window, and select `Git Bash`. - ![git_bash](Images/git_bash.png) + ![git_bash](images/git_bash.png) 3. Navigate to the `scripts` folder where the script files are located and make the script as executable: ```sh cd infra/scripts From e178a300fc3c51e44aafbae23d8e3e9e19223f73 Mon Sep 17 00:00:00 2001 From: "Priyanka Singhal (Persistent Systems Inc)" Date: Mon, 14 Apr 2025 19:58:25 +0530 Subject: [PATCH 3/4] updated Readme --- docs/quota_check.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/quota_check.md b/docs/quota_check.md index a9885457..688f5f71 100644 --- a/docs/quota_check.md +++ b/docs/quota_check.md @@ -57,7 +57,7 @@ eastus, uksouth, eastus2, northcentralus, swedencentral, westus, westus2, southc ### **Sample Output** The final table lists regions with available quota. You can select any of these regions for deployment. -![quota-check-ouput](images/quota-check-output.png) +![quota-check-ouput](Images/quota-check-output.png) --- ### **If using Azure Portal and Cloud Shell** @@ -78,7 +78,7 @@ The final table lists regions with available quota. You can select any of these ### **If using VS Code or Codespaces** 1. Open the terminal in VS Code or Codespaces. 2. If you're using VS Code, click the dropdown on the right side of the terminal window, and select `Git Bash`. - ![git_bash](images/git_bash.png) + ![git_bash](Images/git_bash.png) 3. Navigate to the `scripts` folder where the script files are located and make the script as executable: ```sh cd infra/scripts From dcfbaab24b114072385cdd00cbb2ca11f0eb65da Mon Sep 17 00:00:00 2001 From: Roopan-Microsoft <168007406+Roopan-Microsoft@users.noreply.github.com> Date: Mon, 14 Apr 2025 23:16:03 +0530 Subject: [PATCH 4/4] Update quota_check.md --- docs/quota_check.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/quota_check.md b/docs/quota_check.md index 688f5f71..d79fe42b 100644 --- a/docs/quota_check.md +++ b/docs/quota_check.md @@ -1,9 +1,7 @@ ## Check Quota Availability Before Deployment 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.** +> **For Global Standard | GPT-4o - the capacity to at least 30K tokens for optimal performance.** ### Login if you have not done so already ``` @@ -99,4 +97,4 @@ The final table lists regions with available quota. You can select any of these curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash az login ``` -6. Rerun the script after installing Azure CLI. \ No newline at end of file +6. Rerun the script after installing Azure CLI.