-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
188 lines (169 loc) · 6.75 KB
/
Makefile
File metadata and controls
188 lines (169 loc) · 6.75 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
# RT Predictor Microservices Makefile
.PHONY: help setup build train start stop restart logs clean clean-all test status fresh-start dev-setup
# Default target
help:
@echo "RT Predictor Microservices Management"
@echo "====================================="
@echo "make setup - Initial setup (check prerequisites, prepare data)"
@echo "make build - Build all Docker images"
@echo "make train - Run training service"
@echo "make start - Start all services"
@echo "make stop - Stop all services"
@echo "make restart - Restart all services"
@echo "make logs - Show logs for all services"
@echo "make clean - Clean up containers, volumes, and networks"
@echo "make clean-all - Deep clean including Docker system prune"
@echo "make test - Run all tests"
@echo "make status - Show service status"
@echo "make fresh-start - Complete setup from scratch (clean + setup + train + start)"
@echo ""
@echo "M2 Max Optimization Commands (Apple Silicon):"
@echo "============================================="
@echo "make train-m2max - Run optimized training (2-3x faster)"
@echo "make start-m2max - Start services with resource limits"
@echo "make fresh-start-m2max - Complete setup with M2 Max optimization"
# Initial setup
setup:
@echo "Setting up RT Predictor Microservices..."
@echo "Checking Docker..."
@docker --version || (echo "Docker not installed" && exit 1)
@docker-compose --version || (echo "Docker Compose not installed" && exit 1)
@echo "Checking data..."
@if [ ! -f rt-predictor-training/data/raw/eagle_data.parquet ]; then \
echo "Setting up training data..."; \
if [ -f scripts/copy_data.sh ]; then \
chmod +x scripts/copy_data.sh && ./scripts/copy_data.sh || echo "Warning: Could not copy data. You may need to run 'git lfs pull' first."; \
else \
echo "Warning: copy_data.sh not found. Please ensure training data is in rt-predictor-training/data/raw/"; \
fi; \
fi
@echo "Creating .env file if not exists..."
@if [ ! -f .env ]; then cp .env.example .env 2>/dev/null || echo "Warning: .env.example not found"; fi
@# Ensure proto files are in place for UI service
@if [ -f rt-predictor-api/src/proto/rt_predictor.proto ]; then \
mkdir -p rt-predictor-ui/src/proto; \
cp rt-predictor-api/src/proto/rt_predictor.proto rt-predictor-ui/src/proto/ 2>/dev/null || true; \
echo "# RT Predictor Protocol Buffer Definitions" > rt-predictor-ui/src/proto/__init__.py; \
fi
@echo "Setup complete!"
# Build all images
build:
@echo "Building all services..."
@# Ensure proto file is copied before build
@if [ -f rt-predictor-api/src/proto/rt_predictor.proto ]; then \
mkdir -p rt-predictor-ui/src/proto; \
cp rt-predictor-api/src/proto/rt_predictor.proto rt-predictor-ui/src/proto/ 2>/dev/null || true; \
fi
docker-compose build --no-cache
# Run training
train:
@echo "Running training service..."
@echo "This will train models on the Eagle dataset (may take 5-10 minutes)..."
@# Ensure clean state for training
@docker-compose --profile training down --remove-orphans 2>/dev/null || true
docker-compose --profile training up rt-predictor-training
# Start services
start:
@echo "Starting all services..."
@# Ensure clean state
@docker-compose down --remove-orphans 2>/dev/null || true
docker-compose up -d
@sleep 5
@echo "\nServices started!"
@echo "=================="
@echo "UI: http://localhost:8501"
@echo "API Metrics: http://localhost:8181/metrics"
@echo "Prometheus: http://localhost:9090"
@echo "Grafana: http://localhost:3000 (admin/admin)"
@echo "=================="
@make status
# Stop services
stop:
@echo "Stopping all services..."
docker-compose down --remove-orphans
# Restart services
restart: stop start
# Show logs
logs:
docker-compose logs -f
# Show specific service logs
logs-%:
docker-compose logs -f rt-predictor-$*
# Clean up
clean:
@echo "Cleaning up..."
@docker-compose down -v --remove-orphans 2>/dev/null || true
@# Remove any orphaned networks
@docker network ls | grep microservices | awk '{print $1}' | xargs -r docker network rm 2>/dev/null || true
@echo "Cleaned up containers, volumes, and networks"
# Deep clean
clean-all: clean
@echo "Performing deep clean..."
@docker system prune -f
@echo "Deep clean complete"
# Run tests
test:
@echo "Running tests..."
@echo "Tests should be run inside containers or with proper environment setup"
@echo "To run tests in containers:"
@echo " docker-compose run --rm rt-predictor-training pytest tests/"
@echo " docker-compose run --rm rt-predictor-api pytest tests/"
@echo " docker-compose run --rm rt-predictor-ui pytest tests/"
# Show status
status:
@echo "\nService Status:"
@echo "==============="
@docker-compose ps
@echo "\nVolumes:"
@docker volume ls | grep microservices || echo "No volumes found"
@echo "\nNetworks:"
@docker network ls | grep microservices || echo "No networks found"
# Fresh start from scratch
fresh-start:
@echo "Starting fresh setup..."
@make clean-all
@make setup
@make build
@make train
@make start
@echo "\nFresh setup complete! All services are running."
# M2 Max optimized training
train-m2max:
@echo "Running M2 Max optimized training..."
@echo "Using 10 CPU cores and up to 48GB RAM..."
@# Copy optimized config
@cp rt-predictor-training/configs/config.m2max.toml rt-predictor-training/configs/config.toml
@# Ensure clean state for training
@docker-compose --profile training down --remove-orphans 2>/dev/null || true
docker-compose -f docker-compose.m2max.yml --profile training up rt-predictor-training
# M2 Max optimized start
start-m2max:
@echo "Starting services with M2 Max optimization..."
@docker-compose down --remove-orphans 2>/dev/null || true
docker-compose -f docker-compose.m2max.yml up -d
@sleep 5
@echo "\nServices started with M2 Max optimization!"
@echo "=================="
@echo "UI: http://localhost:8501"
@echo "API Metrics: http://localhost:8181/metrics"
@echo "Prometheus: http://localhost:9090"
@echo "Grafana: http://localhost:3000 (admin/admin)"
@echo "=================="
@make status
# Fresh start with M2 Max optimization
fresh-start-m2max:
@echo "Starting fresh setup with M2 Max optimization..."
@make clean-all
@make setup
@make build
@make train-m2max
@make start-m2max
@echo "\nFresh setup complete with M2 Max optimization!"
# Development setup (for local development)
dev-setup:
@echo "Setting up development environment..."
@echo "Creating Python virtual environments..."
@cd rt-predictor-training && python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt
@cd rt-predictor-api && python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt
@cd rt-predictor-ui && python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt
@echo "Development setup complete!"