From 325d4e99b30a9f327b3c0501c3a5b2f1fb19f715 Mon Sep 17 00:00:00 2001 From: andrius-k Date: Sun, 7 Aug 2022 15:54:29 +0000 Subject: [PATCH] Name levels directory based on the BeamNG version --- code_pipeline/beamng_executor.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/code_pipeline/beamng_executor.py b/code_pipeline/beamng_executor.py index a7e7912..e93af0d 100644 --- a/code_pipeline/beamng_executor.py +++ b/code_pipeline/beamng_executor.py @@ -128,8 +128,21 @@ def _run_simulation(self, the_test) -> SimulationData: # Override default configuration passed via ENV or hardcoded if self.beamng_user is not None: + # Parse BeamNG version + version = '0.24' + directory = self.beamng_user + if '/' in self.beamng_user: + directory = self.beamng_user.split('/')[-1] + prefix = 'BeamNG.tech.v' + if directory.startswith(prefix): + v = directory[len(prefix):len(prefix) + 4] + try: + float(v) + version = v + except: + pass # Note This changed since BeamNG.research - beamng_levels = LevelsFolder(os.path.join(self.beamng_user, '0.24', 'levels')) + beamng_levels = LevelsFolder(os.path.join(self.beamng_user, version, 'levels')) maps.beamng_levels = beamng_levels maps.beamng_map = maps.beamng_levels.get_map('tig') # maps.print_paths()