Skip to content

Commit b0324f2

Browse files
committed
Update task runner to conditionally compile / clean benchmarks
1 parent 50419b4 commit b0324f2

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

tasks.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
@task
1010
def build_alloy(c):
1111
"""Build all alloy configurations"""
12-
exps = Experiments()
12+
exps = Experiments.new()
1313
cfgs = exps.configurations(only_missing=True)
1414
alloy_cfgs_needed = set(cfg.alloy for cfg in cfgs if not cfg.alloy.installed)
15-
alloy_build_steps = sum(a.build_steps for a in alloy_cfgs_needed)
15+
alloy_build_steps = sum(a.steps for a in alloy_cfgs_needed)
1616
with timer("Building missing alloy configurations", alloy_build_steps):
1717
for alloy in alloy_cfgs_needed:
1818
alloy.build()
@@ -22,14 +22,17 @@ def build_alloy(c):
2222
def build_benchmarks(c, suites=None):
2323
"""Build all benchmarks for all configurations"""
2424

25-
exps = Experiments()
25+
exps = Experiments.new()
2626
if suites:
2727
exps = exps.filter_suites(suites)
2828

2929
cfgs = exps.configurations(only_missing=True)
3030

3131
alloy_cfgs_needed = set(cfg.alloy for cfg in cfgs if not cfg.alloy.installed)
32-
alloy_build_steps = sum(a.build_steps for a in alloy_cfgs_needed)
32+
alloy_build_steps = sum(a.steps for a in alloy_cfgs_needed)
33+
34+
print(f"Found {len(alloy_cfgs_needed)} Alloy configuration(s):")
35+
[print(f" {os.path.relpath(a.path)}") for a in alloy_cfgs_needed]
3336

3437
with timer("Building missing alloy configurations", alloy_build_steps):
3538
for alloy in alloy_cfgs_needed:
@@ -43,7 +46,7 @@ def build_benchmarks(c, suites=None):
4346
@task
4447
def run_benchmarks(c, pexecs, experiments=None, suites=None, metric=None):
4548
pexecs = int(pexecs)
46-
exps = Experiments(pexecs)
49+
exps = Experiments.new(pexecs)
4750
if suites:
4851
exps = exps.filter_suites(suites)
4952

@@ -117,13 +120,17 @@ def compare(c, experiment_name, cfg, name, suite=None):
117120

118121
@task
119122
def clean_alloy(c, experiments=None):
120-
exps = Experiments()
123+
exps = Experiments.new()
121124

122125
if experiments:
123126
exps = exps.filter_experiments(experiments)
124127

125128
to_remove = set(cfg.alloy for cfg in exps.configurations() if cfg.alloy.installed)
126129

130+
if not to_remove:
131+
print("No Alloy configurations installed")
132+
return
133+
127134
print(f"Found {len(to_remove)} Alloy configuration(s):")
128135
[print(f" {os.path.relpath(a.bin)}") for a in to_remove]
129136

@@ -146,21 +153,37 @@ def clean_results(c, suites=None):
146153

147154

148155
@task
149-
def clean_benchmarks(c, suites=None, reclone=False):
156+
def clean_benchmarks(c, suites=None, including_src=False):
150157
"""Clean all benchmarks for all configurations"""
151158

152-
exps = Experiments()
159+
exps = Experiments.new()
153160
if suites:
154161
exps = exps.filter_suites(suites)
155162

156163
cfgs = exps.configurations(only_installed=True)
164+
165+
if not cfgs:
166+
print("No benchmark programs installed")
167+
return
157168
print(f"Found {len(cfgs)} configurations:")
158169
[print(f" {os.path.relpath(cfg.bin)}") for cfg in cfgs]
159170

160171
response = input(f"Are you sure you want to remove them? (y/n): ").strip().lower()
161172
if response == "y":
162173
for cfg in cfgs:
163-
cfg.remove()
174+
cfg.remove(including_src)
164175
print(f"{len(cfgs)} benchmark configurations removed.")
165176
else:
166177
print("cancelled.")
178+
179+
180+
@task
181+
def clean(c):
182+
response = (
183+
input("Are you sure you want to remove everything? (y/n): ").strip().lower()
184+
)
185+
if response == "y":
186+
clean_alloy(c)
187+
clean_benchmarks(c)
188+
else:
189+
print("cancelled.")

0 commit comments

Comments
 (0)