From adac499a3e02e76ab5741208b65a00dae8c37560 Mon Sep 17 00:00:00 2001 From: Stephanie Labasan Brink Date: Tue, 7 Nov 2023 17:47:05 -0800 Subject: [PATCH] Throw exceptions for bad input parameters (#52) * throw exceptions for bad input parameters * black formatting --- bin/benchpark | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/benchpark b/bin/benchpark index 4626036f8..2d72ace3e 100755 --- a/bin/benchpark +++ b/bin/benchpark @@ -96,8 +96,8 @@ def benchpark_list_handler(args): for system in systems: print(f"\t{system}") else: - print( - f"Invalid benchpark list [{sublist}] - must choose [benchmarks],[systems], or leave empty" + raise ValueError( + f'Invalid benchpark list "{sublist}" - must choose [benchmarks], [systems], or leave empty' ) @@ -105,9 +105,10 @@ def benchpark_check_benchmark(arg_str): benchmarks = benchpark_benchmarks() found = arg_str in benchmarks if not found: - print(f"Invalid benchmark/experiment {arg_str} - must choose one of: ") + out_str = f'Invalid benchmark/experiment "{arg_str}" - must choose one of: ' for benchmark in benchmarks: - print(f"\t{benchmark}") + out_str += f"\n\t{benchmark}" + raise ValueError(out_str) return found @@ -115,9 +116,10 @@ def benchpark_check_system(arg_str): systems = benchpark_systems() found = arg_str in systems if not found: - print(f"Invalid system {arg_str} - must choose one of: ") + out_str = f'Invalid system "{arg_str}" - must choose one of: ' for system in systems: - print(f"\t{system}") + out_str += f"\n\t{system}" + raise ValueError(out_str) return found @@ -192,7 +194,11 @@ def benchpark_setup_handler(args): debug_print(f"specified system = {system}") valid_system = benchpark_check_system(system) if not (valid_benchmark and valid_system): - return + raise ValueError( + "Invalid benchmark/experiment and system provided: {0} {1}".format( + benchmark, system + ) + ) workspace_dir = workspace_root / str(benchmark) / str(system)