Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
162 lines (142 loc) · 5.54 KB
/
Copy pathMakefile
File metadata and controls
162 lines (142 loc) · 5.54 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
# Ensure tools are in PATH
SHELL := /bin/bash
export PATH := $(HOME)/.local/bin:$(HOME)/.cargo/bin:$(PATH)
# Recursive $(MAKE) calls (e.g. `install` -> doctor) otherwise print a
# "Entering/Leaving directory" line around every sub-invocation.
MAKEFLAGS += --no-print-directory
.PHONY: help setup install run run-fg stop restart logs status check-stopped test lint build-frontend setup-chrome pick-model doctor
# tmux session Condor runs in
SESSION := condor
# Helper function to find node/npm via nvm or system
define find_node
@(export NVM_DIR="$HOME/.nvm"; \
if [ -s "$NVM_DIR/nvm.sh" ]; then \
. "$NVM_DIR/nvm.sh" >/dev/null 2>&1; \
nvm use default >/dev/null 2>&1 || nvm use node >/dev/null 2>&1 || true; \
fi; \
$(1))
endef
help:
@echo "Condor - Available Commands"
@echo ""
@echo " make setup - Interactive setup wizard"
@echo " make pick-model - Choose the AI model Condor thinks with"
@echo " make install - Setup + install all dependencies"
@echo " make run - Start Condor in the '$(SESSION)' tmux session"
@echo " make run-fg - Run in the foreground (debugging)"
@echo " make logs - Attach to the session (detach: Ctrl+B then D)"
@echo " make stop - Stop Condor"
@echo " make restart - Stop and start again"
@echo " make status - Is Condor running?"
@echo " make doctor - Verify dependencies, config, and Hummingbot API access"
@echo " make test - Run tests"
@echo " make lint - Run black + isort"
setup:
@chmod +x setup-environment.sh && ./setup-environment.sh
pick-model:
uv run python -m condor.setup_llm
install: setup
uv sync --dev
@bash -c ' \
export NVM_DIR="$$HOME/.nvm"; \
[ -s "$$NVM_DIR/nvm.sh" ] && . "$$NVM_DIR/nvm.sh"; \
cd frontend && npm install \
'
@$(MAKE) setup-chrome
@-$(MAKE) doctor
setup-chrome:
@echo "Setting up Chrome for chart rendering..."
@uv run python -c "import kaleido; kaleido.get_chrome_sync()" 2>/dev/null || \
echo "Chrome setup skipped (not required for basic usage)"
doctor:
@bash -c ' \
export NVM_DIR="$$HOME/.nvm"; \
[ -s "$$NVM_DIR/nvm.sh" ] && . "$$NVM_DIR/nvm.sh"; \
uv run python -m condor.doctor \
'
# Reinstall when the lockfile moved, not merely when node_modules is absent:
# after the first boot the directory always exists, so a pull that adds a
# dependency would otherwise build against a stale tree and fail. npm rewrites
# node_modules/.package-lock.json on every install, which makes it the honest
# record of what is actually installed.
build-frontend:
@bash -c ' \
export NVM_DIR="$$HOME/.nvm"; \
[ -s "$$NVM_DIR/nvm.sh" ] && . "$$NVM_DIR/nvm.sh"; \
cd frontend || exit 1; \
if [ ! -f node_modules/.package-lock.json ] || \
[ package-lock.json -nt node_modules/.package-lock.json ]; then \
npm ci || exit 1; \
fi; \
npm run build \
'
# Fails early (before the frontend build) if Condor is already up
check-stopped:
@if tmux has-session -t $(SESSION) 2>/dev/null; then \
echo "Condor is already running in tmux session '$(SESSION)'."; \
echo " make logs - attach to it"; \
echo " make restart - stop and start again"; \
exit 1; \
fi
# `remain-on-exit` keeps the pane alive after the process dies, so a startup
# failure can be read back with capture-pane instead of scrolling away with the
# session. Config errors (a bad ADMIN_USER_ID, a mode with no token, a local user
# config.yml has never heard of) exit in the first second and used to leave
# nothing behind but "run make run-fg to see the error".
#
# It is turned back off the moment the boot is confirmed: a crash three hours
# later must still take the session with it, or `make status` and `check-stopped`
# would report a dead Condor as running.
run: check-stopped build-frontend
@tmux new-session -d -s $(SESSION) -c "$(CURDIR)" 'uv run python main.py'
@tmux set-option -t $(SESSION) remain-on-exit on >/dev/null 2>&1 \
|| tmux set-window-option -t $(SESSION) remain-on-exit on >/dev/null 2>&1 || true
@sleep 3
@if ! tmux has-session -t $(SESSION) 2>/dev/null; then \
echo "Condor exited on startup. Run 'make run-fg' to see the error."; \
exit 1; \
fi
@if [ "$$(tmux list-panes -t $(SESSION) -F '#{pane_dead}' 2>/dev/null | head -1)" = "1" ]; then \
echo "Condor exited on startup:"; \
echo ""; \
tmux capture-pane -p -t $(SESSION) 2>/dev/null | grep -v '^[[:space:]]*$$' | tail -20 | sed 's/^/ /'; \
echo ""; \
echo " make run-fg - run in the foreground for the full output"; \
tmux kill-session -t $(SESSION) >/dev/null 2>&1 || true; \
exit 1; \
fi
@tmux set-option -t $(SESSION) remain-on-exit off >/dev/null 2>&1 \
|| tmux set-window-option -t $(SESSION) remain-on-exit off >/dev/null 2>&1 || true
@echo "Condor started in tmux session '$(SESSION)'."
@echo " make logs - attach (detach: Ctrl+B then D)"
@echo " make stop - stop Condor"
run-fg: build-frontend
uv run python main.py
logs:
@tmux attach -t $(SESSION) 2>/dev/null || echo "No '$(SESSION)' session running. Start it with 'make run'."
status:
@if tmux has-session -t $(SESSION) 2>/dev/null; then \
echo "Condor is running (tmux session '$(SESSION)')."; \
else \
echo "Condor is not running."; \
fi
stop:
@if tmux has-session -t $(SESSION) 2>/dev/null; then \
tmux send-keys -t $(SESSION) C-c; \
for i in $$(seq 1 20); do \
tmux has-session -t $(SESSION) 2>/dev/null || break; \
sleep 0.5; \
done; \
tmux kill-session -t $(SESSION) 2>/dev/null || true; \
echo "Condor stopped."; \
else \
echo "Condor is not running."; \
fi
restart:
@$(MAKE) stop
@$(MAKE) run
test:
uv run pytest
lint:
uv run black .
uv run isort .