From b54ba5cc25349aa0a4a2f5d82f2dfb25c9dbcca3 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Tue, 21 Nov 2023 09:57:14 +0100 Subject: [PATCH] Skip module init --- reframe/core/modules.py | 61 ++++++++++++++++++++++++++-------------- reframe/core/pipeline.py | 15 +++++++--- reframe/core/systems.py | 7 +++-- 3 files changed, 55 insertions(+), 28 deletions(-) diff --git a/reframe/core/modules.py b/reframe/core/modules.py index 766218c921..056e04320e 100644 --- a/reframe/core/modules.py +++ b/reframe/core/modules.py @@ -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) @@ -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: @@ -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: @@ -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) @@ -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: @@ -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' @@ -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') @@ -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' diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index a9dd6254d7..7adfb48b16 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -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: @@ -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) diff --git a/reframe/core/systems.py b/reframe/core/systems.py index 53ed8ad40b..8fef375a4c 100644 --- a/reframe/core/systems.py +++ b/reframe/core/systems.py @@ -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 @@ -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