-
Notifications
You must be signed in to change notification settings - Fork 10
90 lines (75 loc) · 2.98 KB
/
benchmark.yml
File metadata and controls
90 lines (75 loc) · 2.98 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
name: RAG Benchmark
run-name: RAG Benchmark by ${{ github.actor }}
on:
workflow_dispatch:
jobs:
benchmark:
environment: main
runs-on: ubuntu-latest
strategy:
matrix:
dataset: [kunji, sneha]
service: [assistants, responses]
count: [100]
env:
LOCAL_CREDENTIALS_ORG_OPENAI_API_KEY: ${{ secrets.LOCAL_CREDENTIALS_ORG_OPENAI_API_KEY }}
LOCAL_CREDENTIALS_API_KEY: ${{ secrets.LOCAL_CREDENTIALS_API_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- run: |
cp .env.example .env
sed -i 's/changethis/secret123/g' .env
- name: Run server
run: |
docker compose up -d
sleep 10
- name: prestart logs on failure
if: failure()
run: |
docker compose logs -f prestart
exit 1
- name: Create local credentials
run: |
curl -X POST "http://localhost:8000/api/v1/credentials/" \
-H "Content-Type: application/json" \
-H "X-API-KEY: ${{ env.LOCAL_CREDENTIALS_API_KEY }}" \
-d '{
"organization_id": 1,
"project_id": 1,
"is_active": true,
"credential": {
"openai": {
"api_key": "${{ env.LOCAL_CREDENTIALS_ORG_OPENAI_API_KEY }}"
}
}
}'
- name: Run benchmark
run: |
docker compose exec backend uv run ai-cli bench ${{ matrix.service }} --dataset ${{ matrix.dataset }} --count ${{ matrix.count }} | tee benchmark_output.txt
# Extract mean duration from benchmark output
MEAN_DURATION=$(grep '^Mean duration:' benchmark_output.txt | awk '{print $3}')
echo "## Benchmark Results for ${{ matrix.service }} - ${{ matrix.dataset }} (${{ matrix.count }} queries, ${MEAN_DURATION} avg)" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat benchmark_output.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# Find latest benchmark file inside container first
CONTAINER_LATEST=$(docker compose exec backend sh -c "ls -t bench_results_*.csv | head -n1")
# Copy the specific file out
docker compose cp backend:/app/$CONTAINER_LATEST ./
cp $CONTAINER_LATEST bench-${{ matrix.service }}-${{ matrix.dataset }}-${{ matrix.count }}.csv
ls -l bench-${{ matrix.service }}-${{ matrix.dataset }}-${{ matrix.count }}.csv
- name: backend logs on failure
if: failure()
timeout-minutes: 1
run: |
docker compose logs -f backend
exit 1
- name: Upload benchmark results
uses: actions/upload-artifact@v7
with:
name: bench-${{ matrix.service }}-${{ matrix.dataset }}-${{ matrix.count }}.csv
path: bench-${{ matrix.service }}-${{ matrix.dataset }}-${{ matrix.count }}.csv
- name: Cleanup
if: always()
run: docker compose down