Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hierarchical module naming scheme categorizing modulefiles by 'moduleclass' #1176

Merged
merged 12 commits into from Feb 16, 2015

Conversation

geimer
Copy link
Contributor

@geimer geimer commented Feb 12, 2015

NOTE: This PR depends on #1163

This is an enhanced hierarchical module naming scheme which uses the moduleclass easyconfig parameter to further categorize modulefiles on each level of the hierarchy.

@fgeorgatos, @pforai: here you go :-)

by 'moduleclass' easyconfig parameter on each level of the hierarchy
@hpcugentbot
Copy link
Contributor

Automatic reply from Jenkins: Can I test this?

@fgeorgatos
Copy link
Collaborator

hooray! nice contribution Markus, thanks;

My assumption is that most phys/chem HPC shops would much prefer a namespace of this type.

(and now we need to convince @ocaisa for sharing the other alternative toolchain namespace, so that we can cook hybrids of these ideas)

# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
Copy link
Collaborator

Choose a reason for hiding this comment

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

as I see it, this is 3-clause BSD, no? http://en.wikipedia.org/wiki/BSD_licenses

It would be nice if it was stated as such somewhere (just me pipedreaming here that all devs would do the same)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fgeorgatos: Yes, it is 3-clause BSD. I'm so used to it that I thought it was obvious ;-) Not sure where to best add such a statement, though.

Copy link
Member

Choose a reason for hiding this comment

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

just add an extra comment line, mentioning something like:

# License: 3-clause BSD
# Author: Markus Geimer (JSC)

Copy link
Member

Choose a reason for hiding this comment

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

ok, you already have the author bit below, so just an extra comment for the license part is sufficient

@fgeorgatos
Copy link
Collaborator

visual review, all looks good. TBC.

@boegel
Copy link
Member

boegel commented Feb 13, 2015

We need to get this integrated in the unit tests somehow, to make sure we don't break it in the future.

There are several test modules that now test HierachicalMNS:

test/framework//easyblock.py:520:        Make sure that modules under the HierarchicalMNS are correct,
test/framework//easyblock.py:532:        os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = 'HierarchicalMNS'
test/framework//easyblock.py:543:        # example: for imkl on top of iimpi toolchain with HierarchicalMNS, no module load statements should be included
test/framework//module_generator.py:399:        os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = 'HierarchicalMNS'
test/framework//modules.py:258:        os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = 'HierarchicalMNS'
test/framework//options.py:439:            'module-naming-schemes': ['EasyBuildMNS', 'HierarchicalMNS'],
test/framework//options.py:723:            '--module-naming-scheme=HierarchicalMNS',
test/framework//options.py:1219:        for extra_args in [[], ['--module-naming-scheme=HierarchicalMNS']]:
test/framework//toy_build.py:524:            '--module-naming-scheme=HierarchicalMNS',
test/framework//utilities.py:215:        # a flat scheme like EasyBuildMNS and a hierarhical one like HierarchicalMNS doesn't work

Not all of these need to also test this new MNS, but it should be tested in one or two places at least.

@geimer: Are you up for that? If not, I can look into it (not sure how soon though).

@boegel
Copy link
Member

boegel commented Feb 13, 2015

Jenkins: ok to test

paths = []
for path in basepaths:
for moduleclass in known_module_classes:
paths.extend([os.path.join(path, moduleclass)])
Copy link
Member

Choose a reason for hiding this comment

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

this is pretty much copy-paste of det_modpath_extensions, so the body should be fleshed out in another method or function like categorise_paths(paths), which is simply called twice

we already have enough LoC to take care of ;)

Copy link
Member

Choose a reason for hiding this comment

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

or, alternatively, collapse this into a single line using a Python list comprehension:

paths = [os.path.join(p, mc) for p in basepaths for mc in known_module_classes]

Copy link
Member

Choose a reason for hiding this comment

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

and then you don't even need paths or a separate categorize_paths() anymore, just return the list straight away :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Lovely meeting of Python with the functional languages world ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest, your suggestion looks more like perl than Python... looks awful...

Since I'm in favor of readable code, I opt for the separate method (which in fact makes sense -- and I don't know why I didn't think of it myself).

Copy link
Member

Choose a reason for hiding this comment

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

this is a pretty clean list comprehension, we have many others... ;-)

but sure, go ahead and do it via a separate method then, I don't feel strongly about making it a list comprehension, since I won't have to maintain this bit ;)

@ocaisa
Copy link
Member

ocaisa commented Feb 13, 2015

@fgeorgatos It's sitting there waiting for your attention ;) #1168

