Skip to content

CI Check - wandb-integration #29

CI Check - wandb-integration

CI Check - wandb-integration #29

Workflow file for this run

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 "================================"