@@ -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