Skip to content

Commit

Permalink
Skip module sanity checking when module resolution is off
Browse files Browse the repository at this point in the history
  • Loading branch information
ekouts committed Nov 29, 2023
1 parent 5986ed5 commit 7e09c0d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 deletions.
58 changes: 43 additions & 15 deletions reframe/core/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,22 @@ class ModulesSystem:
module_map = fields.TypedField(types.Dict[str, types.List[str]])

@classmethod
def create(cls, modules_kind=None):
def create(cls, modules_kind=None, module_resolution=True):
getlogger().debug(f'Initializing modules system {modules_kind!r}')
if modules_kind is None or modules_kind == 'nomod':
return ModulesSystem(NoModImpl())
elif modules_kind == 'tmod31':
return ModulesSystem(TMod31Impl())
return ModulesSystem(TMod31Impl(module_resolution))
elif modules_kind == 'tmod':
return ModulesSystem(TModImpl())
return ModulesSystem(TModImpl(module_resolution))
elif modules_kind == 'tmod32':
return ModulesSystem(TModImpl())
return ModulesSystem(TModImpl(module_resolution))
elif modules_kind == 'tmod4':
return ModulesSystem(TMod4Impl())
return ModulesSystem(TMod4Impl(module_resolution))
elif modules_kind == 'lmod':
return ModulesSystem(LModImpl())
return ModulesSystem(LModImpl(module_resolution))
elif modules_kind == 'spack':
return ModulesSystem(SpackImpl())
return ModulesSystem(SpackImpl(module_resolution))
else:
raise ConfigError('unknown module system: %s' % modules_kind)

Expand Down Expand Up @@ -585,7 +585,12 @@ class TModImpl(ModulesSystemImpl):

MIN_VERSION = (3, 2)

def __init__(self):
def __init__(self, module_resolution=True):
if not module_resolution:
# The module system may not be available locally
self._version = None
return

# Try to figure out if we are indeed using the TCL version
try:
completed = osext.run_command('modulecmd -V')
Expand Down Expand Up @@ -717,7 +722,14 @@ class TMod31Impl(TModImpl):

MIN_VERSION = (3, 1)

def __init__(self):
def __init__(self, module_resolution=True):
self._version = None
self._command = None

if not module_resolution:
# The module system may not be available locally
return

# Try to figure out if we are indeed using the TCL version
try:
modulecmd = os.getenv('MODULESHOME')
Expand Down Expand Up @@ -792,7 +804,13 @@ class TMod4Impl(TModImpl):

MIN_VERSION = (4, 1)

def __init__(self):
def __init__(self, module_resolution=True):
self._version = None
self._extra_module_paths = []
if not module_resolution:
# The module system may not be available locally
return

try:
completed = osext.run_command(self.modulecmd('-V'), check=True)
except OSError as e:
Expand Down Expand Up @@ -915,7 +933,13 @@ def searchpath_remove(self, *dirs):
class LModImpl(TMod4Impl):
'''Module system for Lmod (Tcl/Lua).'''

def __init__(self):
def __init__(self, module_resolution=True):
self._extra_module_paths = []
self._version = None
if not module_resolution:
# The module system may not be available locally
return

# Try to figure out if we are indeed using LMOD
self._lmod_cmd = os.getenv('LMOD_CMD')
if self._lmod_cmd is None:
Expand Down Expand Up @@ -945,8 +969,6 @@ def __init__(self):
raise ConfigError('Python is not supported by '
'this Lmod installation')

self._extra_module_paths = []

def name(self):
return 'lmod'

Expand Down Expand Up @@ -1094,7 +1116,14 @@ class SpackImpl(ModulesSystemImpl):
'''

def __init__(self):
def __init__(self, module_resolution=True):
self._name_format = '{name}/{version}-{hash}'
self._version = None

if not module_resolution:
# The module system may not be available locally
return

# Try to figure out if we are indeed using the TCL version
try:
completed = osext.run_command('spack -V')
Expand All @@ -1103,7 +1132,6 @@ def __init__(self):
'could not find a sane Spack installation') from e

self._version = completed.stdout.strip()
self._name_format = '{name}/{version}-{hash}'

def name(self):
return 'spack'
Expand Down
7 changes: 4 additions & 3 deletions reframe/core/systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,12 @@ class System(jsonext.JSONSerializable):

def __init__(self, name, descr, hostnames, modules_system,
preload_env, prefix, outputdir,
resourcesdir, stagedir, partitions):
resourcesdir, stagedir, partitions, module_resolution):
getlogger().debug(f'Initializing system {name!r}')
self._name = name
self._descr = descr
self._hostnames = hostnames
self._modules_system = ModulesSystem.create(modules_system)
self._modules_system = ModulesSystem.create(modules_system, module_resolution)
self._preload_env = preload_env
self._prefix = prefix
self._outputdir = outputdir
Expand Down Expand Up @@ -590,7 +590,8 @@ def create(cls, site_config):
outputdir=site_config.get('systems/0/outputdir'),
resourcesdir=site_config.get('systems/0/resourcesdir'),
stagedir=site_config.get('systems/0/stagedir'),
partitions=partitions
partitions=partitions,
module_resolution=site_config.get('general/resolve_module_conflicts')
)

@property
Expand Down

0 comments on commit 7e09c0d

Please sign in to comment.