-
Notifications
You must be signed in to change notification settings - Fork 3
120 lines (102 loc) · 4.26 KB
/
ai_pull_pr_workflow.yml
File metadata and controls
120 lines (102 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
name: PR Workflow for AI Search Components
on:
pull_request:
branches: [development]
workflow_call:
env:
SUBSCRIPTION_ID: ${{ vars.SUBSCRIPTION_ID }}
RESOURCE_GROUP_NAME: ${{ vars.RESOURCE_GROUP_NAME }}
STORAGE_ACCOUNT_NAME: ${{ vars.STORAGE_ACCOUNT_NAME }}
ACS_SERVICE_NAME: ${{ vars.ACS_SERVICE_NAME }}
AOAI_BASE_ENDPOINT: ${{ vars.AOAI_BASE_ENDPOINT }}
AI_FOUNDRY_PROJECT_URI: ${{ vars.AI_FOUNDRY_PROJECT_URI }}
MANAGED_IDENTITY_CLIENT_ID: ${{ vars.MANAGED_IDENTITY_CLIENT_ID }}
MANAGED_IDENTITY_NAME: ${{ vars.MANAGED_IDENTITY_NAME }}
MANAGED_IDENTITY_TENANT_ID: ${{ vars.MANAGED_IDENTITY_TENANT_ID }}
FEDERATED_CLIENT_ID: ${{ vars.FEDERATED_CLIENT_ID }}
FUNCTION_APP_NAME: ${{ vars.FUNCTION_APP_NAME }}
permissions:
id-token: write
contents: read
pull-requests: write
jobs:
build-validation:
name: Build Validation
uses: ./.github/workflows/build_validation_workflow.yml
secrets:
ACR_USERNAME: ${{ secrets.ACR_USERNAME }}
ACR_PASSWORD: ${{ secrets.ACR_PASSWORD }}
deploy-and-evaluate:
name: Deployment and Evaluation
runs-on: ubuntu-latest
needs: build-validation
container:
image: ${{ vars.ACR_CONTAINER_REGISTRY }}.azurecr.io/${{ vars.IMAGE_NAME }}:latest
options: --user root
credentials:
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
steps:
- name: Checkout Actions
uses: actions/checkout@v1
- name: Azure login
uses: azure/login@v2
with:
client-id: ${{ env.FEDERATED_CLIENT_ID }}
tenant-id: ${{ env.MANAGED_IDENTITY_TENANT_ID}}
subscription-id: ${{ env.SUBSCRIPTION_ID }}
- name: Execute Azure Functions Deployment
shell: bash
run: |
python -u -m mlops.deployment_scripts.deploy_azure_functions --ignore_slot
env:
BUILD_SOURCEBRANCHNAME: ${{ github.head_ref || github.ref_name }}
- name: Validate Azure Functions Deployment
shell: bash
run: |
python -u -m mlops.deployment_scripts.run_functions --ignore_slot
env:
BUILD_SOURCEBRANCHNAME: ${{ github.head_ref || github.ref_name }}
- name: Deploy Indexer
shell: bash
run: |
python -u -m mlops.deployment_scripts.build_indexer --ignore_slot
env:
BUILD_SOURCEBRANCHNAME: ${{ github.head_ref || github.ref_name }}
- name: Execute search evaluation
shell: bash
run: |
python -u -m mlops.evaluation.search_evaluation --gt_path "./mlops/evaluation/data/search_evaluation_data_sample.jsonl" --semantic_config my-semantic-config
env:
BUILD_SOURCEBRANCHNAME: ${{ github.head_ref || github.ref_name }}
- name: Post PR comment with results of evaluation
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if ! command -v jq &> /dev/null; then
sudo apt-get update && sudo apt-get install -y jq
fi
latest_results_file=$(ls -t results/ | head -n 1)
results=$(cat "results/${latest_results_file}")
metrics=$(echo "$results" | jq -r '.metrics')
metric_keys=$(echo "$metrics" | jq -r 'keys[]')
metric_values=$(echo "$metrics" | jq -r 'values[]')
metrics_table="## Search Evaluation Results \n \n"
metrics_table="${metrics_table}| Metric | Value |\n"
metrics_table="${metrics_table}| ------ | ----- |\n"
for key in $metric_keys; do
value=$(echo "$metrics" | jq -r --arg key "$key" '.[$key]')
metrics_table="${metrics_table}| $key | $value |\n"
done
formatted_table=$(echo "$metrics_table")
# Use the captured output in the curl command
curl -s -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
--data "$(jq -nc --arg body "$formatted_table" '{body: $body}')" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/comments"
- name: Remove results directory
run: |
if [ -d "results" ]; then
rm -rf results
fi