lmod : support for hierarchical modules#107
Conversation
lib/spack/spack/modules.py
Outdated
There was a problem hiding this comment.
@alalazo: You can actually simplify this whole loop to this:
if not 'mpi' in spec:
raise RuntimeError('No MPI dependency found')
mpi_name = spec['mpi'].name
mpi_version = spec['mpi'].version
The above is actually more correct, as well, because spec.dependencies is just the direct deps. If you want all dependencies you want to look at Spec.traverse(), which will walk the DAG for you. Spec.__contains__ does this automatically and tests each dep to see if it satisfies the argument (which is why 'mpi' in spec works).
Maybe this is better illustrated in an example:
>>> from spack.spec import Spec
>>> from spack.graph import graph_ascii
>>> s = Spec('adept-utils')
>>> s.normalize()
>>> graph_ascii(s)
o adept-utils
|\
o | mpi
/
o boost
>>> 'mpi' in s
True
>>> 'mpich' in s
False
>>> 'openmpi' in s
False
>>> s.concretize()
>>> graph_ascii(s)
o adept-utils
|\
o | mpich
/
o boost
>>> 'mpi' in s
True
>>> 'mpich' in s
True
>>> 'openmpi' in s
False
There was a problem hiding this comment.
You are right, the loop is definitely not necessary. I also removed the raise, as the conditional already checks that 'mpi' is in the spec.
|
I haven't had a chance to test this but it looks great (and pretty straightforward) to me. I could see extending this with a syntax to describe different hierarchical schemes (e.g. not just mpi/compiler/etc.). If you can address some of the comments and push changes, I think this is pretty close to being merged into develop with preliminary support. I'll probably add something to disable/enable certain types of modules in the config file, as well, since Spack now does three types and I'm not sure everyone wants them all. One more question: Are there edits that need to be made to |
If you have already a clear idea in mind, I am available to extend this implementation.
To my knowledge will set-up a configuration where This brings me a couple question:
|
|
I still need to implement: @property
def use_name(self):
# FIXME : this needs to be implemented. It seems to be used only in module.module_find(m_type, spec_array)
passWhat is this function used for? |
I have some ideas but not enough to constitute a 'spec'. So let's go with your version for now and I can add some configurability later.
Ok cool -- I think this is fine. I can add some configurable options to select between the TCL module and Lmod.
I think the first one's fine. Most people will want Lmod to be hierarchical.
Yes, please. |
|
|
I implemented In fact and sometimes you may access to a module in multiple ways (as in the example above, where hdf5/1.8.13 is compiled using either default compiler over mpich or gcc 5.2.0 over mpich) |
|
I took a look at this, there's a lot of different things going on here at the same time:
I'm not sure whether you want to be doing everything at the same time (although the combination sure makes sense). As @tgamblin already mentioned, this also hard-codes to the traditional The support for using Lmod as a modules tool (i.e., to use Since I was involved with much of the support for using Lmod, generating module files in Lua syntax and supporting hierarchical modules in EasyBuild, I'm aware of the hoops you need to make Spack jump through. I'm happy to answer any questions. The paper on using Lmod and a module hierarchy I'm a co-author of is a good read to get a good view on this, see http://hpcugent.github.io/easybuild/files/hust14_paper.pdf . |
|
@boegel : many thanks for taking the time to review and comment on this PR.
This changeset addresses only two of the three aspects you cited, that is the support for using a hierarchical module naming scheme and for writing module files in Lua syntax. I merged together those two aspects mainly because:
Do you see relevant use cases where it would it make sense to use Lmod with "traditional" TCL modulefiles, or where one would use
I agree that having more flexibility would be nice, but I don't see an easy way at the moment to go far ahead of what is in this PR. As I see it 'levels' in a hierarchical naming scheme maps directly to virtual dependencies (you have 'compiler', 'mpi', 'blas', etc.). Having the traditional Core/Compiler/MPI hierarchy covers a good part of our use cases, and is pretty straightforward. Adding other things to the mix (like 'blas', 'lapack', 'cuda', etc.) naturally calls for a better support of a dependency matrix, where things should be visible only if providers of all their virtual dependencies are loaded. As far as I understood this is still an open area of research for Lmod. How do you deal in EasyBuild with this case?
I guess module files generation and support for the delegation to a module tool (e.g. |
|
@tgamblin Do you think this PR misses anything to be merged? |
|
@tgamblin Odd : this old PR seems not to be able to trigger Travis anymore... |
|
Even when you rebase it? |
|
@adamjstewart Yes |
|
@tgamblin Any chance this could be reviewed manually ? |
|
Huh, Travis works again for you too eh? |
|
Not really... it seems it's pulling a travis.yaml file from a while ago... |
Includes : - treatment of a generic hierarchy (i.e. lapack + mpi + compiler) - possibility to specify which compilers are to be considered Core - correct treatment of the 'family' directive - unit tests for most new features
0d70e27 to
9d54df0
Compare
…level-namespace Enable two level namespace with openmpi on MacOS
Modifications
lmodRelated issues / Open questions
Example
A
modules.yamlconfiguration like :will generate a hierarchical structure that extends the usual
Core/compiler/MPIstructure treatinglapackproviders the same way asmpiproviders