-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (107 loc) · 4.44 KB
/
Copy pathMakefile
File metadata and controls
131 lines (107 loc) · 4.44 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
# =============================================================================
# Production RAG Answering API
# =============================================================================
# Build, run, and manage the RAG answering system in Docker containers.
# =============================================================================
.PHONY: build up down notebook prepare-data index query evaluate test lint format gpu-check logs clean help
# Default target
.DEFAULT_GOAL := help
# ---------------------------------------------------------------------------
# Docker
# ---------------------------------------------------------------------------
## Build all Docker images
build:
docker compose build
## Start all services (FastAPI, Qdrant, Phoenix, Notebook)
up:
docker compose up -d
## Stop all services
down:
docker compose down
## View logs for all services
logs:
docker compose logs -f
## Remove all containers, volumes, and images
clean:
docker compose down -v --rmi local
# ---------------------------------------------------------------------------
# Notebook
# ---------------------------------------------------------------------------
## Open JupyterLab (starts if not running)
notebook:
@echo "Starting JupyterLab..."
@docker compose up -d notebook
@echo "JupyterLab is available at: http://localhost:8888"
# ---------------------------------------------------------------------------
# Data & Indexing
# ---------------------------------------------------------------------------
## Download and prepare SciFact data
prepare-data:
docker compose exec app python -m scripts.prepare_data
## Build embeddings and index documents into Qdrant
index:
docker compose exec app python -m scripts.index_corpus
# ---------------------------------------------------------------------------
# Query & Evaluate
# ---------------------------------------------------------------------------
## Run a sample query against the API
query:
docker compose exec app python -m scripts.run_query
## Run answering evaluation on SciFact subset
evaluate:
docker compose exec app python -m scripts.evaluate_answers
# ---------------------------------------------------------------------------
# Testing & Quality
# ---------------------------------------------------------------------------
## Run pytest test suite
test:
docker compose exec app pytest tests/ -v --tb=short
## Run Ruff linting
lint:
docker compose exec app ruff check src/ tests/ scripts/
## Format codebase with Ruff
format:
docker compose exec app ruff format src/ tests/ scripts/
# ---------------------------------------------------------------------------
# GPU
# ---------------------------------------------------------------------------
## Verify GPU access inside Docker container
gpu-check:
@echo "=== nvidia-smi ==="
docker compose exec app nvidia-smi
@echo ""
@echo "=== PyTorch CUDA Check ==="
docker compose exec app python -c "import torch; print('PyTorch version:', torch.__version__); print('CUDA available:', torch.cuda.is_available()); print('GPU:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A'); print('VRAM:', f\"{torch.cuda.get_device_properties(0).total_memory / 1024**3:.1f} GB\" if torch.cuda.is_available() else 'N/A')"
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
## Show this help message
help:
@echo "Production RAG Answering API — Available Commands"
@echo "================================================="
@echo ""
@echo "Docker:"
@echo " make build Build all Docker images"
@echo " make up Start all services"
@echo " make down Stop all services"
@echo " make logs View service logs"
@echo " make clean Remove containers, volumes, images"
@echo ""
@echo "Notebook:"
@echo " make notebook Open JupyterLab"
@echo ""
@echo "Data & Indexing:"
@echo " make prepare-data Download and prepare SciFact data"
@echo " make index Build embeddings and index into Qdrant"
@echo ""
@echo "Query & Evaluate:"
@echo " make query Run a sample query"
@echo " make evaluate Run answering evaluation"
@echo ""
@echo "Testing & Quality:"
@echo " make test Run pytest"
@echo " make lint Run Ruff linting"
@echo " make format Format code with Ruff"
@echo ""
@echo "GPU:"
@echo " make gpu-check Verify GPU access inside Docker"