-
Notifications
You must be signed in to change notification settings - Fork 192
/
Makefile
177 lines (152 loc) · 5.56 KB
/
Makefile
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
.PHONY: test
test: build-all-scenarios
# sstudio uses hash(...) as part of some of its type IDs. To make the tests
# repeatable we fix the seed.
PYTHONPATH=$(PWD) PYTHONHASHSEED=42 pytest -v \
--cov=smarts \
--doctest-modules \
--forked \
--dist=loadscope \
--durations=0 \
-n `expr \( \`nproc\` \/ 2 \& \`nproc\` \> 3 \) \| 2` \
--nb-exec-timeout 65536 \
./examples/tests ./smarts/env ./envision ./smarts/core ./smarts/sstudio \
--ignore=./smarts/core/waymo_map.py \
--ignore=./smarts/core/argoverse_map.py \
--ignore=./smarts/core/tests/test_argoverse.py \
--ignore=./smarts/core/tests/test_smarts_memory_growth.py \
--ignore=./smarts/core/tests/test_env_frame_rate.py \
--ignore=./smarts/core/tests/test_notebook.py \
--ignore=./smarts/env/tests/test_benchmark.py \
--ignore=./examples/tests/test_learning.py \
--ignore=./examples/tests/test_rl.py \
-k 'not test_long_determinism'
rm -f .coverage.*
rm -f .coverage*
.PHONY: sanity-test
sanity-test: build-sanity-scenarios
PYTHONPATH=$(PWD) PYTHONHASHSEED=42 pytest -v \
--doctest-modules \
--forked \
--dist=loadscope \
--junitxml="sanity_test_result.xml" \
-n `expr \( \`nproc\` \/ 2 \& \`nproc\` \> 3 \) \| 2` \
./smarts/core/tests/test_python_version.py::test_python_version \
./smarts/core/tests/test_sumo_version.py::test_sumo_version \
./smarts/core/tests/test_dynamics_backend.py::test_set_pose \
./smarts/core/tests/test_sensors.py::test_waypoints_sensor \
./smarts/core/tests/test_smarts.py::test_smarts_doesnt_leak_tasks_after_reset \
./examples/tests/test_examples.py::test_examples[e2_single_agent] \
./smarts/env/tests/test_social_agent.py::test_social_agents_not_in_env_obs_keys
.PHONY: test-learning
test-learning: build-all-scenarios
pytest -v -s -o log_cli=1 -o log_cli_level=INFO ./examples/tests/test_learning.py
.PHONY: test-long-determinism
test-long-determinism:
scl scenario build --clean scenarios/sumo/minicity
PYTHONHASHSEED=42 pytest -v \
--forked \
--durations=0 \
./smarts/env/tests/test_determinism.py::test_long_determinism
.PHONY: test-memory-growth
test-memory-growth: build-all-scenarios
PYTHONHASHSEED=42 pytest -v \
--cov=smarts \
--forked \
--dist=loadscope \
-n `nproc --ignore 1` \
./smarts/core/tests/test_smarts_memory_growth.py
rm -f .coverage.*
rm -f .coverage*
.PHONY: benchmark
benchmark: build-all-scenarios
pytest -v --durations=0 ./smarts/env/tests/test_benchmark.py
.PHONY: test-zoo
test-zoo: build-all-scenarios
cd smarts/zoo/policies && make test
.PHONY: run
run: build-scenario
python $(script) $(scenario)
.PHONY: build-all-scenarios
build-all-scenarios:
scl scenario build-all scenarios
.PHONY: build-sumo-scenarios
build-sumo-scenarios:
scl scenario build-all scenarios/sumo
.PHONY: build-sanity-scenarios
build-sanity-scenarios:
scl scenario build --clean scenarios/sumo/loop
scl scenario build --clean scenarios/sumo/zoo_intersection
.PHONY: build-scenario
build-scenario:
scl scenario build $(scenario)
.PHONY: flamegraph
flamegraph: $(scenario)/flamegraph.svg
# We want the default browser to open this flamegraph since it's an
# interactive SVG, browsers will accept anything you throw at
# them with a .html extension so lets just rename this svg so that
# `open` will open the file with the browser.
mv $(scenario)/flamegraph.svg $(scenario)/flamegraph.html
# Python's webbrowser module is a cross-platform way of opening a webpage using a preferred browser
python -m webbrowser $(scenario)/flamegraph.html
.PHONY: $(scenario)/flamegraph.svg
$(scenario)/flamegraph.svg: $(scenario)/flamegraph-perf.log
./utils/third_party/tools/flamegraph.pl --title "HiWay CPU ($(scenario))" $(scenario)/flamegraph-perf.log > $(scenario)/flamegraph.svg
.PHONY: $(scenario)/flamegraph-perf.log
$(scenario)/flamegraph-perf.log: build-scenario $(script) smarts/core/* smarts/env/*
# pip install git+https://github.com/asokoloski/python-flamegraph.git
python -m flamegraph -i 0.001 -o $(scenario)/flamegraph-perf.log $(script) $(scenario)
.PHONY: sumo-gui
sumo-gui: $(scenario)/map.net.xml
sumo-gui \
-n ./$(scenario)/map.net.xml
.PHONY: header-test
header-test:
bash ./bin/header_test.sh
.PHONY: gen-header
gen-header:
bash ./bin/gen_header.sh
.PHONY: clean
clean:
# we use `rm -f` for discard errors when the file does not exist
rm -f ./$(scenario)/map.egg
rm -f ./$(scenario)/map.glb
rm -f ./$(scenario)/bubbles.pkl
rm -f ./$(scenario)/missions.pkl
rm -f ./$(scenario)/friction_map.pkl
rm -f ./$(scenario)/flamegraph-perf.log
rm -f ./$(scenario)/flamegraph.svg
rm -f ./$(scenario)/flamegraph.html
rm -f ./$(scenario)/*.rou.xml
rm -f ./$(scenario)/*.rou.alt.xml
rm -f ./$(scenario)/*.smarts.xml
rm -rf ./$(scenario)/traffic
rm -rf ./$(scenario)/social_agents
rm -f .coverage.*
rm -f .coverage*
.PHONY: format
format: gen-header
echo "isort, version `isort --version-number`"
isort -m VERTICAL_HANGING_INDENT --skip-gitignore --ac --tc --profile black ./cli ./envision ./examples/ ./utils/ ./scenarios/ ./smarts ./zoo
black --version
black .
# npm install prettier
# Make sure to install Node.js 14.x before running `prettier`
npx prettier --write envision/web/src
.PHONY: docs
docs:
cd docs && make clean html SPHINXOPTS="-W -T -n --keep-going -b spelling -b linkcheck"
.PHONY: wheel
wheel: docs
python setup.py clean --all
python setup.py bdist_wheel
@echo
@echo "ls ./dist:"
@ls -l1 ./dist | sed 's/^/ /'
.PHONY: rm-pycache
rm-pycache:
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
.PHONY: rm-cov
rm-cov:
find . -type f -name ".coverage.*" -delete
find . -type f -name ".coverage*" -delete