Skip to content

Commit 4080129

Browse files
authored
[CI][Benchmarks] Fix exit on benchmark failure (#19290)
Currently this functionality doesn't work at all because of a missing field in `options.py` module.
1 parent cf8dab2 commit 4080129

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

devops/scripts/benchmarks/main.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,22 @@ def run_iterations(
4343
print(f"running {benchmark.name()}, iteration {iter}... ", flush=True)
4444
bench_results = benchmark.run(env_vars)
4545
if bench_results is None:
46-
failures[benchmark.name()] = "benchmark produced no results!"
47-
break
46+
if options.exit_on_failure:
47+
raise RuntimeError(f"Benchmark {benchmark.name()} produced no results!")
48+
else:
49+
failures[benchmark.name()] = "benchmark produced no results!"
50+
break
4851

4952
for bench_result in bench_results:
5053
if not bench_result.passed:
51-
failures[bench_result.label] = "verification failed"
52-
print(f"complete ({bench_result.label}: verification failed).")
53-
continue
54+
if options.exit_on_failure:
55+
raise RuntimeError(
56+
f"Benchmark {benchmark.name()} failed: {bench_result.label} verification failed."
57+
)
58+
else:
59+
failures[bench_result.label] = "verification failed"
60+
print(f"complete ({bench_result.label}: verification failed).")
61+
continue
5462

5563
print(
5664
f"{benchmark.name()} complete ({bench_result.label}: {bench_result.value:.3f} {bench_result.unit})."
@@ -220,7 +228,6 @@ def main(directory, additional_env_vars, save_name, compare_names, filter):
220228
benchmark.setup()
221229
if options.verbose:
222230
print(f"{benchmark.name()} setup complete.")
223-
224231
except Exception as e:
225232
if options.exit_on_failure:
226233
raise e
@@ -405,7 +412,9 @@ def validate_and_parse_env_args(env_args):
405412
"--verbose", help="Print output of all the commands.", action="store_true"
406413
)
407414
parser.add_argument(
408-
"--exit-on-failure", help="Exit on first failure.", action="store_true"
415+
"--exit-on-failure",
416+
help="Exit on first benchmark failure.",
417+
action="store_true",
409418
)
410419
parser.add_argument(
411420
"--compare-type",

devops/scripts/benchmarks/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Options:
6969
current_run_name: str = "This PR"
7070
preset: str = "Full"
7171
build_jobs: int = multiprocessing.cpu_count()
72+
exit_on_failure: bool = False
7273

7374
# Options intended for CI:
7475
regression_threshold: float = 0.05

0 commit comments

Comments
 (0)