Change from modulecmd interface to module interface#8570
Conversation
|
I'm testing this on Blue Waters now. I can confirm that it gets rid of the pesky error message from #8193, but I'm encountering a few other problems. With Python 2.6.9: $ spack -d install zlib
...
==> Error: TypeError: 'str' object is not callable
/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/build_environment.py:694, in child_process:
691 tb_string = traceback.format_exc()
692
693 # build up some context from the offending package so we can
>> 694 # show that, too.
695 package_context = get_package_context(tb)
696
697 build_log = None
Traceback (most recent call last):
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/build_environment.py", line 676, in child_process
setup_package(pkg, dirty=dirty)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/build_environment.py", line 585, in setup_package
pkg.architecture.platform.setup_platform_environment(pkg, spack_env)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/platforms/cray.py", line 109, in setup_platform_environment
module('unload', module)
TypeError: 'str' object is not callableWith Python 3.5.4: $ spack -d install zlib
...
Traceback (most recent call last):
File "/u/sciteam/stewart1/spack/bin/spack", line 85, in <module>
sys.exit(spack.main.main())
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/main.py", line 580, in main
parser.add_command(cmd_name)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/main.py", line 288, in add_command
module = spack.cmd.get_module(cmd_name)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/cmd/__init__.py", line 128, in get_module
level=0)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/cmd/install.py", line 36, in <module>
import spack.cmd.common.arguments as arguments
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/cmd/common/arguments.py", line 30, in <module>
import spack.modules
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/modules/__init__.py", line 32, in <module>
from .dotkit import DotkitModulefileWriter
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/modules/dotkit.py", line 29, in <module>
from .common import BaseConfiguration, BaseFileLayout
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/modules/common.py", line 69, in <module>
configuration = spack.config.get('modules')
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/config.py", line 515, in get
return config.get(path, default, scope)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/llnl/util/lang.py", line 556, in __getattr__
return getattr(self.instance, name)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/llnl/util/lang.py", line 552, in instance
self._instance = self.factory()
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/config.py", line 492, in _config
platform = spack.architecture.platform().name
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/llnl/util/lang.py", line 182, in __call__
self.cache[args] = self.func(*args)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/architecture.py", line 498, in platform
return platform_cls()
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/platforms/cray.py", line 68, in __init__
for target in self._avail_targets():
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/platforms/cray.py", line 159, in _avail_targets
_fill_craype_targets_from_modules(targets, craype_modules)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/platforms/cray.py", line 48, in _fill_craype_targets_from_modules
if 'craype-' in mod:
TypeError: a bytes-like object is required, not 'str' |
|
Cool – Thank you for implementing the idea so quickly! One caveat: The approach puts the onus on local admins/users (reasonably so, I might add) to have the |
|
@adamjstewart The python 2.6.9 issue should be fixed now. It was a name shadowing issue. @mgsternberg Yes, we do have to rely on the module function to be set up reasonably for this approach to work. Out of the box modules do work properly for this, so I think it's safe to count on DIYers to know what they're doing, as you said. If it becomes an issue, we could look into using the |
|
Thanks @becker33, the Python 2 issue is now fixed. However, I'm now encountering new problems with Python 3: $ spack -d install zlib
...
==> Error: TypeError: the JSON object must be str, not 'bytes'
/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/build_environment.py:694, in child_process:
691 tb_string = traceback.format_exc()
692
693 # build up some context from the offending package so we can
>> 694 # show that, too.
695 package_context = get_package_context(tb)
696
697 build_log = None
Traceback (most recent call last):
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/build_environment.py", line 676, in child_process
setup_package(pkg, dirty=dirty)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/build_environment.py", line 585, in setup_package
pkg.architecture.platform.setup_platform_environment(pkg, spack_env)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/platforms/cray.py", line 109, in setup_platform_environment
module('unload', mod)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/util/module_cmd.py", line 48, in module
env_dict = json.loads(module_p.communicate()[0])
File "/mnt/bwpy/single/usr/lib/python3.5/json/__init__.py", line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes' |
|
@adamjstewart The python 2.6.9 issue should be fixed now. It was a name shadowing issue. @mgsternberg Yes, we do have to rely on the module function to be set up reasonably for this approach to work. Out of the box modules do work properly for this, so I think it's safe to count on DIYers to know what they're doing, as you said. If it becomes an issue, we could look into using the |
|
I'm ok with what's implemented here but I really wish there were more tests. @becker33: if you could assume that, say, @mpbelhorn @mamelara: do you mind testing this to ensure that it still works at your sites: |
|
oh and @adamjstewart: does this work well on BW now? |
|
I'll test this tomorrow or next week. Can you rebase in the meantime? |
|
Yeah, I can run some tests on this tomorrow.
Conveniently, I just started retooling our use of spack on titan with the
head of develop and am very interested in this issue.
|
|
LGTM. Tested it out on Cori and Edison. |
|
@mpbelhorn: ping |
|
Running into a problem on Titan. The It looks like the output of this line on Titan is which is not surprising to me since in my interactive shell, I would expect The only reason I didn't do this is because I didn't want to inherit the currently loaded modules when trying to probe for the system default modules and so subprocess a shell which invokes In theory, a correctly configured TCL Environment Module system should have the init scripts located at |
|
I see exactly the same behavior on Cori as I do on Titan: |
|
Just to note, I did not checkout a fresh copy of Spack so it could be that my configuration is much different. Either way something must have broke and I didn't see it with my own copy of spack. |
adamjstewart
left a comment
There was a problem hiding this comment.
Just did a quick test (spack install zlib) with Python 2.6.9 and 3.5.5 on Blue Waters. I'm still seeing the Python 3 error message:
$ spack -d install zlib %gcc
...
==> Installing zlib dependencies
==> Installing zlib
==> '/usr/bin/env' '-' 'USER=stewart1' 'HOME=/u/sciteam/stewart1' '/bin/bash' '--noprofile' '--norc' '-c' '. /etc/profile; module list -lt'
==> Found default modules:
modules/3.2.10.4
eswrap/1.3.3-1.020200.1280.0
cce/8.4.6
craype-network-gemini
craype/2.5.8
cray-libsci/16.11.1
udreg/2.3.2-1.0502.10518.2.17.gem
ugni/6.0-1.0502.10863.8.28.gem
pmi/5.0.10-1.0000.11050.179.3.gem
dmapp/7.0.1-1.0502.11080.8.74.gem
gni-headers/4.0-1.0502.10859.7.8.gem
xpmem/0.1-2.0502.64982.5.3.gem
dvs/2.5_0.9.0-1.0502.2188.1.113.gem
alps/5.2.4-2.0502.9774.31.12.gem
rca/1.0.0-2.0502.60530.1.63.gem
atp/2.0.4
PrgEnv-cray/5.2.82
cray-mpich/7.5.0
craype-interlagos
torque/6.0.4
moab/9.1.2-sles11
java/jdk1.8.0_51
globus/5.2.5
gsissh/6.2p2
xalt/0.7.6.local
scripts
OpenSSL/1.0.2m
cURL/7.59.0
git/2.17.0
wget/1.19.4
user-paths
gnuplot/5.0.5
darshan/3.1.3
==> Error: TypeError: the JSON object must be str, not 'bytes'
/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/build_environment.py:694, in child_process:
691 tb_string = traceback.format_exc()
692
693 # build up some context from the offending package so we can
>> 694 # show that, too.
695 package_context = get_package_context(tb)
696
697 build_log = None
Traceback (most recent call last):
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/build_environment.py", line 676, in child_process
setup_package(pkg, dirty=dirty)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/build_environment.py", line 585, in setup_package
pkg.architecture.platform.setup_platform_environment(pkg, spack_env)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/platforms/cray.py", line 109, in setup_platform_environment
module('unload', mod)
File "/mnt/a/u/sciteam/stewart1/spack/lib/spack/spack/util/module_cmd.py", line 48, in module
env_dict = json.loads(module_p.communicate()[0])
File "/mnt/bwpy/single/usr/lib/python3.5/json/__init__.py", line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'34a8711 to
031cf9a
Compare
|
@adamjstewart your bug should be gone now. |
|
@mpbelhorn One reason not to use the python interface to modules is that neither TCL modules nor Lmod have python3 compliant python interfaces. If we could make it work, it would be preferable to this method. |
d2527dd to
039f477
Compare
|
@floli Does this bug still manifest for you? |
|
Ok, using a fresh checkout of |
Remove a vestigial print statement introduced in #8570
Fixes #6451.
Fixes #7884.
Fixes #8193.
Update Spack core to use new
modulefunction instead ofget_module_cmdPreviously, Spack relied on either examining the bash
module()function or using thewhichcommand to find the underlying executable for modules.As @mgsternberg commented in detail on #6451, more complicated module systems do not allow for the sort of simple analysis we were doing.
This PR uses the
modulefunction directly and copies environment changes from the resulting subprocess back into Spack. This should provide a future-proof implementation for changes to the logic underlying the module system on various HPC systems.