-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
154 lines (132 loc) · 4.76 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
.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.
PYTHONHASHSEED=42 pytest -v \
--cov=smarts \
--doctest-modules \
--forked \
--dist=loadscope \
-n `nproc --ignore 2` \
./envision ./smarts/contrib ./smarts/core ./smarts/env ./smarts/sstudio ./tests \
--ignore=./smarts/core/tests/test_smarts_memory_growth.py \
--ignore=./smarts/env/tests/test_benchmark.py \
--ignore=./smarts/env/tests/test_learning.py \
-k 'not test_long_determinism'
.PHONY: sanity-test
sanity-test: build-all-scenarios
./tests/test_setup.py
PYTHONHASHSEED=42 pytest -v \
--doctest-modules \
--forked \
--dist=loadscope \
--junitxml="sanity_test_result.xml" \
-n `nproc --ignore 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 \
./tests/test_examples.py::test_examples[multi_agent] \
./tests/test_examples.py::test_multi_instance_example \
./smarts/env/tests/test_social_agent.py::test_social_agents
.PHONY: test-learning
test-learning: build-all-scenarios
pytest -v -s -o log_cli=1 -o log_cli_level=INFO ./smarts/env/tests/test_learning.py
.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
.PHONY: test-long-determinism
test-long-determinism:
scl scenario build --clean scenarios/minicity
PYTHONHASHSEED=42 pytest -v \
--forked \
./smarts/env/tests/test_determinism.py::test_long_determinism
.PHONY: benchmark
benchmark: build-all-scenarios
pytest -v ./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-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
./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: pview
pview: $(scenario)/map.egg
# !!! READ THE pview MANUAL !!!
# https://www.panda3d.org/manual/?title=Previewing_3D_Models_in_Pview
pview -c -l $(scenario)/map.egg
.PHONY: sumo-gui
sumo-gui: $(scenario)/map.net.xml
sumo-gui \
-n ./$(scenario)/map.net.xml
.PHONY: header-test
header-test:
bash ./header_test.sh
.PHONY: gen-header
gen-header:
bash ./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 -rf ./$(scenario)/traffic
rm -rf ./$(scenario)/social_agents
.PHONY: format
format:
# pip install isort==5.7.0
isort -m VERTICAL_HANGING_INDENT --skip-gitignore --ac --tc --profile black ./benchmark/ ./cli ./envision ./examples/ ./extras/ ./scenarios/ ./smarts ./ultra ./zoo
# pip install black==20.8b1
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)
.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