forked from jimmc414/Kosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
301 lines (249 loc) · 10.2 KB
/
Copy pathMakefile
File metadata and controls
301 lines (249 loc) · 10.2 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
.PHONY: help install setup-docker setup-neo4j setup-env start stop restart status verify clean test test-e2e test-smoke test-e2e-quick lint format
# Default target
help:
@echo "╔════════════════════════════════════════════════════════════╗"
@echo "║ Kosmos AI Scientist - Make Targets ║"
@echo "╚════════════════════════════════════════════════════════════╝"
@echo ""
@echo "Setup Commands:"
@echo " make install - Complete environment setup (Python, deps, config)"
@echo " make setup-docker - Install Docker on WSL2"
@echo " make setup-neo4j - Setup and start Neo4j container"
@echo " make setup-env - Setup Python environment only"
@echo ""
@echo "Service Management:"
@echo " make start - Start all services (dev profile)"
@echo " make start-prod - Start all services (production profile)"
@echo " make stop - Stop all services"
@echo " make restart - Restart all services"
@echo " make status - Show status of all containers"
@echo ""
@echo "Development:"
@echo " make verify - Run deployment verification checks"
@echo " make test - Run test suite"
@echo " make test-unit - Run unit tests only"
@echo " make test-int - Run integration tests (requires services)"
@echo " make lint - Run code linters"
@echo " make format - Format code with black/isort"
@echo ""
@echo "Maintenance:"
@echo " make clean - Remove caches and temporary files"
@echo " make clean-all - Remove caches, temp files, and venv"
@echo " make logs - View logs from all services"
@echo " make logs-neo4j - View Neo4j logs only"
@echo ""
@echo "Database:"
@echo " make db-migrate - Run database migrations"
@echo " make db-reset - Reset database (DESTRUCTIVE)"
@echo ""
@echo "Quick Start:"
@echo " 1. make setup-docker # Install Docker (one-time)"
@echo " 2. make install # Setup environment"
@echo " 3. make start # Start services"
@echo " 4. make verify # Verify everything works"
@echo ""
#==============================================================================
# Setup Targets
#==============================================================================
install:
@echo "📦 Setting up Kosmos development environment..."
@./scripts/setup_environment.sh
setup-docker:
@echo "🐳 Installing Docker on WSL2..."
@./scripts/setup_docker_wsl2.sh
setup-neo4j:
@echo "🔷 Setting up Neo4j..."
@./scripts/setup_neo4j.sh
setup-env:
@echo "🐍 Setting up Python environment..."
@./scripts/setup_environment.sh
#==============================================================================
# Service Management
#==============================================================================
start:
@echo "🚀 Starting Kosmos services (dev profile)..."
@docker compose --profile dev up -d
@echo "✓ Services started"
@make status
start-prod:
@echo "🚀 Starting Kosmos services (production profile)..."
@docker compose --profile prod up -d
@echo "✓ Services started"
@make status
stop:
@echo "🛑 Stopping all services..."
@docker compose down
@echo "✓ Services stopped"
restart:
@echo "🔄 Restarting services..."
@docker compose restart
@echo "✓ Services restarted"
@make status
status:
@echo "📊 Service Status:"
@echo "════════════════════════════════════════════════════════════"
@docker compose ps || echo "No services running"
@echo ""
#==============================================================================
# Development & Testing
#==============================================================================
verify:
@echo "🔍 Running deployment verification..."
@./scripts/verify_deployment.sh
test:
@echo "🧪 Running test suite..."
@pytest tests/ -v
test-unit:
@echo "🧪 Running unit tests..."
@pytest tests/unit/ -v
test-int:
@echo "🧪 Running integration tests..."
@pytest tests/integration/ -v
test-cov:
@echo "🧪 Running tests with coverage..."
@pytest tests/ --cov=kosmos --cov-report=html --cov-report=term
@echo "📄 Coverage report generated in htmlcov/index.html"
test-e2e:
@echo "🧪 Running E2E tests..."
@pytest tests/e2e/ -v --no-cov
test-smoke:
@echo "🧪 Running smoke tests..."
@pytest tests/e2e/ -m smoke -v --no-cov
test-e2e-quick:
@echo "🧪 Running quick E2E tests (excluding slow)..."
@pytest tests/e2e/ -m "not slow" -v --no-cov
lint:
@echo "🔍 Running linters..."
@echo "Running pylint..."
@pylint kosmos/ || true
@echo "Running mypy..."
@mypy kosmos/ --ignore-missing-imports || true
@echo "Running flake8..."
@flake8 kosmos/ --max-line-length=120 || true
format:
@echo "✨ Formatting code..."
@echo "Running black..."
@black kosmos/ tests/
@echo "Running isort..."
@isort kosmos/ tests/
@echo "✓ Code formatted"
#==============================================================================
# Logs
#==============================================================================
logs:
@echo "📜 Viewing logs from all services..."
@docker compose logs -f
logs-neo4j:
@echo "📜 Viewing Neo4j logs..."
@docker compose logs -f neo4j
logs-postgres:
@echo "📜 Viewing PostgreSQL logs..."
@docker compose logs -f postgres
logs-redis:
@echo "📜 Viewing Redis logs..."
@docker compose logs -f redis
#==============================================================================
# Database Management
#==============================================================================
db-migrate:
@echo "🗄️ Running database migrations..."
@alembic upgrade head
@echo "✓ Migrations complete"
db-reset:
@echo "⚠️ WARNING: This will delete all data!"
@read -p "Are you sure? (yes/NO): " confirm && [ "$$confirm" = "yes" ] || exit 1
@echo "Stopping services..."
@docker compose down
@echo "Removing database volumes..."
@rm -rf postgres_data/ neo4j_data/
@echo "Recreating volumes..."
@mkdir -p postgres_data neo4j_data
@echo "Starting services..."
@docker compose up -d
@echo "Running migrations..."
@sleep 5
@alembic upgrade head
@echo "✓ Database reset complete"
#==============================================================================
# Maintenance
#==============================================================================
clean:
@echo "🧹 Cleaning caches and temporary files..."
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
@find . -type f -name "*.pyo" -delete 2>/dev/null || true
@find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name ".coverage" -delete 2>/dev/null || true
@rm -rf htmlcov/ 2>/dev/null || true
@echo "✓ Cleanup complete"
clean-all: clean
@echo "🧹 Deep cleaning (including venv)..."
@read -p "Remove virtual environment? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
@rm -rf venv/
@echo "✓ Deep cleanup complete"
#==============================================================================
# Utility Targets
#==============================================================================
shell:
@echo "🐚 Starting shell in kosmos container..."
@docker exec -it kosmos-app /bin/bash
shell-neo4j:
@echo "🐚 Starting Cypher shell..."
@docker exec -it kosmos-neo4j cypher-shell -u neo4j -p kosmos-password
shell-postgres:
@echo "🐚 Starting PostgreSQL shell..."
@docker exec -it kosmos-postgres psql -U kosmos
ps:
@docker compose ps
top:
@docker compose top
stats:
@docker stats
pull:
@echo "📥 Pulling latest images..."
@docker compose pull
@echo "✓ Images updated"
build:
@echo "🔨 Building kosmos image..."
@docker compose build
@echo "✓ Build complete"
#==============================================================================
# Graph Management
#==============================================================================
graph-stats:
@echo "📊 Knowledge graph statistics:"
@source venv/bin/activate && kosmos graph --stats || echo "Activate venv first: source venv/bin/activate"
graph-export:
@echo "💾 Exporting knowledge graph..."
@source venv/bin/activate && kosmos graph --export backup_$(shell date +%Y%m%d_%H%M%S).json
@echo "✓ Export complete"
graph-reset:
@echo "⚠️ WARNING: This will delete all graph data!"
@source venv/bin/activate && kosmos graph --reset
#==============================================================================
# Documentation
#==============================================================================
docs:
@echo "📚 Building documentation..."
@cd docs && make html
@echo "✓ Documentation built in docs/_build/html/"
docs-serve:
@echo "📚 Serving documentation..."
@python -m http.server -d docs/_build/html 8080
#==============================================================================
# Environment Information
#==============================================================================
info:
@echo "ℹ️ Kosmos Environment Information"
@echo "════════════════════════════════════════════════════════════"
@echo "Python: $$(python3 --version 2>/dev/null || echo 'Not found')"
@echo "Docker: $$(docker --version 2>/dev/null || echo 'Not installed')"
@echo "Docker Compose: $$(docker compose version 2>/dev/null || echo 'Not installed')"
@echo "Git: $$(git --version 2>/dev/null || echo 'Not found')"
@echo "Kosmos: $$(source venv/bin/activate 2>/dev/null && kosmos --version 2>/dev/null || echo 'Not installed')"
@echo ""
@echo "Virtual Env: $$([ -d venv ] && echo 'venv/' || echo 'Not created')"
@echo "Config: $$([ -f .env ] && echo '.env exists' || echo '.env not found')"
@echo ""