From 2960ee26a149705e2ccb27a8cd1d09e79a5d3727 Mon Sep 17 00:00:00 2001 From: David Gasinski Date: Tue, 9 Sep 2025 13:51:19 +0100 Subject: [PATCH 1/2] force rebuild --- config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 945dc24..97ab270 100644 --- a/config.yaml +++ b/config.yaml @@ -24,7 +24,7 @@ scenario_runner: initialisation_budget: 200 # ticks algorithm: iterations: 10 - path: algorithms/test_alg + path: algorithms/hill_climb args: # will be passed into the algorithm class as a dict lanelet_path: /autoware_scenario_runner/algorithms/resources/Town01.osm radius: 10 From ebb034474a19be38ee1d5f1e4fb80f1993b8048d Mon Sep 17 00:00:00 2001 From: David Gasinski Date: Tue, 9 Sep 2025 14:39:33 +0100 Subject: [PATCH 2/2] added cleanup method to remove temp XML files from results directory --- aw_scenario_runner.py | 3 +++ srunner/tools/results_manager.py | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/aw_scenario_runner.py b/aw_scenario_runner.py index 49a7aea..90c6fbc 100644 --- a/aw_scenario_runner.py +++ b/aw_scenario_runner.py @@ -339,6 +339,9 @@ def run(self) -> None: f"Scenario iteration {iteration} achieved a score of {driving_score}" ) + # clean up - delete XML files + self.results_manager.cleanup_xml() + # read the scenario definition if not self.DEV_MODE: self.json_definition = self.algorithm._scenario_callback( diff --git a/srunner/tools/results_manager.py b/srunner/tools/results_manager.py index a28b21b..7e0d425 100644 --- a/srunner/tools/results_manager.py +++ b/srunner/tools/results_manager.py @@ -17,7 +17,7 @@ def __init__(self, output_dir: str = "results") -> None: self.results_path = "" self._scenario_decoder = XMLToFiles() - def _create_run_folder(self, base_path: str = ""): + def _create_run_folder(self, scenario: str, base_path: str = ""): """Creates a experiment folder under base_path. The naming convention is as follows ``` run-{yy-mm-dd-h-m-s} @@ -33,15 +33,15 @@ def _create_run_folder(self, base_path: str = ""): base_path = self.output_dir now = datetime.datetime.now() - full_path = os.path.join(base_path, f"run-{now.strftime('%Y-%m-%d-%H-%M-%S')}") # type: ignore + full_path = os.path.join( + base_path, f"{scenario}-{now.strftime('%Y-%m-%d-%H-%M-%S')}" + ) # type: ignore os.makedirs(full_path, exist_ok=True) # exist_ok=True, no need to error handle self.results_path = full_path return full_path - def _create_scenario_folder( - self, scenario: str, iteration: str, results_folder: str - ): + def _create_scenario_folder(self, iteration: str, results_folder: str): """Creates a folder to hold the results of a individual scenario execution. The naming convention is as follows ``` @@ -57,7 +57,7 @@ def _create_scenario_folder( _type_: _description_ """ - full_path = os.path.join(results_folder, f"{scenario}-{iteration}") + full_path = os.path.join(results_folder, f"{iteration}") os.makedirs(full_path, exist_ok=True) # exist_ok=True, no need to error handle self.last_scenario = full_path @@ -75,9 +75,9 @@ def parse_json( """ if not self.results_path: - self._create_run_folder() + self._create_run_folder(scenario) - self._create_scenario_folder(scenario, iteration, self.results_path) + self._create_scenario_folder(iteration, self.results_path) # save the definition as a new file if save_def and isinstance(json_, dict): @@ -87,3 +87,14 @@ def parse_json( json.dump(json_, f) self._scenario_decoder.parse_scenario(json_, self.last_scenario) + + def cleanup_xml(self) -> None: + """Cleanup the .xml files left over by the scenario execution.""" + + full_paths = [ + f"{self.last_scenario}/route.xml", + f"{self.last_scenario}/scenario.xml", + ] + + for path in full_paths: + os.remove(path)