Skip to content

Commit 0d0f545

Browse files
Merge pull request #99 from Intelligent-Testing-Lab/rebuild
force rebuild
2 parents e4c2ed3 + ebb0344 commit 0d0f545

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

‎aw_scenario_runner.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ def run(self) -> None:
339339
f"Scenario iteration {iteration} achieved a score of {driving_score}"
340340
)
341341

342+
# clean up - delete XML files
343+
self.results_manager.cleanup_xml()
344+
342345
# read the scenario definition
343346
if not self.DEV_MODE:
344347
self.json_definition = self.algorithm._scenario_callback(

‎config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ scenario_runner:
2424
initialisation_budget: 200 # ticks
2525
algorithm:
2626
iterations: 10
27-
path: algorithms/test_alg
27+
path: algorithms/hill_climb
2828
args: # will be passed into the algorithm class as a dict
2929
lanelet_path: /autoware_scenario_runner/algorithms/resources/Town01.osm
3030
radius: 10

‎srunner/tools/results_manager.py‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, output_dir: str = "results") -> None:
1717
self.results_path = ""
1818
self._scenario_decoder = XMLToFiles()
1919

20-
def _create_run_folder(self, base_path: str = ""):
20+
def _create_run_folder(self, scenario: str, base_path: str = ""):
2121
"""Creates a experiment folder under base_path. The naming convention is as follows
2222
```
2323
run-{yy-mm-dd-h-m-s}
@@ -33,15 +33,15 @@ def _create_run_folder(self, base_path: str = ""):
3333
base_path = self.output_dir
3434

3535
now = datetime.datetime.now()
36-
full_path = os.path.join(base_path, f"run-{now.strftime('%Y-%m-%d-%H-%M-%S')}") # type: ignore
36+
full_path = os.path.join(
37+
base_path, f"{scenario}-{now.strftime('%Y-%m-%d-%H-%M-%S')}"
38+
) # type: ignore
3739

3840
os.makedirs(full_path, exist_ok=True) # exist_ok=True, no need to error handle
3941
self.results_path = full_path
4042
return full_path
4143

42-
def _create_scenario_folder(
43-
self, scenario: str, iteration: str, results_folder: str
44-
):
44+
def _create_scenario_folder(self, iteration: str, results_folder: str):
4545
"""Creates a folder to hold the results of a individual scenario execution.
4646
The naming convention is as follows
4747
```
@@ -57,7 +57,7 @@ def _create_scenario_folder(
5757
_type_: _description_
5858
"""
5959

60-
full_path = os.path.join(results_folder, f"{scenario}-{iteration}")
60+
full_path = os.path.join(results_folder, f"{iteration}")
6161

6262
os.makedirs(full_path, exist_ok=True) # exist_ok=True, no need to error handle
6363
self.last_scenario = full_path
@@ -75,9 +75,9 @@ def parse_json(
7575
"""
7676

7777
if not self.results_path:
78-
self._create_run_folder()
78+
self._create_run_folder(scenario)
7979

80-
self._create_scenario_folder(scenario, iteration, self.results_path)
80+
self._create_scenario_folder(iteration, self.results_path)
8181

8282
# save the definition as a new file
8383
if save_def and isinstance(json_, dict):
@@ -87,3 +87,14 @@ def parse_json(
8787
json.dump(json_, f)
8888

8989
self._scenario_decoder.parse_scenario(json_, self.last_scenario)
90+
91+
def cleanup_xml(self) -> None:
92+
"""Cleanup the .xml files left over by the scenario execution."""
93+
94+
full_paths = [
95+
f"{self.last_scenario}/route.xml",
96+
f"{self.last_scenario}/scenario.xml",
97+
]
98+
99+
for path in full_paths:
100+
os.remove(path)

0 commit comments

Comments
 (0)