From 2fb5c3ee9217ded5aeeeabbd9dea3718e4bad488 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 7 Nov 2023 15:09:00 -0800 Subject: [PATCH 1/2] throw exceptions for bad input parameters --- bin/benchpark | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/benchpark b/bin/benchpark index 4626036f8..8c0ff1063 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,7 @@ 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) From 297bb56a0ec7c4f225a3f8e832834a2fe67f9b34 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 7 Nov 2023 15:38:23 -0800 Subject: [PATCH 2/2] black formatting --- bin/benchpark | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/benchpark b/bin/benchpark index 8c0ff1063..2d72ace3e 100755 --- a/bin/benchpark +++ b/bin/benchpark @@ -97,7 +97,7 @@ def benchpark_list_handler(args): print(f"\t{system}") else: raise ValueError( - f"Invalid benchpark list \"{sublist}\" - must choose [benchmarks], [systems], or leave empty" + f'Invalid benchpark list "{sublist}" - must choose [benchmarks], [systems], or leave empty' ) @@ -105,7 +105,7 @@ def benchpark_check_benchmark(arg_str): benchmarks = benchpark_benchmarks() found = arg_str in benchmarks if not found: - out_str = 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: out_str += f"\n\t{benchmark}" raise ValueError(out_str) @@ -116,7 +116,7 @@ def benchpark_check_system(arg_str): systems = benchpark_systems() found = arg_str in systems if not found: - out_str = f"Invalid system \"{arg_str}\" - must choose one of: " + out_str = f'Invalid system "{arg_str}" - must choose one of: ' for system in systems: out_str += f"\n\t{system}" raise ValueError(out_str) @@ -194,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): - raise ValueError("Invalid benchmark/experiment and system provided: {0} {1}".format(benchmark, system)) + raise ValueError( + "Invalid benchmark/experiment and system provided: {0} {1}".format( + benchmark, system + ) + ) workspace_dir = workspace_root / str(benchmark) / str(system)