-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
317 lines (235 loc) · 9.78 KB
/
Justfile
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# Use with https://github.com/casey/just
@_default:
just --list --unsorted
just _default-args
# ============================================================================ #
# Arguments #
# ============================================================================ #
PY_V := "3.$(python3 -V | cut -d\" \" -f2 | cut -d\".\" -f2)"
PY_T := "prod"
PY_D := ".venv"
_default-args:
#!/bin/bash
echo
echo "Default arguments:"
labels=("PY_V: {{PY_V}}" "PY_T: {{PY_T}}" "PY_D: {{PY_D}}")
comments=("Version of Python" "Python target (prod/dev)" "Python virtual environment folder")
max_length=27
for label in "${labels[@]}"; do
length=${#label}
if ((length > max_length)); then
max_length=$length
fi
done
for i in "${!labels[@]}"; do
printf " %-${max_length}s %b\n" "${labels[i]}" "\033[34m# ${comments[i]}\033[0m"
done
echo
echo "Update an argument:"
echo " just --set <ARG_NAME> <ARG_VAL> <RECIPE>"
# ============================================================================ #
# Constants #
# ============================================================================ #
logs_dir := "logs"
domains_dir := "src/tyr/problems/domains"
planners_dir := "src/tyr/planners/planners"
python := if PY_D != "." { PY_D + "/bin/python" } else { "python" }
# ============================================================================ #
# Clear #
# ============================================================================ #
# Clear everything
clear-full: clear-venv clear-cov clear-logs
alias clear := clear-full
# Clear virtual environment
clear-venv:
rm -rf {{ PY_D }}
rm -rf **/*.egg-info
# Clear coverage
clear-cov:
rm -rf coverage
# Clear logs
clear-logs:
rm -rf {{ logs_dir }}
# ============================================================================ #
# Install #
# ============================================================================ #
# Install Python virtual environment
install-venv:
if test ! -e {{ PY_D }}; then python{{ PY_V }} -m venv {{ PY_D }}; fi
# Install Python dependencies
install-pip: install-venv
{{ python }} -m pip install -r requirements/{{ PY_T }}.txt
alias install := install-pip
# Install Python dependencies, planners, and domains
install-full: install-pip install-all-planners install-all-domains
# ================================== Domains ================================= #
# Install all integrated domains
install-all-domains: install-ipc-domains install-scheduling-domains install-custom-domains
_install-domain-submodule name:
git submodule update --init --recursive {{ domains_dir }}/{{ name }}
# Install the IPC domains
install-ipc-domains:
@just _install-domain-submodule ipc
# Install the Scheduling domains
install-scheduling-domains:
@just _install-domain-submodule scheduling
# Install the Custom domains
install-custom-domains:
@just _install-domain-submodule custom
# ================================= Planners ================================= #
# Install all integrated planners
install-all-planners: install-aries install-enhsp install-linear-complex install-lpg install-optic install-panda-pi install-popcorn install-popf install-tamer
_install-planner-submodule name:
git submodule update --init --recursive {{ planners_dir }}/{{ name }}
_register-planner name:
#!/bin/bash
file="shortcuts/configuration/planners.yaml"
line="name: {{ name }}"
if ! grep -Fq "$line" "$file"
then
echo "- $line" >> "$file"
echo "{{ name }} planner registered."
else
echo "{{ name }} planner already registered."
fi
_register-planner-aries:
#!/bin/bash
file="shortcuts/configuration/planners.yaml"
line="name: aries"
if ! grep -Fq "$line" "$file"
then
echo "- $line" >> "$file"
echo " env:" >> "$file"
echo " ARIES_UP_ASSUME_REALS_ARE_INTS: \"true\"" >> "$file"
echo " GRPC_VERBOSITY: \"ERROR\"" >> "$file"
echo " upf_engine: tyr.planners.planners.aries.planning.unified.plugin.up_aries.Aries" >> "$file"
echo "aries planner registered."
else
echo "aries planner already registered."
fi
_register-planner-lpg:
#!/bin/bash
file="shortcuts/configuration/planners.yaml"
line="name: lpg"
if ! grep -Fq "$line" "$file"
then
echo "- $line" >> "$file"
echo " anytime_name: lpg-anytime" >> "$file"
echo "lpg planner registered."
else
echo "lpg planner already registered."
fi
# Install the Aries planner
install-aries: install-venv
@just _install-planner-submodule aries
cargo build --release --bin up-server --manifest-path {{ planners_dir }}/aries/Cargo.toml
cp {{ planners_dir }}/aries/target/release/up-server {{ planners_dir }}/aries/planning/unified/plugin/up_aries/bin/up-aries_linux_amd64
{{ python }} -m pip install -r {{ planners_dir }}/aries/planning/unified/requirements.txt
@just _register-planner-aries
# Install the ENHSP planner
install-enhsp: install-venv
{{ python }} -m pip install up-enhsp
@just _register-planner enhsp
# Install the LinearComplex planner
install-linear-complex:
@just _install-planner-submodule linear-complex
./{{ planners_dir }}/linear-complex/install.sh
@just _register-planner linear-complex
# Install the LPG planner
install-lpg:
@just _install-planner-submodule lpg
{{ python }} -m pip install -e {{ planners_dir }}/lpg
@just _register-planner-lpg
# Install the Optic planner
install-optic:
@just _install-planner-submodule optic
@just _register-planner optic
# Install the PandaPi planner
install-panda-pi:
@just _install-planner-submodule pandapi
./{{ planners_dir }}/pandapi/install.sh
@just _register-planner panda-pi
# Install the Popcorn planner
install-popcorn:
@just _install-planner-submodule popcorn
./{{ planners_dir }}/popcorn/install.sh
@just _register-planner popcorn
# Install the Popf planner
install-popf:
@just _install-planner-submodule popf
@just _register-planner popf
# Install the Tamer planner
install-tamer: install-venv
{{ python }} -m pip install up-tamer
@just _register-planner tamer
# ============================================================================ #
# Reset #
# ============================================================================ #
# Reset the python environment
reset-venv: clear-venv install-pip
alias reset := reset-venv
# Reset the python environment, planners, and domains
reset-full: clear-full install-full
# ============================================================================ #
# Container #
# ============================================================================ #
# Build the Apptainer image.
build-apptainer:
apptainer build --fakeroot --writable-tmpfs container/tyr.sif container/tyr.def
# ============================================================================ #
# Linters #
# ============================================================================ #
# Format Justfile.
fmt-justfile:
just --fmt --unstable
_lint linter folder *args:
@echo "\033[1m\033[96m==> Linting {{ folder }} with {{ linter }}\033[0m"
{{ python }} -m {{ linter }} {{ args }} {{ folder }}
# Run all python linters in the folder.
@lint +folders="src/ tests/":
#!/usr/bin/env sh
set -e;
for folder in {{ folders }}; do
just _lint "bandit" $folder "-r -c pyproject.toml";
just _lint "black" $folder;
just _lint "flake8" $folder;
just _lint "isort" $folder;
just _lint "mypy" $folder;
just _lint "pylint" $folder;
done
# ============================================================================ #
# Tests #
# ============================================================================ #
# Run pytest.
test-all +args="tests/":
{{ python }} -m pytest {{ args }}
# Run pytest without slow tests.
test +args="tests/": (test-all "-m 'not slow'" args)
# Run pytest for coverage.
cov: (test-all "tests --cov src --cov-report term:skip-covered --cov-report html:coverage")
# ============================================================================ #
# CI #
# ============================================================================ #
_erase-planners-config-ci:
rm -f shortcuts/configuration/planners.yaml
_install-planners-ci: _erase-planners-config-ci install-aries
_install-domains-ci: install-all-domains
_install-ci: install-pip _install-planners-ci _install-domains-ci
_reset-ci: reset-venv _install-planners-ci _install-domains-ci
_cov-ci: (test-all "tests --cov src --cov-report term --cov-report xml --junitxml report.xml")
# ============================================================================ #
# CLI #
# ============================================================================ #
# Run the tyr module.
tyr *args:
{{ python }} -m tyr {{ args }}
# Run the bench command.
bench *args: (tyr "bench" args)
# Run the plot command.
plot *args: (tyr "plot" args)
# Run the slurm command.
slurm *args: (tyr "slurm" args)
# Run the solve command.
solve *args: (tyr "solve" args)
# Run the table command.
table *args: (tyr "table" args)