-
Notifications
You must be signed in to change notification settings - Fork 0
211 lines (184 loc) · 6.59 KB
/
ci.yml
File metadata and controls
211 lines (184 loc) · 6.59 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: MLOps Pipeline (Langfuse v3)
run-name: "CI Check - wandb-integration"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
qdrant:
image: qdrant/qdrant:latest
ports:
- 6333:6333
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl build-essential
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
# Install PyTorch CPU version first (faster, no GPU needed in CI)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# Install all other dependencies
pip install -r requirements.txt
# Install dev dependencies
pip install ruff pytest pytest-cov
- name: Lint with Ruff
run: |
ruff check . --fix
continue-on-error: true
- name: Component Initialization Check
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY }}
LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY }}
LANGFUSE_HOST: "https://cloud.langfuse.com"
QDRANT_URL: "http://localhost:6333"
PYTHONPATH: .
run: |
echo "🔍 Testing RAG Engine initialization..."
# Невелика пауза для впевненості, що контейнер прокинувся
sleep 5
python -c "
import sys
try:
from src.rag import engine
print('✅ RAG Engine initialized successfully')
print(f'✅ Collection: {engine.client.get_collection(\"rag_documents\")}')
except Exception as e:
print(f'❌ Initialization failed: {e}')
sys.exit(1)
"
- name: Ingest Test Data
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
QDRANT_URL: "http://localhost:6333"
PYTHONPATH: .
run: |
echo "📄 Ingesting test data..."
python -c "
from src.rag import engine
from langchain.schema import Document
test_docs = [
Document(
page_content='PDF was created by Dr. John Warnock at Adobe. The ISO standard is ISO 32000.',
metadata={'source': 'test_doc.pdf', 'page': 1, 'doc_hash': 'test123'}
),
Document(
page_content='PostScript is the programming language that PDF is based on.',
metadata={'source': 'test_doc.pdf', 'page': 2, 'doc_hash': 'test456'}
)
]
engine.vector_store.add_documents(test_docs)
# Verify ingestion
count = engine.client.count('rag_documents').count
print(f'✅ Test data ingested successfully. Total documents: {count}')
if count < 2:
raise Exception('Expected at least 2 documents in the collection')
"
- name: Test RAG Query (Smoke Test)
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY }}
LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY }}
QDRANT_URL: "http://localhost:6333"
PYTHONPATH: .
run: |
echo "🧪 Running smoke test query..."
python -c "
from src.rag import engine
# Simple query test (skip if API key missing)
try:
answer, sources, trace_id = engine.get_answer_with_sources('Who created PDF?')
print(f'✅ Query test passed')
print(f'Answer preview: {answer[:100]}...')
print(f'Sources found: {len(sources)}')
print(f'Trace ID: {trace_id}')
except Exception as e:
print(f'⚠️ Query test skipped or failed: {e}')
"
continue-on-error: true
- name: Run RAG Evaluation
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY }}
LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY }}
QDRANT_URL: "http://localhost:6333"
PYTHONPATH: .
run: |
if [ -z "$GROQ_API_KEY" ]; then
echo "⚠️ GROQ_API_KEY not set. Skipping evaluation."
exit 0
fi
echo "📊 Running Ragas evaluation..."
# Try to find evaluation script
if [ -f "evaluation/evaluate.py" ]; then
python evaluation/evaluate.py
elif [ -f "evaluation/run_eval.py" ]; then
python evaluation/run_eval.py
else
echo "⚠️ Evaluation script not found. Skipping."
exit 0
fi
continue-on-error: true
- name: Upload Evaluation Report
uses: actions/upload-artifact@v4
if: always()
with:
name: rag-evaluation-report
path: |
evaluation/report.csv
evaluation/*.csv
retention-days: 30
- name: Test FastAPI Endpoints (Integration Test)
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY }}
LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY }}
QDRANT_URL: "http://localhost:6333"
PYTHONPATH: .
run: |
echo "🧪 Testing FastAPI endpoints..."
# Start API in background
uvicorn src.main:app --host 0.0.0.0 --port 8000 &
API_PID=$!
# Wait for API to start
sleep 10
# Test health endpoint
curl -f http://localhost:8000/health || {
echo "❌ Health check failed"
kill $API_PID
exit 1
}
echo "✅ FastAPI health check passed"
# Cleanup
kill $API_PID
continue-on-error: true
- name: Cleanup Test Data
if: always()
env:
QDRANT_URL: "http://localhost:6333"
run: |
echo "🧹 Cleaning up test data..."
curl -X DELETE "http://localhost:6333/collections/rag_documents" || true
echo "✅ Cleanup complete"
- name: Summary
if: always()
run: |
echo "================================"
echo "📋 CI Pipeline Summary"
echo "================================"
echo "✅ CI process finished"
echo "================================"