easybuilders / easybuild-framework

EasyBuild is a software installation framework in Python that allows you to install software in a structured and robust way.
https://easybuild.io
GNU General Public License v2.0
152 stars 204 forks source link

Bug in install directory when using modaltsoftname #2130

Open mboisson opened 7 years ago

mboisson commented 7 years ago

Hi, I am trying to install a 64bit version of PETSc. I use modaltsoftname to change the module name to "petsc-64bits"

I would have expected EB to install the software under a directory of the same name, but it instead overwrote the existing petsc directory.

I believe this is a bug in hierarchical_mns (I have not checked other MNS).

I have modified our own MNS here. https://github.com/ComputeCanada/easybuild-framework/commit/b4b03bc225ca2b5d64d1c7bb9144d0935c41ece9

I also have a branch to fix it into hierarchical_mns and I am ready to open a PR if you consider this a bug, but I know you might not since it changes the behaviour. Let me know if you want me to open a PR for this change: https://github.com/ComputeCanada/easybuild-framework/commit/1ea92d8b3171cf6d88ea81b933d23e13f7f8c951

boegel commented 7 years ago

modaltsoftname is intended to only affect the module name, but I understand that the side effect of silently overwriting an existing installation isn't exactly desirable...

So, I think we have a couple of options:

Right now, EasyBuild solely relies on the presence of modules to determine whether or not an installation is already present, and it happily trashes and recreates an install directory that it happens to find (although, I think it creates a backup rather than actually fully trashing it, does it not?).

So, we need a separate --force-cleanup-existing-installdir or something like that (along with an appropriate check)?

mboisson commented 7 years ago

A third option might be to have an "installaltsoftname" which changes the name of the installation folder.

mboisson commented 7 years ago

Note that the current behaviour is actually to use the "det_module_short_name" to figure out the installdir path. So, one could argue that "det_module_short_name" should actually give the alternative name, and the behaviour of the install dir just happens to follows from that.

boegel commented 7 years ago

Also supporting installaltsoftname is certainly doable, but we still need the check on the install dir.

The name of the install directory is determined via det_install_subdir, which indeed relies on det_full_module_name, but that method is aware of modaltsoftname...

Am I missing something? Also because you mention det_module_short_name rather than ...full...?

mboisson commented 7 years ago

det_full_module_name is not aware of modaltsoftname, it just calls det_short_module_name to get the last part, and this one is not aware of modaltsoftname.

At least, they are not in hierarchical_mns.py

mboisson commented 7 years ago

None of the MNS - except our custom one - are aware of modaltsoftname directly:

[mboisson@build-node easybuild-framework]$ grep -r modaltsoftname ./easybuild/tools/module_naming_scheme/
Fichier binaire ./easybuild/tools/module_naming_scheme/SoftCCHierarchicalMNS.pyo correspondant
./easybuild/tools/module_naming_scheme/SoftCCHierarchicalMNS.py:        return os.path.join((ec['modaltsoftname'] or ec['name']).lower(), self.det_full_version(ec))
boegel commented 7 years ago

The module naming scheme being used is not called directly, but via the ActiveMNS mechanism, see https://github.com/hpcugent/easybuild-framework/blob/master/easybuild/framework/easyconfig/easyconfig.py#L1636, which calls _det_module_name_with, which is aware of modaltsoftname.

So, that makes me wonder why you're hitting this at all, since the intention indeed seems to be that the installdir follows the module name (instead when --fixed-installdir-naming-scheme is used, see https://github.com/hpcugent/easybuild-framework/blob/master/easybuild/framework/easyconfig/easyconfig.py#L1648)

mboisson commented 7 years ago

Mmmm

Looking at my installation logs, I do see that at some point it creates a directory and replace the software name with "petsc-64bits":

3043 == 2017-02-23 20:58:27,916 module_generator.py:662 INFO Not including statement to define environment variable $LD_LIBRARY_PATH, as specified
3044 == 2017-02-23 20:58:27,917 filetools.py:988 INFO Creating directory /home/mboisson/easybuild/software/2017/avx2/MPI/intel2016.4/openmpi2.0/petsc-64bits/3.7.5/easybuild (parents: True, set_gid:            False, sticky: False)
3045 == 2017-02-23 20:58:27,917 easyconfig.py:1616 INFO Replaced software name 'PETSc' with 'petsc-64bits' when determining module name
3046 == 2017-02-23 20:58:28,011 environment.py:97 INFO Environment variable LD_LIBRARY_PATH set to /cvmfs/soft.computecanada.ca/nix/lib (previous value: '/cvmfs/soft.computecanada.ca/nix/lib')

However, I do not see the same message when make_installdir is called:

2434 == 2017-02-23 20:58:22,921 easyblock.py:2292 INFO Starting install step
2435 == 2017-02-23 20:58:22,921 easyblock.py:2295 INFO Running method stage_install_step part of step install
2436 == 2017-02-23 20:58:22,921 easyblock.py:2295 INFO Running method make_installdir part of step install
2437 == 2017-02-23 20:58:22,921 easyblock.py:818 INFO Found old directory /home/mboisson/easybuild/software/2017/avx2/MPI/intel2016.4/openmpi2.0/petsc-64bits/3.7.5

here, it finds the petsc-64bits directory because this is a log obtained with my patch.

mboisson commented 7 years ago

Some more logs after reverting my local patch:

