Skip to content

Commit f4b4921

Browse files
authored
Merge pull request #252 from nitya/aitour-ldn/fix-1
add / postdeploy hook for data
2 parents 7fa5612 + 1f70d45 commit f4b4921

File tree

5 files changed

+73
-42
lines changed

5 files changed

+73
-42
lines changed

azure.yaml

+13-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,25 @@ hooks:
1212
postprovision:
1313
posix:
1414
shell: sh
15-
continueOnError: false
15+
continueOnError: true
1616
interactive: true
1717
run: infra/hooks/postprovision.sh
1818
windows:
1919
shell: pwsh
20-
continueOnError: false
20+
continueOnError: true
2121
interactive: true
2222
run: infra/hooks/postprovision.ps1
23+
postdeploy:
24+
posix:
25+
shell: sh
26+
continueOnError: true
27+
interactive: true
28+
run: infra/hooks/postdeploy.sh
29+
windows:
30+
shell: pwsh
31+
continueOnError: true
32+
interactive: true
33+
run: infra/hooks/postdeploy.ps1
2334
infra:
2435
provider: "bicep"
2536

infra/hooks/postdeploy.ps1

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env pwsh
2+
3+
Write-Host "--- ☑️ 1. Starting postdeploy ---"
4+
5+
# -----------------------------------------------------------
6+
# Setup to run notebooks
7+
python -m pip install -r ./src/api/requirements.txt > $null
8+
Write-Host "---- ✅ 3. Installed required dependencies ---"
9+
10+
# -----------------------------------------------------------
11+
# Run notebooks to populate data
12+
jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > $null
13+
jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > $null
14+
Write-Host "---- ✅ 4. Completed populating data ---"
15+
16+
# -----------------------------------------------------------
17+
Write-Host "--- ✅ Completed postdeploy ---"

infra/hooks/postdeploy.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
echo "--- ☑️ Starting postpdeploy ---"
4+
5+
# -----------------------------------------------------------
6+
# Setup to run notebooks
7+
python -m pip install -r ./src/api/requirements.txt > /dev/null
8+
python -m pip install ipython ipykernel > /dev/null # Install ipython and ipykernel
9+
ipython kernel install --name=python3 --user > /dev/null # Configure the IPython kernel
10+
jupyter kernelspec list > /dev/null # Verify kernelspec list isn't empty
11+
echo "---- ✅ 3. Installed required dependencies ---"
12+
13+
# -----------------------------------------------------------
14+
# Run notebooks to populate data
15+
echo "Populating data ...."
16+
jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > /dev/null
17+
jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > /dev/null
18+
echo "---- ✅ 4. Completed populating data ---"
19+
20+
echo "--- ✅ Completed postdeploy ---"

infra/hooks/postprovision.ps1

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env pwsh
22

3-
Write-Host "Starting postprovisioning..."
3+
Write-Host "--- ☑️ 1. Starting postprovisioning ---"
4+
5+
# -----------------------------------------------------------
6+
# Retrieve service names, resource group name, and other values from environment variables
47

58
# Retrieve service names, resource group name, and other values from environment variables
69
$resourceGroupName = $env:AZURE_RESOURCE_GROUP
@@ -23,25 +26,24 @@ Write-Host "azureSearchEndpoint: $azureSearchEndpoint"
2326

2427
# Ensure all required environment variables are set
2528
if ([string]::IsNullOrEmpty($resourceGroupName) -or [string]::IsNullOrEmpty($openAiService) -or [string]::IsNullOrEmpty($subscriptionId)) {
26-
Write-Host "One or more required environment variables are not set."
29+
Write-Host "🅇 One or more required environment variables are not set."
2730
Write-Host "Ensure that AZURE_RESOURCE_GROUP, AZURE_OPENAI_NAME, AZURE_SUBSCRIPTION_ID are set."
2831
exit 1
2932
}
3033

