Skip to content

Commit

Permalink
Skip module init
Browse files Browse the repository at this point in the history
  • Loading branch information
ekouts committed Nov 21, 2023
1 parent e963330 commit b54ba5c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 28 deletions.
61 changes: 40 additions & 21 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,9 +585,11 @@ class TModImpl(ModulesSystemImpl):

MIN_VERSION = (3, 2)

def __init__(self):
# FIXME
return
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:
Expand Down Expand Up @@ -720,9 +722,13 @@ class TMod31Impl(TModImpl):

MIN_VERSION = (3, 1)

def __init__(self):
# FIXME
return
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:
Expand Down Expand Up @@ -798,9 +804,12 @@ class TMod4Impl(TModImpl):

MIN_VERSION = (4, 1)

def __init__(self):
# FIXME
return
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)
Expand Down Expand Up @@ -924,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 @@ -954,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 @@ -1103,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 @@ -1112,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
15 changes: 11 additions & 4 deletions reframe/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,13 @@ def _setup_paths(self):
except OSError as e:
raise PipelineError('failed to set up paths') from e

def _create_job(self, job_type, force_local=False, clean_up_stage=False, **job_opts):
def _create_job(
self,
job_type,
force_local=False,
clean_up_stage=False,
**job_opts
):
'''Setup the job related to this check.'''

if force_local:
Expand Down Expand Up @@ -1696,9 +1702,10 @@ def _create_job(self, job_type, force_local=False, clean_up_stage=False, **job_o
**job_opts)

def _setup_build_job(self, clean_up_stage=False, **job_opts):
self._build_job = self._create_job(
'build', self.local or self.build_locally, clean_up_stage, **job_opts
)
self._build_job = self._create_job('build',
self.local or self.build_locally,
clean_up_stage,
**job_opts)

def _setup_run_job(self, clean_up_stage=False, **job_opts):
self._job = self._create_job(f'run', self.local, **job_opts)
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 b54ba5c

Please sign in to comment.