@boegel
Copy link
Member

boegel commented Feb 13, 2015

@ocaisa: I've just reviewed #1168

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1336/
Test PASSed.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1342/
Test PASSed.

@boegel
Copy link
Member

boegel commented Feb 13, 2015

@geimer: the best location for a test is probably test/framework/module_generator.py, see test_hierarchical_mns

@geimer
Copy link
Contributor Author

geimer commented Feb 13, 2015

@boegel: That's what I thought, too. Just staring at it and trying to understand. The first part is quite clear, but what is the final part after the

os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = self.orig_module_naming_scheme

good for?

@boegel
Copy link
Member

boegel commented Feb 13, 2015

@geimer: leave that in, it restores whatever module naming scheme was active before running the tests

@geimer
Copy link
Contributor Author

geimer commented Feb 13, 2015

That's understood. I was actually wondering why the test is verifying some things again afterwards, assuming that the original naming scheme is the "traditional" one.

@boegel
Copy link
Member

boegel commented Feb 13, 2015

@geimer: it's checking whether the default naming scheme setting is being honored, which is why the tests shouldn't be picking up any user config files :)

@geimer
Copy link
Contributor Author

geimer commented Feb 13, 2015

Shouldn't this be in a separate test method then? I mean, test_hierarchical_mns somehow implies that the test is testing the hierarchical module naming scheme. But apparently it's doing more. So why not have a separate test_easybuild_mns? The nested test_ec should then probably be moved outside to avoid code duplication.

@boegel
Copy link
Member

boegel commented Feb 13, 2015

@geimer: yes, you're probably right, that could be cleaned up, indeed; I guess it's also checking whether restoring the default MNS actually works

@geimer
Copy link
Contributor Author

geimer commented Feb 14, 2015

@boegel: I now integrated a test into the existing method. Assuming that @ocaisa adds a test there too, refactoring should probably be done in a separate PR afterwards to simplify merging.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1346/
Test PASSed.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1350/
Test FAILed.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1352/
Test PASSed.

@boegel
Copy link
Member

boegel commented Feb 15, 2015

@geimer: just gave this another review, looks great.

The only thing, as discussed off-PR: let's isolate the test modules specific to CategorizedHMNS in a subdirectory of test/framework/modules?

You can enhance setup_hierarchical_modules in test/framework/utilities.py as follows:

def setup_hierarchical_modules(self, subdir=None):
    """Setup hierarchical modules to run tests on."""
    if subdir is not None:
        mod_prefix = os.path.join(self.test_installpath, 'modules', 'all', subdir)
    else:
        mod_prefix = os.path.join(self.test_installpath, 'modules', 'all')

and then call setup_hierarchical_modules(subdir='CategorizedHMNS') before testing your MNS

@geimer
Copy link
Contributor Author

geimer commented Feb 15, 2015

@boegel: There is a little bit more to be done than just modifying mod_prefix. Thus, creating a setup_categorized_modules method.

@boegel
Copy link
Member

boegel commented Feb 15, 2015

@geimer: that should be setup_categorized_hmns_modules?

@geimer
Copy link
Contributor Author

geimer commented Feb 15, 2015

@boegel: Then setup_hierarchical_modules should have been setup_hierarchical_mns_modules, no? ;-)

I'm happy to rename setup_categorized_modules as suggested. Though renaming setup_hierarchical_modules should be done in a separate PR.

@boegel
Copy link
Member

boegel commented Feb 15, 2015

I'm just saying you're using a hierarchical MNS too, so only calling it categorised is misleading.

So, setup_categorized_hierarchical_modules is another option. ;-)

@geimer
Copy link
Contributor Author

geimer commented Feb 15, 2015

Ah, got your point. Makes sense.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1358/
Test PASSed.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1360/
Test FAILed.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1363/
Test PASSed.

@geimer
Copy link
Contributor Author

geimer commented Feb 16, 2015

@boegel: Unless you see a need for enhancing even more unit tests for the CategorizedHMNS, I'd say this PR is good for review.

@boegel
Copy link
Member

boegel commented Feb 16, 2015

@geimer: this looks great, thanks for all the effort! Going in!

@ocaisa: if you need inspiration for adding tests for your PR #1168, checkout the diff here

boegel added a commit that referenced this pull request Feb 16, 2015
Hierarchical module naming scheme categorizing modulefiles by 'moduleclass'
@boegel boegel merged commit da5762f into easybuilders:develop Feb 16, 2015
@geimer geimer deleted the categorized_hmns branch February 16, 2015 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants