Skip to content

Commit 15ff01a

Browse files
committed
chore: add snakefile use of run_with_limits
1 parent 30ee91a commit 15ff01a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Snakefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,13 @@ rule hdel_compare_make_output:
120120
GIT_ROOT / "bv-evaluation/results/HackersDelight/{file}_{width}_r{r}.txt"
121121
resources:
122122
# TODO: actually impose memory and time limit, using a python script.
123-
runtime=config["hdel_timeout"]
124-
shell:
125-
"lake lean {input} 2>&1 > {output} && "
126-
"echo 'done.'"
123+
run:
124+
status, stdout, stderr = run_with_limits(cmd=["lake", "lean", input[0]], timeout=int(config["hdel_timeout_sec"]), memout_mb=int(config["hdel_memout_mb"]))
125+
with open(output[0], "w") as f:
126+
f.write(stdout)
127+
f.write(stderr)
128+
if not isinstance(status, int) or status != 0:
129+
raise Exception(f"rule failed with status '{status}'. See {output[0]} for possible more details.")
127130

128131
# We can eventually split these, if we carefully understand the naming convention
129132
# of 'collect' for hacker's delight.

config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
hdel_ntests: 100 # default number of goals to take.
22
hdel_bv_widths: [4, 8, 16, 32, 64] # number of hackers delight widths.
33
hdel_nreps: 2 # number of repetitions to run hacker's delight tests.
4-
# Time parsed using 'humanfriendly'. https://humanfriendly.readthedocs.io/en/latest/api.html?highlight=parse_timespan#humanfriendly.parse_timespan
5-
hdel_timeout: "30min" # parsed using 'humanfriendly
4+
hdel_timeout_sec: 1800
5+
hdel_memout_mb: 3600
66
hdel_nthreads: 8 # number of threads to use for hacker's delight tests.
77
seed: 42 # random number generator seed.
88

0 commit comments

Comments
 (0)