From 660f92f64679cf0fbc3033d398d78025be740328 Mon Sep 17 00:00:00 2001 From: David Joy <10147749+dmjoy@users.noreply.github.com> Date: Tue, 11 Jul 2023 13:15:40 -0400 Subject: [PATCH] Handle probes embedded in scenario file --- baseline_system_local_files.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/baseline_system_local_files.py b/baseline_system_local_files.py index dd59d8e2..f2ef5141 100644 --- a/baseline_system_local_files.py +++ b/baseline_system_local_files.py @@ -22,7 +22,7 @@ def main(): help="File path to input alignment target JSON") parser.add_argument('probes_filepaths', type=str, - nargs='+', + nargs='*', help="File path to input probe JSON") parser.add_argument("--print-details", action='store_true', @@ -114,10 +114,19 @@ def run_baseline_system_local_filepath( algorithm.load_model() - for probe_filepath in probes_filepaths: - with open(probe_filepath) as f: - probe_data = json.load(f) + probes = [] + if len(probes_filepaths) > 0: + for probe_filepath in probes_filepaths: + with open(probe_filepath) as f: + probes.append(json.load(f)) + else: + # Assume probes are embedded in the scenario file + probes.extend(scenario_data.get('probes', [])) + + if len(probes) == 0: + raise RuntimeError("No probes specified, and none found in scenario") + for probe_data in probes: probe_type = probe_data['type'] scenario_info = scenario_data['state'].get('unstructured')