From 2e39d3cfa7186306e8e64b430423b7fb9358a7c3 Mon Sep 17 00:00:00 2001 From: UtkarshMishra-Microsoft Date: Tue, 1 Apr 2025 19:49:31 +0530 Subject: [PATCH 1/4] Package azure-ai-ml updation with ai script --- .../Deployment/scripts/aihub_scripts/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResearchAssistant/Deployment/scripts/aihub_scripts/requirements.txt b/ResearchAssistant/Deployment/scripts/aihub_scripts/requirements.txt index f1930f44..98acb23a 100644 --- a/ResearchAssistant/Deployment/scripts/aihub_scripts/requirements.txt +++ b/ResearchAssistant/Deployment/scripts/aihub_scripts/requirements.txt @@ -1,7 +1,7 @@ azure-identity azure-keyvault-secrets azure-ai-resources -azure-ai-ml==1.24.0 +azure-ai-ml==1.26.1 msal[broker]==1.24.0b1 azure-mgmt-resource==23.1.0b2 azure-mgmt-cognitiveservices From 52b51d586de61fa51e8c66147f49310d7cb361f8 Mon Sep 17 00:00:00 2001 From: UtkarshMishra-Microsoft Date: Tue, 1 Apr 2025 20:10:08 +0530 Subject: [PATCH 2/4] ai_hub base version --- .../Deployment/scripts/aihub_scripts/create_ai_hub.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ResearchAssistant/Deployment/scripts/aihub_scripts/create_ai_hub.py b/ResearchAssistant/Deployment/scripts/aihub_scripts/create_ai_hub.py index cf0b8c3a..55d71b10 100644 --- a/ResearchAssistant/Deployment/scripts/aihub_scripts/create_ai_hub.py +++ b/ResearchAssistant/Deployment/scripts/aihub_scripts/create_ai_hub.py @@ -73,7 +73,7 @@ def get_secrets_from_kv(kv_name, secret_name): # construct a hub my_hub = Hub(name=aihub_name, location=solutionLocation, display_name=aihub_name) -created_hub = ml_client.workspaces.begin_create(my_hub).result() +created_hub = ml_client.workspaces.begin_create(my_hub) # construct the project my_project = Project( @@ -83,8 +83,8 @@ def get_secrets_from_kv(kv_name, secret_name): hub_id=created_hub.id, ) -created_project = ml_client.workspaces.begin_create(workspace=my_project).result() - +created_project = ml_client.workspaces.begin_create(workspace=my_project) + open_ai_connection = AzureOpenAIConnection( name="Azure_OpenAI", api_key=open_ai_key, From 970b3aaf48b6ab601f408c0c37cc7c415f270822 Mon Sep 17 00:00:00 2001 From: UtkarshMishra-Microsoft Date: Tue, 1 Apr 2025 20:12:54 +0530 Subject: [PATCH 3/4] ai-script --- .github/dependabot.yml | 18 ++--- .github/workflows/CAdeploy.yml | 1 + .github/workflows/RAdeploy.yml | 1 + .github/workflows/stale-bot.yml | 75 +++++++++++++++++-- .../Deployment/scripts/checkquota.sh | 4 +- .../scripts/aihub_scripts/create_ai_hub.py | 4 +- .../Deployment/scripts/checkquota.sh | 4 +- 7 files changed, 86 insertions(+), 21 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c5164136..525a33a3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,7 +8,7 @@ updates: commit-message: prefix: "build" target-branch: "dependabotchanges" - open-pull-requests-limit: 15 + open-pull-requests-limit: 100 - package-ecosystem: "npm" directory: "/ResearchAssistant/App/frontend" @@ -17,7 +17,7 @@ updates: commit-message: prefix: "build" target-branch: "dependabotchanges" - open-pull-requests-limit: 15 + open-pull-requests-limit: 100 # 2. Python dependencies - package-ecosystem: "pip" @@ -27,7 +27,7 @@ updates: commit-message: prefix: "build" target-branch: "dependabotchanges" - open-pull-requests-limit: 15 + open-pull-requests-limit: 100 - package-ecosystem: "pip" directory: "/ClientAdvisor/AzureFunction" @@ -36,7 +36,7 @@ updates: commit-message: prefix: "build" target-branch: "dependabotchanges" - open-pull-requests-limit: 15 + open-pull-requests-limit: 100 - package-ecosystem: "pip" directory: "/ClientAdvisor/Deployment/scripts/fabric_scripts" @@ -45,7 +45,7 @@ updates: commit-message: prefix: "build" target-branch: "dependabotchanges" - open-pull-requests-limit: 15 + open-pull-requests-limit: 100 - package-ecosystem: "pip" directory: "/ClientAdvisor/Deployment/scripts/index_scripts" @@ -54,7 +54,7 @@ updates: commit-message: prefix: "build" target-branch: "dependabotchanges" - open-pull-requests-limit: 15 + open-pull-requests-limit: 100 - package-ecosystem: "pip" directory: "/ResearchAssistant/App" @@ -63,7 +63,7 @@ updates: commit-message: prefix: "build" target-branch: "dependabotchanges" - open-pull-requests-limit: 15 + open-pull-requests-limit: 100 - package-ecosystem: "pip" directory: "/ResearchAssistant/Deployment/scripts/aihub_scripts" @@ -72,7 +72,7 @@ updates: commit-message: prefix: "build" target-branch: "dependabotchanges" - open-pull-requests-limit: 15 + open-pull-requests-limit: 100 - package-ecosystem: "pip" directory: "/ResearchAssistant/Deployment/scripts/fabric_scripts" @@ -81,7 +81,7 @@ updates: commit-message: prefix: "build" target-branch: "dependabotchanges" - open-pull-requests-limit: 15 + open-pull-requests-limit: 100 - package-ecosystem: "pip" directory: "/ResearchAssistant/Deployment/scripts/index_scripts" diff --git a/.github/workflows/CAdeploy.yml b/.github/workflows/CAdeploy.yml index c75b5406..9a94da77 100644 --- a/.github/workflows/CAdeploy.yml +++ b/.github/workflows/CAdeploy.yml @@ -26,6 +26,7 @@ jobs: export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}" export GPT_MIN_CAPACITY="11" export TEXT_EMBEDDING_MIN_CAPACITY="45" + export AZURE_REGIONS="${{ vars.AZURE_REGIONS_CA }}" chmod +x ClientAdvisor/Deployment/scripts/checkquota.sh if ! ClientAdvisor/Deployment/scripts/checkquota.sh; then diff --git a/.github/workflows/RAdeploy.yml b/.github/workflows/RAdeploy.yml index b7783827..76a6e73d 100644 --- a/.github/workflows/RAdeploy.yml +++ b/.github/workflows/RAdeploy.yml @@ -25,6 +25,7 @@ jobs: export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}" export GPT_MIN_CAPACITY="30" export TEXT_EMBEDDING_MIN_CAPACITY="45" + export AZURE_REGIONS="${{ vars.AZURE_REGIONS_RA }}" chmod +x ResearchAssistant/Deployment/scripts/checkquota.sh if ! ResearchAssistant/Deployment/scripts/checkquota.sh; then diff --git a/.github/workflows/stale-bot.yml b/.github/workflows/stale-bot.yml index b4e41fc4..c9157580 100644 --- a/.github/workflows/stale-bot.yml +++ b/.github/workflows/stale-bot.yml @@ -1,19 +1,82 @@ -name: 'Stale Bot' +name: "Manage Stale Issues, PRs & Unmerged Branches" on: schedule: - - cron: '30 1 * * *' - + - cron: '30 1 * * *' # Runs daily at 1:30 AM UTC + workflow_dispatch: # Allows manual triggering permissions: contents: write issues: write pull-requests: write - jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v9 + - name: Mark Stale Issues and PRs + uses: actions/stale@v9 with: - stale-issue-message: 'This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.' + stale-issue-message: "This issue is stale because it has been open 180 days with no activity. Remove stale label or comment, or it will be closed in 30 days." + stale-pr-message: "This PR is stale because it has been open 180 days with no activity. Please update or it will be closed in 30 days." days-before-stale: 180 days-before-close: 30 + exempt-issue-labels: "keep" + exempt-pr-labels: "keep" + cleanup-branches: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch full history for accurate branch checks + - name: Fetch All Branches + run: git fetch --all --prune + - name: List Merged Branches With No Activity in Last 3 Months + run: | + + echo "Branch Name,Last Commit Date,Committer,Committed In Branch,Action" > merged_branches_report.csv + + for branch in $(git for-each-ref --format '%(refname:short) %(committerdate:unix)' refs/remotes/origin | awk -v date=$(date -d '3 months ago' +%s) '$2 < date {print $1}'); do + if [[ "$branch" != "origin/main" && "$branch" != "origin/dev" ]]; then + branch_name=${branch#origin/} + # Ensure the branch exists locally before getting last commit date + git fetch origin "$branch_name" || echo "Could not fetch branch: $branch_name" + last_commit_date=$(git log -1 --format=%ci "origin/$branch_name" || echo "Unknown") + committer_name=$(git log -1 --format=%cn "origin/$branch_name" || echo "Unknown") + committed_in_branch=$(git branch -r --contains "origin/$branch_name" | tr -d ' ' | paste -sd "," -) + echo "$branch_name,$last_commit_date,$committer_name,$committed_in_branch,Delete" >> merged_branches_report.csv + fi + done + - name: List PR Approved and Merged Branches Older Than 30 Days + run: | + + for branch in $(gh api repos/${{ github.repository }}/pulls --jq '.[] | select(.merged_at != null and (.base.ref == "main" or .base.ref == "dev")) | select(.merged_at | fromdateiso8601 < (now - 2592000)) | .head.ref'); do + # Ensure the branch exists locally before getting last commit date + git fetch origin "$branch" || echo "Could not fetch branch: $branch" + last_commit_date=$(git log -1 --format=%ci origin/$branch || echo "Unknown") + committer_name=$(git log -1 --format=%cn origin/$branch || echo "Unknown") + committed_in_branch=$(git branch -r --contains "origin/$branch" | tr -d ' ' | paste -sd "," -) + echo "$branch,$last_commit_date,$committer_name,$committed_in_branch,Delete" >> merged_branches_report.csv + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: List Open PR Branches With No Activity in Last 3 Months + run: | + + for branch in $(gh api repos/${{ github.repository }}/pulls --state open --jq '.[] | select(.base.ref == "main" or .base.ref == "dev") | .head.ref'); do + # Ensure the branch exists locally before getting last commit date + git fetch origin "$branch" || echo "Could not fetch branch: $branch" + last_commit_date=$(git log -1 --format=%ci origin/$branch || echo "Unknown") + committer_name=$(git log -1 --format=%cn origin/$branch || echo "Unknown") + if [[ $(date -d "$last_commit_date" +%s) -lt $(date -d '3 months ago' +%s) ]]; then + # If no commit in the last 3 months, mark for deletion + committed_in_branch=$(git branch -r --contains "origin/$branch" | tr -d ' ' | paste -sd "," -) + echo "$branch,$last_commit_date,$committer_name,$committed_in_branch,Delete" >> merged_branches_report.csv + fi + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload CSV Report of Inactive Branches + uses: actions/upload-artifact@v4 + with: + name: merged-branches-report + path: merged_branches_report.csv + retention-days: 30 diff --git a/ClientAdvisor/Deployment/scripts/checkquota.sh b/ClientAdvisor/Deployment/scripts/checkquota.sh index fc0caeec..cad835e8 100644 --- a/ClientAdvisor/Deployment/scripts/checkquota.sh +++ b/ClientAdvisor/Deployment/scripts/checkquota.sh @@ -1,7 +1,7 @@ #!/bin/bash # List of Azure regions to check for quota (update as needed) -REGIONS=("eastus" "westus" "northcentralus" "uksouth" "swedencentral") +IFS=', ' read -ra REGIONS <<< "$AZURE_REGIONS" SUBSCRIPTION_ID="${AZURE_SUBSCRIPTION_ID}" GPT_MIN_CAPACITY="${GPT_MIN_CAPACITY}" @@ -18,7 +18,7 @@ if ! az login --service-principal -u "$AZURE_CLIENT_ID" -p "$AZURE_CLIENT_SECRET fi echo "🔄 Validating required environment variables..." -if [[ -z "$SUBSCRIPTION_ID" || -z "$GPT_MIN_CAPACITY" || -z "$TEXT_EMBEDDING_MIN_CAPACITY" ]]; then +if [[ -z "$SUBSCRIPTION_ID" || -z "$GPT_MIN_CAPACITY" || -z "$TEXT_EMBEDDING_MIN_CAPACITY" || -z "$REGIONS" ]]; then echo "❌ ERROR: Missing required environment variables." exit 1 fi diff --git a/ResearchAssistant/Deployment/scripts/aihub_scripts/create_ai_hub.py b/ResearchAssistant/Deployment/scripts/aihub_scripts/create_ai_hub.py index 55d71b10..e4d43490 100644 --- a/ResearchAssistant/Deployment/scripts/aihub_scripts/create_ai_hub.py +++ b/ResearchAssistant/Deployment/scripts/aihub_scripts/create_ai_hub.py @@ -73,7 +73,7 @@ def get_secrets_from_kv(kv_name, secret_name): # construct a hub my_hub = Hub(name=aihub_name, location=solutionLocation, display_name=aihub_name) -created_hub = ml_client.workspaces.begin_create(my_hub) +created_hub = ml_client.workspaces.begin_create(my_hub).result() # construct the project my_project = Project( @@ -83,7 +83,7 @@ def get_secrets_from_kv(kv_name, secret_name): hub_id=created_hub.id, ) -created_project = ml_client.workspaces.begin_create(workspace=my_project) +created_project = ml_client.workspaces.begin_create(workspace=my_project).result() open_ai_connection = AzureOpenAIConnection( name="Azure_OpenAI", diff --git a/ResearchAssistant/Deployment/scripts/checkquota.sh b/ResearchAssistant/Deployment/scripts/checkquota.sh index e1039ec5..18a1ca71 100644 --- a/ResearchAssistant/Deployment/scripts/checkquota.sh +++ b/ResearchAssistant/Deployment/scripts/checkquota.sh @@ -1,7 +1,7 @@ #!/bin/bash # List of Azure regions to check for quota (update as needed) -REGIONS=("eastus2" "westus" "northcentralus" "uksouth" "francecentral") +IFS=', ' read -ra REGIONS <<< "$AZURE_REGIONS" SUBSCRIPTION_ID="${AZURE_SUBSCRIPTION_ID}" GPT_MIN_CAPACITY="${GPT_MIN_CAPACITY}" @@ -18,7 +18,7 @@ if ! az login --service-principal -u "$AZURE_CLIENT_ID" -p "$AZURE_CLIENT_SECRET fi echo "🔄 Validating required environment variables..." -if [[ -z "$SUBSCRIPTION_ID" || -z "$GPT_MIN_CAPACITY" || -z "$TEXT_EMBEDDING_MIN_CAPACITY" ]]; then +if [[ -z "$SUBSCRIPTION_ID" || -z "$GPT_MIN_CAPACITY" || -z "$TEXT_EMBEDDING_MIN_CAPACITY" || -z "$REGIONS" ]]; then echo "❌ ERROR: Missing required environment variables." exit 1 fi From 4da685639ef3a39923ca701b85fda8707665900f Mon Sep 17 00:00:00 2001 From: UtkarshMishra-Microsoft Date: Tue, 1 Apr 2025 20:14:13 +0530 Subject: [PATCH 4/4] Delete .github/dependabot.yml --- .github/dependabot.yml | 93 ------------------------------------------ 1 file changed, 93 deletions(-) delete mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 525a33a3..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,93 +0,0 @@ -version: 2 -updates: - # 1. React (JavaScript/TypeScript) dependencies - - package-ecosystem: "npm" - directory: "/ClientAdvisor/App/frontend" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 100 - - - package-ecosystem: "npm" - directory: "/ResearchAssistant/App/frontend" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 100 - - # 2. Python dependencies - - package-ecosystem: "pip" - directory: "/ClientAdvisor/App" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 100 - - - package-ecosystem: "pip" - directory: "/ClientAdvisor/AzureFunction" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 100 - - - package-ecosystem: "pip" - directory: "/ClientAdvisor/Deployment/scripts/fabric_scripts" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 100 - - - package-ecosystem: "pip" - directory: "/ClientAdvisor/Deployment/scripts/index_scripts" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 100 - - - package-ecosystem: "pip" - directory: "/ResearchAssistant/App" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 100 - - - package-ecosystem: "pip" - directory: "/ResearchAssistant/Deployment/scripts/aihub_scripts" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 100 - - - package-ecosystem: "pip" - directory: "/ResearchAssistant/Deployment/scripts/fabric_scripts" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 100 - - - package-ecosystem: "pip" - directory: "/ResearchAssistant/Deployment/scripts/index_scripts" - schedule: - interval: "monthly" - commit-message: - prefix: "build" - target-branch: "dependabotchanges" - open-pull-requests-limit: 16