Skip to content

add support for Environment Modules 4#2365

Merged
boegel merged 22 commits intoeasybuilders:developfrom
ebagrenrut:env-modules-4
Jan 5, 2018
Merged

add support for Environment Modules 4#2365
boegel merged 22 commits intoeasybuilders:developfrom
ebagrenrut:env-modules-4

Conversation

@ebagrenrut
Copy link
Copy Markdown
Contributor

Add a new class EnvironmentModules4. Introduces a MAX_VERSION to ModulesTool that can be used to set a maximum version for a particular module tool. Limits EnvironmentModulesC to a maximum version of 3.2.10 (the last release of the C implementation of Environment Modules). Limits EnvironmentModulesTcl to a maximum version of 1.923 (the last version of modules-tcl).

Comment thread easybuild/tools/modules.py Outdated
if self.REQ_VERSION is None:
self.log.debug("No version requirement defined.")
if self.REQ_VERSION is None and self.MAX_VERSION is None:
self.log.debug("No version requirement defined.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the extra indent here?

Comment thread easybuild/tools/modules.py Outdated
if StrictVersion(self.version) < StrictVersion(self.REQ_VERSION):
raise EasyBuildError("EasyBuild requires v%s >= v%s (no rc), found v%s",
self.__class__.__name__, self.REQ_VERSION, self.version)
if self.REQ_VERSION is None: # MAX_VERSION is not None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check directly whether self.MAX_VERSION is different from None?

elif self. MAX_VERSION is not None:

Comment thread easybuild/tools/modules.py Outdated
self.__class__.__name__, self.version, self.MAX_VERSION)
else:
self.log.debug('Version %s matches requirement <= %s' % (self.version, self.MAX_VERSION))
elif self.MAX_VERSION is None: # REQ_VERSION is not None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should change this to an if, to make sure that if both self.REQ_VERSION and self.MAX_VERSION are specified, that both are checked?

if self. REQ_VERSION is not None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, my logic is broken. Will fix.

