From 3b82062d359256fe0e63bc50dfdcc719d12280cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schm=C3=B6lder?= <j.schmoelder@fz-juelich.de> Date: Sat, 16 Mar 2024 16:08:13 +0100 Subject: [PATCH] Change directory when running study --- cadetrdm/batch_runner.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cadetrdm/batch_runner.py b/cadetrdm/batch_runner.py index ef9209b..8f0e1f2 100644 --- a/cadetrdm/batch_runner.py +++ b/cadetrdm/batch_runner.py @@ -1,4 +1,5 @@ import importlib +import os from pathlib import Path import sys @@ -126,6 +127,9 @@ class Case: return try: + cur_dir = os.getcwd() + + os.chdir(self.study.path) sys.path.append(str(self.study.path)) module = importlib.import_module(self.study.name) @@ -137,6 +141,7 @@ class Case: self.status = 'finished' sys.path.remove(str(self.study.path)) + os.chdir(cur_dir) except (KeyboardInterrupt, Exception) as e: print(f"Command execution failed: {e}") -- GitLab