31-
# Set additional environment variables expected by app
32-
# --- Removed these since they are already set in azd env refresh ---
33-
# azd env set AZURE_OPENAI_API_VERSION $AZURE_OPENAI_API_VERSION # 2023-03-15-preview
34-
# azd env set AZURE_OPENAI_CHAT_DEPLOYMENT AZURE_OPENAI_API_VERSION # gpt-35-turbo
35-
# azd env set AZURE_SEARCH_ENDPOINT $AZURE_SEARCH_ENDPOINT
36-
3734
# Output environment variables to .env file using azd env get-values
3835
azd env get-values > .env
39-
Write-Host "Script execution completed successfully."
36+
#Write-Host "--- ✅ 2. Set environment variables ---"
37+
38+
# -----------------------------------------------------------
39+
# Setup to run notebooks
40+
#python -m pip install -r ./src/api/requirements.txt > $null
41+
#Write-Host "---- ✅ 3. Installed required dependencies ---"
4042

41-
Write-Host 'Installing dependencies from "requirements.txt"'
42-
python -m pip install -r ./src/api/requirements.txt > $null
43+
# -----------------------------------------------------------
44+
# Run notebooks to populate data
45+
#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > $null
46+
#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > $null
47+
#Write-Host "---- ✅ 4. Completed populating data ---"
4348

44-
# populate data
45-
Write-Host "Populating data ...."
46-
jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > $null
47-
jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > $null
49+
Write-Host "--- ✅ Completed postprovisioning ---"

infra/hooks/postprovision.sh

+6-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
echo "--- ☑️ Starting postprovisioning ---"
4+
5+
# -----------------------------------------------------------
36
# Retrieve service names, resource group name, and other values from environment variables
47
resourceGroupName=$AZURE_RESOURCE_GROUP
58
searchService=$AZURE_SEARCH_NAME
@@ -14,33 +17,11 @@ if [ -z "$resourceGroupName" ] || [ -z "$searchService" ] || [ -z "$openAiServic
1417
exit 1
1518
fi
1619

17-
# Set additional environment variables expected by app
18-
# --- Removed these since they are already set in azd env refresh ---
19-
# azd env set AZURE_OPENAI_API_VERSION $AZURE_OPENAI_API_VERSION # 2023-03-15-preview
20-
# azd env set AZURE_OPENAI_CHAT_DEPLOYMENT AZURE_OPENAI_CHAT_DEPLOYMENT # gpt-35-turbo
21-
# azd env set AZURE_SEARCH_ENDPOINT $AZURE_SEARCH_ENDPOINT
22-
23-
2420
# Output environment variables to .env file using azd env get-values
2521
azd env get-values >.env
22+
echo "--- ✅ 2. Set environment variables ---"
2623

27-
echo "--- ✅ | 1. Post-provisioning - env configured ---"
28-
29-
# Setup to run notebooks
30-
echo 'Installing dependencies from "requirements.txt"'
31-
python -m pip install -r ./src/api/requirements.txt > /dev/null
32-
python -m pip install ipython ipykernel > /dev/null # Install ipython and ipykernel
33-
ipython kernel install --name=python3 --user > /dev/null # Configure the IPython kernel
34-
jupyter kernelspec list > /dev/null # Verify kernelspec list isn't empty
35-
echo "--- ✅ | 2. Post-provisioning - ready execute notebooks ---"
3624

37-
echo "Populating data ...."
38-
jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/customer_info/create-cosmos-db.ipynb > /dev/null
39-
jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 data/product_info/create-azure-search.ipynb > /dev/null
40-
echo "--- ✅ | 3. Post-provisioning - populated data ---"
4125

42-
#echo "Running evaluations ...."
43-
#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 evaluations/evaluate-chat-flow-sdk.ipynb
44-
#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 evaluations/evaluate-chat-flow-custom-no-sdk.ipynb
45-
#jupyter nbconvert --execute --to python --ExecutePreprocessor.timeout=-1 evaluations/evaluate-chat-flow-custom.ipynb
46-
#echo "--- ✅ | 4. Post-provisioning - ran evaluations ---"
26+
echo "--- ✅ Completed postprovisioning ---"
27+
# -----------------------------------------------------------

0 commit comments

Comments
 (0)