Comment thread easybuild/tools/modules.py Outdated
if self.REQ_VERSION is None: # MAX_VERSION is not None
self.log.debug("No required minimum version defined.")
if StrictVersion(self.version) > StrictVersion(self.MAX_VERSION):
raise EasyBuildError("EasyBuild requires v%s <= v%s (no rc), found v%s",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably drop the no rc part here, since using a release candidate of the highest allowed version is older than that version, so it's OK to use it.

Comment thread easybuild/tools/modules.py Outdated
raise EasyBuildError("EasyBuild requires v%s <= v%s (no rc), found v%s",
self.__class__.__name__, self.version, self.MAX_VERSION)
else:
self.log.debug('Version %s matches requirement <= %s' % (self.version, self.MAX_VERSION))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nitpicking: Please use , rather than %:

self.log.debug('Version %s matches requirement <= %s', self.version, self.MAX_VERSION)

Comment thread easybuild/tools/modules.py Outdated
raise EasyBuildError("EasyBuild requires v%s >= v%s (no rc), found v%s",
self.__class__.__name__, self.REQ_VERSION, self.version)
else:
self.log.debug('Version %s matches requirement >= %s' % (self.version, self.REQ_VERSION))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use , rather than %:

self.log.debug('Version %s matches requirement >= %s', self.version, self.REQ_VERSION)

Comment thread easybuild/tools/modules.py Outdated
if StrictVersion(self.REQ_VERSION) > StrictVersion(self.MAX_VERSION):
raise EasyBuildError("v%s, REQ_VERSION must be <= MAX_VERSION", self.__class__)
else:
self.log.debug('Version %s matches requirements >= %s, <= %s' % (self.version, self.REQ_VERSION, self.MAX_VERSION))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would drop this whole block, and use two if conditions above.

Comment thread easybuild/tools/modules.py Outdated
"""Interface to (C) environment modules (modulecmd)."""
COMMAND = "modulecmd"
REQ_VERSION = '3.2.10'
MAX_VERSION = '3.2.10'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a bit more liberal, in case people have local made local modifications and bumped this version.

MAX_VERSION = '3.99'  # fictional version, just to indicate that version 4.0.0 and up are not compatible

Comment thread easybuild/tools/modules.py Outdated
"""Update after new modules were added."""
pass

class EnvironmentModules4(EnvironmentModulesC):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe EnvironmentModulesTcl4 is a better name?

Comment thread easybuild/tools/modules.py Outdated
COMMAND_SHELL = ['tclsh']
VERSION_OPTION = ''
REQ_VERSION = None
MAX_VERSION = '1.923'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave this unspecified, there's little point to it?

If somebody uses EnvironmentModulesTcl with Modules v4.0, it will fail anyway because eb can't determine the version?

…ed the hastily-named EnvironmentModules4 class until there is a better implementation. Style corrections.
…tead of string concatenation. Add a second blank line after EnvironmentModules class to match style of other classes.
Comment thread easybuild/tools/modules.py Outdated

class EnvironmentModules(EnvironmentModulesTcl):
"""Interface to environment modules 4.0+"""
COMMAND = os.path.join(os.environ['MODULESHOME'], 'libexec', 'modulecmd.tcl')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done more carefully, if $MODULESHOME is not defined, this will lead to a nasty crash/traceback.

My suggestion is to use a fallback value, like this:

COMMAND = os.path.join(os.getenv('MODULESHOME', 'MODULESHOME_NOT_DEFINED'), 'libexec', 'modulecmd.tcl')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DO we need both MODULESHOME and MODULESHOME_NOT_DEFINED? If using os.getenv and MODULESHOME is undefined, None will be returned and the traceback won't occur. In that case, eb would look for None/libexec/modulecmd.tcl and throw an exception.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebagrenrut Yes, we need the fallback value, since os.path.join won't be happy with the None value:

>>> os.path.join(None, 'libexec', 'modulecmd.tcl')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 70, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'

boegel and others added 6 commits December 29, 2017 10:37
also test against Modules v4
…ad of os.environment when getting value of MODULESHOME. The latter results in a traceback if MODULESHOME is undefined.
ebagrenrut and others added 6 commits December 29, 2017 13:51
…odule purge. It causes an extraneous argument error with Modules 4+
don't pass empty argument to 'module purge'
…(>=4.0) like EnvironmentModulesTcl (<=1.293)
…(>=4.0) like EnvironmentModulesTcl (<=1.293)
…s 4+ behaves similarly to ModulesC, so also append GCCcore/6.2.0 if we are an instance of EnvironmentModules
@easybuilders easybuilders deleted a comment from boegelbot Dec 30, 2017
@boegel boegel changed the title First attempt at support for Environment Modules 4 add support for Environment Modules 4 Dec 30, 2017
update test_load, Modules v4.0 does not reload already loaded modules
@easybuilders easybuilders deleted a comment from boegelbot Jan 4, 2018
@boegel
Copy link
Copy Markdown
Member

boegel commented Jan 4, 2018

@ebagrenrut The last failing test is because the bootstrap script is not aware of the new EnvironmentModules class yet.

That's not hard to fix, but when that is fixed there's another problem: the test for the bootstrap script will still fail because it will try to install the latest EasyBuild release (v3.5.0), which doesn't know about EnvironmentModules yet. This leads to:

eb: error: option --modules-tool: invalid choice: 'EnvironmentModules' (choose from 'EnvironmentModulesC', 'EnvironmentModulesTcl', 'Lmod')

In other words, a chicken-or-egg problem.

So, I think we should just bypass the testing of the bootstrap script for now under EnvironmentModules, and open another PR to fix the bootstrap script once EasyBuild v3.5.1 (which includes this PR that adds support for Modules v4).

@boegel
Copy link
Copy Markdown
Member

boegel commented Jan 5, 2018

@ebagrenrut Change in Travis config file to bypass testing of bootstrap script done in ebagrenrut#4.

boegel and others added 2 commits January 5, 2018 09:48
disable testing of bootstrap script when Modules v4 is used as modules tool
@easybuilders easybuilders deleted a comment from boegelbot Jan 5, 2018
@boegel
Copy link
Copy Markdown
Member

boegel commented Jan 5, 2018

This looks good to go now, thanks for you help with this @ebagrenrut and @xdelaruelle!

I'll follow up with another PR to re-enable testing of the bootstrap script with Modules v4, which can only be merged once EasyBuild v3.5.1 is released...

@boegel boegel merged commit 596dbc8 into easybuilders:develop Jan 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants