-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·125 lines (95 loc) · 4.78 KB
/
Copy pathMakefile
File metadata and controls
executable file
·125 lines (95 loc) · 4.78 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
# Makefile for running simulation and launching server
# Default output filename when running `make build`
OUTPUT_FILENAME ?= main.bin
# Default target
all: prod
# Run the server for prod settings (able to connect to the Meta Quest). If npm is not installed, it will skip the build step.
prod:
cd ./dashboard && (npm i && npm run build && mkdir -p ../phosphobot/resources/dist/ && cp -r ./dist/* ../phosphobot/resources/dist/)
cd phosphobot && uv run --python 3.10 phosphobot run --simulation=headless --no-crash-telemetry
prod_back:
cd phosphobot && MESA_GL_VERSION_OVERRIDE=3.3 uv run --python 3.10 phosphobot run --simulation=headless --no-crash-telemetry
# Chat agent run
chat:
cd phosphobot && uv run --python 3.10 phosphobot run --chat --simulation=headless --no-crash-telemetry
# Same as prod, but with the simulation GUI (useful when adding new robots to test)
prod_gui:
cd ./dashboard && (npm i && npm run build && mkdir -p ../phosphobot/resources/dist/ && cp -r ./dist/* ../phosphobot/resources/dist/)
cd phosphobot && MESA_GL_VERSION_OVERRIDE=3.3 uv run --python 3.10 phosphobot run --simulation=gui --no-crash-telemetry
# Trick for raspberrypi : pretend opengl>=3.2 so that pybullet will run in a gui
prod_gui_back:
cd phosphobot && MESA_GL_VERSION_OVERRIDE=3.3 uv run --python 3.10 phosphobot run --simulation=gui --no-crash-telemetry
# Run the server for prod settings (able to connect to the Meta Quest) but with telemetry disabled. If npm is not installed, it will skip the build step.
prod_no_telemetry:
cd ./dashboard && ((npm i && npm run build && mkdir -p ../phosphobot/resources/dist/ && cp -r ./dist/* ../phosphobot/resources/dist/) || echo "npm command failed, continuing anyway")
cd phosphobot && uv run phosphobot run --simulation=headless --no-telemetry
# Run the server for prod settings with the simulation enabled
prod_sim:
cd ./phosphobot && uv run phosphobot run --simulation=gui --no-telemetry
# Run info command for prod settings
prod_info:
cd ./phosphobot && uv run phosphobot info --opencv --servos
# Run localhost server for dev settings
local:
cd ./phosphobot && uv run phosphobot run --simulation=gui --port=8080 --host=127.0.0.1 --no-telemetry
# For running integration tests
test_server:
cd ./phosphobot && uv run phosphobot run --simulation=headless --only-simulation --simulate-cameras --port=8080 --host=127.0.0.1 --no-telemetry &
# For running the built app in test mode
run_bin_test:
./phosphobot/dist/main.bin run --simulation=headless --simulate-cameras --port=8080 --host=127.0.0.1 --no-telemetry &
# For running the built app in prod mode
run_bin:
./phosphobot/dist/main.bin run --simulation=headless
# To have the information about the software and the hardware from the built app
info_bin:
./phosphobot/dist/main.bin info
# Don't use sudo uv run, it will break CICD
build_pyinstaller:
cd phosphobot && \
WASMTIME_PATH=$$(uv run python -c "import wasmtime; import os; print(os.path.dirname(wasmtime.__file__))") && \
uv run pyinstaller \
--onefile \
--name $(OUTPUT_FILENAME) \
--add-data "resources:resources" \
--add-data "$$WASMTIME_PATH:wasmtime" \
--additional-hooks-dir "./hooks" \
--hidden-import phosphobot \
--collect-all phosphobot \
--collect-all wasmtime \
--clean -c \
phosphobot/main.py \
clean_build:
cd ./phosphobot && rm -rf main.build main.dist main.onefile-build $(OUTPUT_FILENAME)
build_frontend:
cd ./dashboard && npm i && npm run build && \
mkdir -p ../phosphobot/resources/dist/ && \
cp -r ./dist/* ../phosphobot/resources/dist/
# Clean up
stop:
echo "Checking for uv process..."
ps -ef | grep uv || echo "No uv process running."
echo "Checking for Python processes..."
ps -ef | grep python || echo "No Python processes found."
-killall uv || echo "No uv process found."
-killall python3 || echo "No python3 process found."
-killall python3.8 || echo "No python3.8 process found."
echo "Cleanup complete."
# Clean up hard (kill processes on ports 80 and 8080)
stop_hard:
echo "Killing all processes listening on port 80..."
-sudo lsof -i :80 -t | xargs -r sudo kill -9
echo "Killing all processes listening on port 8020..."
-sudo lsof -i :8020 -t | xargs -r sudo kill -9
echo "Killing all processes listening on port 8080..."
-sudo lsof -i :8080 -t | xargs -r sudo kill -9
echo "Forceful cleanup of all processes on ports 80, 8020 and 8080 complete."
submodule:
git submodule update --init --recursive
types:
cd phosphobot && uv run mypy . --check-untyped-defs --disallow-untyped-defs --ignore-missing-imports --follow-imports=silent
sort:
cd phosphobot && uv run ruff check --select I --fix .
tests:
cd phosphobot && uv run pytest tests/phosphobot/ -n 5
.PHONY: all dev prod prod_gui stop stop_hard dataset_annotate dataset_convert dataset_push robot_watch test_server build clean_build build_pyinstaller run_bin run_bin_test info_bin