-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
215 lines (179 loc) · 6.92 KB
/
Makefile
File metadata and controls
215 lines (179 loc) · 6.92 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
# WSmart+ Route Framework - Makefile
# System for solving complex Combinatorial Optimization (CO) problems
SHELL := /bin/bash
# Colors for terminal output
BLUE := \033[0;34m
CYAN := \033[0;36m
GREEN := \033[0;32m
YELLOW := \033[1;33m
RED := \033[0;31m
MAGENTA := \033[0;35m
NC := \033[0m # No Color
# Configuration
PYTHON := uv run python
PIP := uv pip
UV := uv
MAIN := main.py
# Default Parameters (can be overridden: make train PROBLEM=wcvrp)
PROBLEM ?= vrpp
MODEL ?= am
SIZE ?= 50
AREA ?= riomaior
WTYPE ?= plastic
EPOCHS ?= 100
DAYS ?= 31
SEED ?= 42
# --- Macros ---
define print_header
@echo -e "$(BLUE)╔══════════════════════════════════════════════════════════════════════╗$(NC)"
@echo -e "$(BLUE)║ WSmart+ Route Framework Control ║$(NC)"
@echo -e "$(BLUE)╚══════════════════════════════════════════════════════════════════════╝$(NC)"
endef
.PHONY: help setup sync train eval test-sim gen-data gui lint format clean test-logic test-gui test-fast test-marker
help:
$(call print_header)
@echo -e ""
@echo -e "$(CYAN)Usage:$(NC) make <target> [VARIABLE=value]"
@echo -e ""
@echo -e "$(YELLOW)Setup & Environment:$(NC)"
@echo -e " $(GREEN)setup$(NC) - Initialize environment and install dependencies using uv"
@echo -e " $(GREEN)sync$(NC) - Sync dependencies with uv.lock"
@echo -e " $(GREEN)install$(NC) - Install dependencies using uv pip"
@echo -e ""
@echo -e "$(YELLOW)Task Execution (main.py wrappers):$(NC)"
@echo -e " $(GREEN)train$(NC) - Run model training (Default: PROBLEM=$(PROBLEM), MODEL=$(MODEL), SIZE=$(SIZE))"
@echo -e " $(GREEN)eval$(NC) - Run model evaluation"
@echo -e " $(GREEN)test-sim$(NC) - Run simulator testing"
@echo -e " $(GREEN)gen-data$(NC) - Generate virtual graph data"
@echo -e " $(GREEN)gui$(NC) - Launch the PySide6 Graphical User Interface"
@echo -e ""
@echo -e "$(YELLOW)Script Wrappers (scripts/*.sh):$(NC)"
@echo -e " $(GREEN)run-train$(NC) - Execute scripts/train.sh"
@echo -e " $(GREEN)run-eval$(NC) - Execute scripts/evaluation.sh"
@echo -e " $(GREEN)run-gen$(NC) - Execute scripts/gen_data.sh (Alias: gen_data)"
@echo -e " $(GREEN)run-meta$(NC) - Execute scripts/meta_train.sh"
@echo -e " $(GREEN)run-hpo$(NC) - Execute scripts/hyperparam_optim.sh"
@echo -e ""
@echo -e "$(YELLOW)Testing & Quality:$(NC)"
@echo -e " $(GREEN)test$(NC) - Run all tests using pytest"
@echo -e " $(GREEN)test-fast$(NC) - Run only fast unit tests"
@echo -e " $(GREEN)test-logic$(NC) - Run backend logic tests"
@echo -e " $(GREEN)test-gui$(NC) - Run GUI-specific tests"
@echo -e " $(GREEN)test-marker$(NC) - Run tests with specific marker (e.g., make test-marker MARKER=slow)"
@echo -e " $(GREEN)lint$(NC) - Check code quality with ruff"
@echo -e " $(GREEN)format$(NC) - Format code with black and ruff"
@echo -e ""
@echo -e "$(YELLOW)Maintenance:$(NC)"
@echo -e " $(GREEN)clean$(NC) - Remove temporary files and caches"
@echo -e ""
@echo -e "$(CYAN)Variables:$(NC)"
@echo -e " PROBLEM=$(PROBLEM), MODEL=$(MODEL), SIZE=$(SIZE), AREA=$(AREA), EPOCHS=$(EPOCHS)"
# --- Setup ---
setup:
$(call print_header)
@echo -e "$(BLUE)🔧 Setting up environment with uv...$(NC)"
$(UV) sync
@echo -e "$(GREEN)✓ Environment ready.$(NC)"
sync:
$(call print_header)
@echo -e "$(BLUE)🔄 Syncing dependencies...$(NC)"
$(UV) sync
install:
$(call print_header)
@echo -e "$(BLUE)📦 Installing dependencies with pip...$(NC)"
$(PIP) install -r requirements.txt || $(UV) pip install -e .
# --- Primary Execution ---
train:
$(call print_header)
@echo -e "$(BLUE)🚀 Starting Training [$(PROBLEM)/$(MODEL)/$(SIZE)]...$(NC)"
$(PYTHON) $(MAIN) train --model $(MODEL) --problem $(PROBLEM) --graph_size $(SIZE) --n_epochs $(EPOCHS)
eval:
$(call print_header)
@echo -e "$(BLUE)📊 Starting Evaluation...$(NC)"
$(PYTHON) $(MAIN) eval
test-sim:
$(call print_header)
@echo -e "$(BLUE)🎮 Starting Simulation Test...$(NC)"
$(PYTHON) $(MAIN) test_sim --policies regular gurobi alns --days $(DAYS)
gen-data:
$(call print_header)
@echo -e "$(BLUE)📂 Generating Virtual Data...$(NC)"
$(PYTHON) $(MAIN) generate_data virtual --problem $(PROBLEM) --graph_sizes $(SIZE)
gui:
$(call print_header)
@echo -e "$(BLUE)🖥️ Launching WSmart+ GUI...$(NC)"
$(PYTHON) $(MAIN) gui
# --- Script Runners ---
run-train:
$(call print_header)
@echo -e "$(BLUE)📜 Running training script...$(NC)"
bash scripts/train.sh
run-eval:
$(call print_header)
@echo -e "$(BLUE)📜 Running evaluation script...$(NC)"
bash scripts/evaluation.sh
run-gen:
$(call print_header)
@echo -e "$(BLUE)📜 Running data generation script...$(NC)"
bash scripts/gen_data.sh
gen_data: run-gen
run-meta:
$(call print_header)
@echo -e "$(BLUE)📜 Running meta-training script...$(NC)"
bash scripts/meta_train.sh
run-hpo:
$(call print_header)
@echo -e "$(BLUE)📜 Running HPO script...$(NC)"
bash scripts/hyperparam_optim.sh
run-sim:
$(call print_header)
@echo -e "$(BLUE)📜 Running Simulation script...$(NC)"
bash scripts/test_sim.sh
# --- Test & Quality ---
test:
$(call print_header)
@echo -e "$(BLUE)🧪 Running all tests...$(NC)"
$(UV) run pytest
test-fast:
$(call print_header)
@echo -e "$(BLUE)🧪 Running fast unit tests...$(NC)"
$(UV) run pytest -m "fast or unit"
test-logic:
$(call print_header)
@echo -e "$(BLUE)🧪 Running logic tests...$(NC)"
$(UV) run pytest logic/test/
test-gui:
$(call print_header)
@echo -e "$(BLUE)🧪 Running GUI tests...$(NC)"
$(UV) run pytest gui/test/
test-marker:
$(call print_header)
@echo -e "$(BLUE)🧪 Running tests with marker [$(MARKER)]...$(NC)"
$(UV) run pytest -m "$(MARKER)"
lint:
$(call print_header)
@echo -e "$(BLUE)🔍 Linting with ruff...$(NC)"
$(UV) run ruff check . --fix --exclude ".venv"
format:
$(call print_header)
@echo -e "$(BLUE)✨ Formatting with black & ruff...$(NC)"
$(UV) run ruff format . --exclude ".venv"
# --- Maintenance ---
clean:
$(call print_header)
@echo -e "$(BLUE)🧹 Cleaning caches and artifacts...$(NC)"
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type d -name ".pytest_cache" -exec rm -rf {} +
find . -type d -name ".ruff_cache" -exec rm -rf {} +
find . -type d -name ".mypy_cache" -exec rm -rf {} +
rm -rf build/
rm -rf dist/
rm -rf temp/
rm -rf wandb/
rm -rf outputs/
rm -rf checkpoints/
rm -rf *.egg-info
rm -rf logs/
rm -rf outputs/
rm -rf model_weights/
@echo -e "$(GREEN)✓ Cleanup complete.$(NC)"