== 2017-02-23 21:32:04,059 easyconfig.py:1616 INFO Replaced software name 'PETSc' with 'petsc-64bits' when determining module name
== 2017-02-23 21:32:04,059 easyconfig.py:616 INFO filtered out dependency {'external_module_metadata': {}, 'full_mod_name': None, 'toolchain': {'version': '2016.4', 'name': 'iomkl'}, 'name': 'CMake', 'dummy': False, 'short_mod_name': None, 'external_module': False, 'versionsuffix': '', 'version': '3.5.2', 'toolchain_inherited': True, 'hidden': False, 'build_only': True}
--
== 2017-02-23 21:32:04,208 tools.py:256 WARNING 'eb' not found in $PATH, failed to determine installation prefix
== 2017-02-23 21:32:04,209 filetools.py:988 INFO Creating directory /home/mboisson/easybuild2/sources/p/PETSc (parents: True, set_gid: False, sticky: False)
== 2017-02-23 21:32:08,032 filetools.py:357 INFO Downloaded file petsc-3.7.5.tar.gz from url http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.7.5.tar.gz to /home/mboisson/easybuild2/sources/p/PETSc/petsc-3.7.5.tar.gz
--
== 2017-02-23 21:32:08,082 easyblock.py:1534 INFO Checking dirs that need to be created: ['/home/mboisson/easybuild2/software/2017/avx2/MPI/intel2016.4/openmpi2.0/petsc/3.7.5', '/home/mboisson/easybuild2/modules/2017/avx2/MPI/intel2016.4/openmpi2.0/petsc']
== 2017-02-23 21:32:08,083 filetools.py:988 INFO Creating directory /home/mboisson/easybuild2/software/2017/avx2/MPI/intel2016.4/openmpi2.0/petsc/3.7.5 (parents: True, set_gid: False, sticky: False)
== 2017-02-23 21:32:08,083 filetools.py:988 INFO Creating directory /home/mboisson/easybuild2/modules/2017/avx2/MPI/intel2016.4/openmpi2.0/petsc (parents: True, set_gid: False, sticky: False)
== 2017-02-23 21:32:08,083 build_log.py:217 INFO creating build dir, resetting environment...
--
== 2017-02-23 21:32:08,192 easyblock.py:2295 INFO Running method make_builddir part of step ready
== 2017-02-23 21:32:08,193 filetools.py:988 INFO Creating directory /dev/shm/mboisson/PETSc/3.7.5/iomkl-2016.4 (parents: True, set_gid: False, sticky: False)
== 2017-02-23 21:32:08,193 easyblock.py:2295 INFO Running method env_reset_changes part of step ready
--
== 2017-02-23 21:32:09,182 easyblock.py:2295 INFO Running method prepare_step part of step prepare
== 2017-02-23 21:32:09,247 filetools.py:988 INFO Creating directory /home/mboisson/easybuild2/modules/2017/Core (parents: True, set_gid: False, sticky: False)
== 2017-02-23 21:32:09,310 environment.py:97 INFO Environment variable LD_LIBRARY_PATH set to /cvmfs/soft.computecanada.ca/nix/lib (previous value: '/cvmfs/soft.computecanada.ca/nix/lib')
--
== 2017-02-23 21:32:09,647 easyblock.py:825 INFO Removed old directory /home/mboisson/easybuild2/software/2017/avx2/MPI/intel2016.4/openmpi2.0/petsc/3.7.5
== 2017-02-23 21:32:09,647 filetools.py:988 INFO Creating directory /home/mboisson/easybuild2/software/2017/avx2/MPI/intel2016.4/openmpi2.0/petsc/3.7.5 (parents: True, set_gid: False, sticky: False)

I'm using

name = 'PETSc'
version = '3.7.5'
modaltsoftname = 'petsc-64bits'

homepage = 'http://www.mcs.anl.gov/petsc'
description = """PETSc, pronounced PET-see (the S is silent), is a suite of data structures and routines for the
 scalable (parallel) solution of scientific applications modeled by partial differential equations."""

toolchain = {'name': 'iomkl', 'version': '2016.4'}
toolchainopts = {'usempi': True, 'pic': True}

source_urls = ['http://ftp.mcs.anl.gov/pub/petsc/release-snapshots']
sources = [SOURCELOWER_TAR_GZ]

shared_libs = 1
pic = 1

downloadinstall = True

dependencies = [('HDF5','1.8.18','', ('iompi',toolchain['version']))]

configopts = ""
# compiles PETSc shared
configopts += "--with-mkl_pardiso=1 --with-mkl_pardiso-dir=$MKLROOT "
configopts += "--with-hdf5=1 --with-hdf5-dir=$EBROOTHDF5 "
configopts += "--with-64-bit-indices=1 "
# external packages that are downloaded
#external_packages = ['mumps', 'ptscotch', 'superlu', 'superlu_dist', 'parmetis', 'metis', 'ml', 'suitesparse', 'hypre', 'prometheus']
external_packages = ['ptscotch', 'superlu_dist', 'parmetis', 'metis', 'suitesparse', 'prometheus']
# compiles the external dependencies non-shared
external_packages_shared = "no"
for p in external_packages:
        configopts += "--download-%s=yes --download-%s-shared=%s " % (p,p,external_packages_shared)

builddependencies = [('CMake', '3.5.2')]

moduleclass = 'numlib'

modluafooter = """
family("petsc")
"""

(the downloadinstall thing requires the other PR I opened yesterday, but I doubt it affects anything).

geimer commented 7 years ago

@boegel I'm not using --fixed-installdir-naming-scheme and see the same behavior: modaltsoftname only affects the module name, but the install directory still uses the "original" name. I believe this is the originally intended behavior as modaltsoftname is defined as a modulefile easyconfig parameter. If it would affect both the modulefile and the install path, altsoftname would IMHO be the better name...