diff --git a/azure.yaml b/azure.yaml index d1b333dc..e3ad5b8e 100644 --- a/azure.yaml +++ b/azure.yaml @@ -12,14 +12,25 @@ hooks: postprovision: posix: shell: sh - continueOnError: false + continueOnError: true interactive: true run: infra/hooks/postprovision.sh windows: shell: pwsh - continueOnError: false + continueOnError: true interactive: true run: infra/hooks/postprovision.ps1 + postdeploy: + posix: + shell: sh + continueOnError: true + interactive: true + run: infra/hooks/postdeploy.sh + windows: + shell: pwsh + continueOnError: true + interactive: true + run: infra/hooks/postdeploy.ps1 infra: provider: "bicep" diff --git a/infra/hooks/postdeploy.ps1 b/infra/hooks/postdeploy.ps1 new file mode 100644 index 00000000..81da64a1 --- /dev/null +++ b/infra/hooks/postdeploy.ps1 @@ -0,0 +1,17 @@ +#!/usr/bin/env pwsh + +Write-Host "--- ☑️ 1. Starting postdeploy ---" + +# ----------------------------------------------------------- +# Setup to run notebooks +python -m pip install -r ./src/api/requirements.txt > $null +Write-Host "---- ✅ 3. Installed required dependencies ---" + +# ----------------------------------------------------------- +# Run notebooks to populate data +jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > $null +jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > $null +Write-Host "---- ✅ 4. Completed populating data ---" + +# ----------------------------------------------------------- +Write-Host "--- ✅ Completed postdeploy ---" \ No newline at end of file diff --git a/infra/hooks/postdeploy.sh b/infra/hooks/postdeploy.sh new file mode 100755 index 00000000..be32d4ff --- /dev/null +++ b/infra/hooks/postdeploy.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +echo "--- ☑️ Starting postpdeploy ---" + +# ----------------------------------------------------------- +# Setup to run notebooks +python -m pip install -r ./src/api/requirements.txt > /dev/null +python -m pip install ipython ipykernel > /dev/null # Install ipython and ipykernel +ipython kernel install --name=python3 --user > /dev/null # Configure the IPython kernel +jupyter kernelspec list > /dev/null # Verify kernelspec list isn't empty +echo "---- ✅ 3. Installed required dependencies ---" + +# ----------------------------------------------------------- +# Run notebooks to populate data +echo "Populating data ...." +jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > /dev/null +jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > /dev/null +echo "---- ✅ 4. Completed populating data ---" + +echo "--- ✅ Completed postdeploy ---" \ No newline at end of file diff --git a/infra/hooks/postprovision.ps1 b/infra/hooks/postprovision.ps1 index bf6d99bc..237016b5 100644 --- a/infra/hooks/postprovision.ps1 +++ b/infra/hooks/postprovision.ps1 @@ -1,6 +1,9 @@ #!/usr/bin/env pwsh -Write-Host "Starting postprovisioning..." +Write-Host "--- ☑️ 1. Starting postprovisioning ---" + +# ----------------------------------------------------------- +# Retrieve service names, resource group name, and other values from environment variables # Retrieve service names, resource group name, and other values from environment variables $resourceGroupName = $env:AZURE_RESOURCE_GROUP @@ -23,25 +26,24 @@ Write-Host "azureSearchEndpoint: $azureSearchEndpoint" # Ensure all required environment variables are set if ([string]::IsNullOrEmpty($resourceGroupName) -or [string]::IsNullOrEmpty($openAiService) -or [string]::IsNullOrEmpty($subscriptionId)) { - Write-Host "One or more required environment variables are not set." + Write-Host "🅇 One or more required environment variables are not set." Write-Host "Ensure that AZURE_RESOURCE_GROUP, AZURE_OPENAI_NAME, AZURE_SUBSCRIPTION_ID are set." exit 1 } -# Set additional environment variables expected by app -# --- Removed these since they are already set in azd env refresh --- -# azd env set AZURE_OPENAI_API_VERSION $AZURE_OPENAI_API_VERSION # 2023-03-15-preview -# azd env set AZURE_OPENAI_CHAT_DEPLOYMENT AZURE_OPENAI_API_VERSION # gpt-35-turbo -# azd env set AZURE_SEARCH_ENDPOINT $AZURE_SEARCH_ENDPOINT - # Output environment variables to .env file using azd env get-values azd env get-values > .env -Write-Host "Script execution completed successfully." +#Write-Host "--- ✅ 2. Set environment variables ---" + +# ----------------------------------------------------------- +# Setup to run notebooks +#python -m pip install -r ./src/api/requirements.txt > $null +#Write-Host "---- ✅ 3. Installed required dependencies ---" -Write-Host 'Installing dependencies from "requirements.txt"' -python -m pip install -r ./src/api/requirements.txt > $null +# ----------------------------------------------------------- +# Run notebooks to populate data +#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > $null +#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > $null +#Write-Host "---- ✅ 4. Completed populating data ---" -# populate data -Write-Host "Populating data ...." -jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > $null -jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > $null \ No newline at end of file +Write-Host "--- ✅ Completed postprovisioning ---" \ No newline at end of file diff --git a/infra/hooks/postprovision.sh b/infra/hooks/postprovision.sh index 0967fc67..940b9602 100755 --- a/infra/hooks/postprovision.sh +++ b/infra/hooks/postprovision.sh @@ -1,5 +1,8 @@ #!/bin/bash +echo "--- ☑️ Starting postprovisioning ---" + +# ----------------------------------------------------------- # Retrieve service names, resource group name, and other values from environment variables resourceGroupName=$AZURE_RESOURCE_GROUP searchService=$AZURE_SEARCH_NAME @@ -14,33 +17,11 @@ if [ -z "$resourceGroupName" ] || [ -z "$searchService" ] || [ -z "$openAiServic exit 1 fi -# Set additional environment variables expected by app -# --- Removed these since they are already set in azd env refresh --- -# azd env set AZURE_OPENAI_API_VERSION $AZURE_OPENAI_API_VERSION # 2023-03-15-preview -# azd env set AZURE_OPENAI_CHAT_DEPLOYMENT AZURE_OPENAI_CHAT_DEPLOYMENT # gpt-35-turbo -# azd env set AZURE_SEARCH_ENDPOINT $AZURE_SEARCH_ENDPOINT - - # Output environment variables to .env file using azd env get-values azd env get-values >.env +echo "--- ✅ 2. Set environment variables ---" -echo "--- ✅ | 1. Post-provisioning - env configured ---" - -# Setup to run notebooks -echo 'Installing dependencies from "requirements.txt"' -python -m pip install -r ./src/api/requirements.txt > /dev/null -python -m pip install ipython ipykernel > /dev/null # Install ipython and ipykernel -ipython kernel install --name=python3 --user > /dev/null # Configure the IPython kernel -jupyter kernelspec list > /dev/null # Verify kernelspec list isn't empty -echo "--- ✅ | 2. Post-provisioning - ready execute notebooks ---" -echo "Populating data ...." -jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > /dev/null -jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > /dev/null -echo "--- ✅ | 3. Post-provisioning - populated data ---" -#echo "Running evaluations ...." -#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 evaluations/evaluate-chat-flow-sdk.ipynb -#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 evaluations/evaluate-chat-flow-custom-no-sdk.ipynb -#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 evaluations/evaluate-chat-flow-custom.ipynb -#echo "--- ✅ | 4. Post-provisioning - ran evaluations ---" \ No newline at end of file +echo "--- ✅ Completed postprovisioning ---" +# ----------------------------------------------------------- \ No newline at end of file