Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate module path option to script creation #3032

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions reframe/core/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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):
Expand All @@ -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).'''
Expand Down Expand Up @@ -820,7 +840,6 @@ def __init__(self):
(version, self.MIN_VERSION))

self._version = version
self._extra_module_paths = []

def name(self):
return 'tmod4'
Expand Down Expand Up @@ -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).'''
Expand Down
1 change: 1 addition & 0 deletions reframe/core/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down