-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (109 loc) · 4.3 KB
/
Makefile
File metadata and controls
134 lines (109 loc) · 4.3 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
.PHONY: help setup install dev run test clean build up down logs shell
# Default target
.DEFAULT_GOAL := help
# Colors
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
NC := \033[0m
# Environment
VENV := .venv
UV := uv
help: ## Show this help
@echo "$(BLUE)RAG Fundamentals Workshop$(NC)"
@echo ""
@echo "$(GREEN)Usage:$(NC)"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(YELLOW)%-15s$(NC) %s\n", $$1, $$2}'
# ============================================================================
# Setup & Installation
# ============================================================================
setup: ## Initial setup (create .env, install uv, create venv)
@# 1. Create .env if missing
@if [ ! -f .env ]; then \
echo "$(BLUE)Creating .env file...$(NC)"; \
cp env.example .env; \
echo "$(GREEN)✓ .env created$(NC)"; \
echo "$(YELLOW)⚠ Edit .env and add your GOOGLE_API_KEY$(NC)"; \
else \
echo "$(YELLOW).env already exists$(NC)"; \
fi
@# 2. Check for uv
@if ! command -v uv >/dev/null 2>&1; then \
echo "$(BLUE)Installing uv...$(NC)"; \
curl -LsSf https://astral.sh/uv/install.sh | sh; \
else \
echo "$(GREEN)✓ uv is installed$(NC)"; \
fi
@# 3. Create venv and sync
@echo "$(BLUE)Setting up virtual environment...$(NC)"
@$(UV) sync
@echo "$(BLUE)Installing pip in venv for notebook compatibility...$(NC)"
@$(UV) pip install pip
@echo "$(GREEN)✓ Environment ready$(NC)"
install: ## Install dependencies
@echo "$(BLUE)Syncing dependencies...$(NC)"
@$(UV) sync
@echo "$(GREEN)✓ Dependencies installed$(NC)"
# ============================================================================
# Development
# ============================================================================
dev: setup up-infra run ## Setup, start infra, and run Jupyter locally
run: ## Start JupyterLab locally
@echo "$(BLUE)Starting JupyterLab...$(NC)"
@echo "$(YELLOW)Access at: http://localhost:8888$(NC)"
@$(UV) run jupyter lab --port=8888
# ============================================================================
# Docker / Infrastructure
# ============================================================================
build: ## Build Docker images
@echo "$(BLUE)Building Docker images...$(NC)"
docker compose build
@echo "$(GREEN)✓ Built$(NC)"
up: ## Start all containers (Jupyter + Qdrant)
@echo "$(BLUE)Starting all containers...$(NC)"
docker compose up -d
@echo "$(GREEN)✓ Running at http://localhost:8888$(NC)"
up-infra: ## Start only infrastructure (Qdrant)
@echo "$(BLUE)Starting Qdrant infrastructure...$(NC)"
docker compose up -d qdrant
@echo "$(GREEN)✓ Qdrant is running$(NC)"
down: ## Stop all containers
@echo "$(BLUE)Stopping containers...$(NC)"
docker compose down
@echo "$(GREEN)✓ Stopped$(NC)"
logs: ## View container logs
docker compose logs -f
shell: ## Open shell in container
docker compose exec jupyter /bin/bash
restart: down up ## Restart containers
# ============================================================================
# Testing
# ============================================================================
validate: ## Validate notebook format
@echo "$(BLUE)Validating notebooks...$(NC)"
@for notebook in *.ipynb; do \
$(UV) run jupyter nbconvert --to notebook --stdout "$$notebook" > /dev/null || exit 1; \
done
@echo "$(GREEN)✓ All valid$(NC)"
test: ## Run all notebooks to verify they execute correctly
@echo "$(BLUE)Testing all notebooks...$(NC)"
@for notebook in *.ipynb; do \
echo "Running $$notebook..."; \
$(UV) run jupyter nbconvert --to notebook --execute --stdout "$$notebook" > /dev/null || exit 1; \
done
@echo "$(GREEN)✓ All notebooks passed$(NC)"
# ============================================================================
# Cleanup
# ============================================================================
clean: ## Remove venv, cache, and temp files
@echo "$(BLUE)Cleaning...$(NC)"
rm -rf $(VENV)
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".ipynb_checkpoints" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
@$(UV) cache clean
@echo "$(GREEN)✓ Cleaned$(NC)"
clean-all: clean down ## Clean everything including Docker
docker compose down -v
@echo "$(GREEN)✓ Everything cleaned$(NC)"