From 4074cc5402d1727fe5670adb1cf9567d10e0836f Mon Sep 17 00:00:00 2001 From: "felix.tomski" Date: Tue, 31 Oct 2023 09:06:00 +0100 Subject: [PATCH] Propagate module-path option to shell script creation --- reframe/core/modules.py | 33 ++++++++++++++++++++------------- reframe/core/runtime.py | 1 + 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/reframe/core/modules.py b/reframe/core/modules.py index 5fc41cac00..8a82de2511 100644 --- a/reframe/core/modules.py +++ b/reframe/core/modules.py @@ -367,6 +367,13 @@ def version(self): '''The version of this module system.''' return self._backend.version() + @property + def emit_extra_module_paths(self): + '''Emit extra module paths.''' + if hasattr(self._backend, '_extra_module_paths'): + return self._backend._emit_extra_module_paths() + return [] + def unload_all(self): '''Unload all loaded modules.''' return self._backend.unload_all() @@ -624,6 +631,7 @@ def __init__(self): if re.search(r'Unknown shell type', completed.stderr): raise ConfigError( 'Python is not supported by this TMod installation') + self._extra_module_paths = [] def name(self): return 'tmod' @@ -691,10 +699,12 @@ def searchpath(self): def searchpath_add(self, *dirs): if dirs: + self._extra_module_paths += [('+', mp) for mp in dirs] self.execute('use', *dirs) def searchpath_remove(self, *dirs): if dirs: + self._extra_module_paths += [('-', mp) for mp in dirs] self.execute('unuse', *dirs) def emit_load_instr(self, module): @@ -711,6 +721,16 @@ def emit_load_instr(self, module): def emit_unload_instr(self, module): return [f'module unload {module}'] + def _emit_extra_module_paths(self): + cmds = [] + for op,mp in self._extra_module_paths: + if op == '+': + cmds.append(f'module use {mp}') + elif op == '-': + cmds.append(f'module unuse {mp}') + + return cmds + class TMod31Impl(TModImpl): '''Module system for TMod (Tcl).''' @@ -820,7 +840,6 @@ def __init__(self): (version, self.MIN_VERSION)) self._version = version - self._extra_module_paths = [] def name(self): return 'tmod4' @@ -899,18 +918,6 @@ def emit_unload_instr(self, module): return super().emit_unload_instr(module) - def searchpath_add(self, *dirs): - if dirs: - self._extra_module_paths += [('+', mp) for mp in dirs] - - super().searchpath_add(*dirs) - - def searchpath_remove(self, *dirs): - if dirs: - self._extra_module_paths += [('-', mp) for mp in dirs] - - super().searchpath_remove(*dirs) - class LModImpl(TMod4Impl): '''Module system for Lmod (Tcl/Lua).''' diff --git a/reframe/core/runtime.py b/reframe/core/runtime.py index 9ff0db004e..82c1af7c92 100644 --- a/reframe/core/runtime.py +++ b/reframe/core/runtime.py @@ -241,6 +241,7 @@ def _load_cmds_tracked(**module): modules_system = runtime().modules_system env_snapshot = snapshot() commands = [] + commands += modules_system.emit_extra_module_paths for env in environs: for cmd in env.prepare_cmds: commands.append(cmd)