Skip to content

Commit

Permalink
Ensure correct configuration for EnvironmentModules
Browse files Browse the repository at this point in the history
Defines environment variables when initializing EnvironmentModules
object to ensure that this module tool will not be influenced by
external configuration.

Setup Environment Modules configuration to ensure module search behaves
like EasyBuild expects (match module name start, case sensitive, return
in-depth modulepath content, ignore cache file). Also defines a basic
output configuration not to get unexpected content like tags or
variants.

This change helps to pass "test_avail" test with Environment Modules
v5.0+.
  • Loading branch information
xdelaruelle committed Oct 29, 2023
1 parent f4dda1e commit 94ff50f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions easybuild/tools/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,29 @@ class EnvironmentModules(EnvironmentModulesTcl):
MAX_VERSION = None
VERSION_REGEXP = r'^Modules\s+Release\s+(?P<version>\d\S*)\s'

def __init__(self, *args, **kwargs):
"""Constructor, set Environment Modules-specific class variable values."""
# ensure in-depth modulepath search (MODULES_AVAIL_INDEPTH has been introduced in v4.3)
setvar('MODULES_AVAIL_INDEPTH', '1', verbose=False)
# match against module name start (MODULES_SEARCH_MATCH has been introduced in v4.3)
setvar('MODULES_SEARCH_MATCH', 'starts_with', verbose=False)
# ensure no debug message (MODULES_VERBOSITY has been introduced in v4.3)
setvar('MODULES_VERBOSITY', 'normal', verbose=False)
# make module search case sensitive (search is case insensitive by default since v5.0)
setvar('MODULES_ICASE', 'never', verbose=False)
# disable extended default (introduced in v4.4 and enabled by default in v5.0)
setvar('MODULES_EXTENDED_DEFAULT', '0', verbose=False)
# hard disable output redirection, output messages are expected on stderr
setvar('MODULES_REDIRECT_OUTPUT', '0', verbose=False)
# make sure modulefile cache is ignored (cache mechanism supported since v5.3)
setvar('MODULES_IGNORE_CACHE', '1', verbose=False)
# ensure only module names are returned on avail (MODULES_AVAIL_TERSE_OUTPUT added in v4.7)
setvar('MODULES_AVAIL_TERSE_OUTPUT', '', verbose=False)
# ensure only module names are returned on list (MODULES_LIST_TERSE_OUTPUT added in v4.7)
setvar('MODULES_LIST_TERSE_OUTPUT', '', verbose=False)

super(EnvironmentModules, self).__init__(*args, **kwargs)

def check_module_output(self, cmd, stdout, stderr):
"""Check output of 'module' command, see if if is potentially invalid."""
if "_mlstatus = False" in stdout:
Expand Down

0 comments on commit 94ff50f

Please sign in to comment.