Skip to content

Commit

Permalink
Update versions for EasyBuild user install section
Browse files Browse the repository at this point in the history
  • Loading branch information
dajon committed Mar 6, 2024
1 parent 0dec77a commit 14ba922
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 50 deletions.
104 changes: 54 additions & 50 deletions software/userinstallsw/easybuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ already exists for the particular package you are interested in).
With EasyBuild you might encounter a few different scenarios:

1. An easyconfig already exists for my software and can be used as is.
2. An easyconfig exists, but not for the compiler toolchain that I need.
2. An easyconfig exists, but not for the software version or compiler toolchain that I need.
3. An easyconfig does not exist for my software (not covered here, please
refer to general EasyBuild tutorials).

Expand All @@ -35,9 +35,9 @@ load the software into your environment.
EasyBuild is very explicit in the build specifications for each part in a
software's chain of dependencies, and is very careful not to mix dependencies
that are built using different compiler versions or toolchains. This is the
reason for the long names, like ``rjags-4-6-intel-2017b-R-3.4.3``
which means that the program ``rjags`` version 4.6 has been built using the
``intel-2017b`` toolchain and aimed at ``R`` version 3.4.3. This in turn means
reason for the long names, like ``rjags-4-12-foss-2021b-R-4.1.2``
which means that the program ``rjags`` version 4.12 has been built using the
``foss-2021b`` toolchain and aimed at ``R`` version 4.1.2. This in turn means
that all other dependencies that ``rjags`` might have, or anything that want to
*use* ``rjags`` as a dependency, will have to be compatible with these versions.

Expand All @@ -56,9 +56,9 @@ latest version you can find:
$ module purge
$ module avail easybuild
----------------------- /cluster/modulefiles/all ------------------------
EasyBuild/4.3.1
EasyBuild/4.9.0

$ module load EasyBuild/4.3.1
$ module load EasyBuild/4.9.0

Say you want to install the already mentioned
[rjags](http://cran.r-project.org/web/packages/rjags) package. Then you first
Expand All @@ -67,13 +67,13 @@ done with the `--search-filename` or `-S` option. So to display all rags
version that can be installed use:

$ eb --search-filename rjags
== found valid index for /cluster/software/EasyBuild/4.6.2/easybuild/easyconfigs, so using it...
== found valid index for /cluster/software/EasyBuild/4.9.0/easybuild/easyconfigs, so using it...
* rjags-4-6-intel-2017a-R-3.4.0.eb
* rjags-4-6-intel-2017b-R-3.4.3.eb
* rjags-4-8-foss-2018b-R-3.5.1.eb
* rjags-4-9-foss-2019a-R-3.6.0.eb
* rjags-4-10-foss-2019b.eb
* rjags-4-10-foss-2020a-R-4.0.0.eb
* rjags-4-10-foss-2020a-R4.0.0.eb
* rjags-4-10-foss-2020b-R-4.0.3.eb
* rjags-4-10-foss-2020b-R-4.0.4.eb
* rjags-4-10-foss-2020b-R-4.0.5.eb
Expand All @@ -82,12 +82,14 @@ version that can be installed use:
* rjags-4-10-fosscuda-2020b-R-4.0.4.eb
* rjags-4-10-fosscuda-2020b-R-4.0.5.eb
* rjags-4-12-foss-2021b-R-4.1.2.eb
* rjags-4-13-foss-2022a-R-4.2.1.eb
* rjags-4-13-foss-2022b-R-4.2.2.eb

Note: 1 matching archived easyconfig(s) found, use --consider-archived-easyconfigs to see them


From this list we decide to go for ``rjags`` version mentioned above, i.e.
``rjags-4-6-intel-2017b-R-3.4.3.eb``.
``rjags-4-12-foss-2021b-R-4.1.2.eb``.

Now, we advice to do an install in three steps, first download the sources of
your software, then do a test run where you check what will be installed and
Expand All @@ -107,7 +109,7 @@ This will download a tarball into your local EB directory
what will be installed with the command you are planning to use. This you get
by the command:

$ eb rjags-4-6-intel-2017b-R-3.4.3.eb --dry-run
$ eb rjags-4-12-foss-2021b-R-4.1.2.eb --dry-run

This will check that all the necessary dependencies are available in the current
EB repository. If not, you will get an error message. It will also print the
Expand All @@ -116,7 +118,7 @@ dependency is already satisfied, and won't be re-installed.

**Step 3:** If the test build was successful, you can perform the build with:

$ eb rjags-4-6-intel-2017b-R-3.4.3.eb --robot --parallel=2
$ eb rjags-4-12-foss-2021b-R-4.1.2.eb --robot --parallel=2

where ``--robot`` means that EasyBuild should automatically resolve and install
all necessary dependencies, and ``--parallel`` will set the number of CPU
Expand All @@ -136,7 +138,7 @@ login node.
You can now confirm that the package has been installed under
``.local/easybuild/software``:

$ ls $HOME/.local/easybuild/software/rjags/4-6-intel-2017b-R-3.4.3/rjags/
$ ls $HOME/.local/easybuild/software/rjags/4-12-foss-2021b-R-4.1.2/rjags/
data DESCRIPTION help html INDEX libs Meta NAMESPACE R


Expand All @@ -147,7 +149,7 @@ folder under ``.local/easybuild/software``. At the same time, EasyBuild
created a new module file under ``.local/easybuild/modules``:

$ ls .local/easybuild/modules/all/rjags/
4-6-intel-2017b-R-3.4.3.lua
4-12-foss-2021b-R-4.1.2.lua

which can now be loaded and used alongside any other globally installed
software. In order to do so you need to tell the module system to look for
Expand All @@ -156,14 +158,14 @@ modules in this directory, which is done with the ``module use`` command:
$ module use $HOME/.local/easybuild/modules/all
$ module avail rjags
------------------------------------ .local/easybuild/modules/all -------------------------------------
rjags/4-6-intel-2017b-R-3.4.3
rjags/4-12-foss-2021b-R-4.1.2

Use "module spider" to find all possible modules.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".

You can now load and use the package just like any other module:

$ module load rjags/4-6-intel-2017b-R-3.4.3
$ module load rjags/4-12-foss-2021b-R-4.1.2

**For more information about the module system, please see:**
<https://lmod.readthedocs.io/en/latest>
Expand All @@ -176,9 +178,9 @@ following changes to the above procedure.

$ my_path=/cluster/projects/nnXXXXk/easybuild
$ mkdir -p $my_path
$ eb rjags-4-6-intel-2017b-R-3.4.3.eb --prefix=$my_path --fetch
$ eb rjags-4-6-intel-2017b-R-3.4.3.eb --prefix=$my_path --dry-run
$ eb rjags-4-6-intel-2017b-R-3.4.3.eb --prefix=$my_path
$ eb rjags-4-12-foss-2021b-R-4.1.2.eb --prefix=$my_path --fetch
$ eb rjags-4-12-foss-2021b-R-4.1.2.eb --prefix=$my_path --dry-run
$ eb rjags-4-12-foss-2021b-R-4.1.2.eb --prefix=$my_path

where XXXX is your project id number. Note the easybuild folder in the path,
this is a tip for housekeeping and not strictly required. This will give the
Expand All @@ -193,15 +195,17 @@ Now the ``rjags`` installation is available to everyone associated with the

## Writing your own easyconfigs

Let's say that for some reason you need to use ``rjags`` with the
``intel/2018b`` toolchain, instead of ``2017b`` which we already installed.
Let's say that for some reason you need to use ``rjags-4-12`` with the
``foss/2022a`` toolchain, instead of ``2021b`` which we already installed.
A quick look into the EB repo tells you that this particular version is not
available, which means that simply substituting the toolchain version will
*not* work:

$ eb rjags-4-6-intel-2018b-R-3.4.3.eb --fetch
== temporary log file in case of crash /tmp/eb-hZoghE/easybuild-2YC1pX.log
ERROR: Can't find path /cluster/home/$USER/rjags-4-6-intel-2018b-R-3.4.3.eb
$ eb rjags-4-12-foss-2022a-R-4.1.2.eb --fetch
== Temporary log file in case of crash /tmp/eb-bliwuikc/easybuild-2a9dc17d.log
== found valid index for /cluster/software/EasyBuild/4.9.0/easybuild/easyconfigs, so using it...
ERROR: One or more files not found: rjags-4-12-foss-2022a-R-4.1.2.eb (search paths:
/cluster/software/EasyBuild/4.9.0/easybuild/easyconfigs)

In this case what you need to do is to write your own easyconfig file and use
that for your easy build. Depending on the package this can be either really
Expand All @@ -215,80 +219,80 @@ already become available on the
so please check this out first. In that case you can simply download or copy
the easyconfig file from there, otherwise it's a good idea to start from an
easyconfig that is similar to the one you are trying to make. In our case we
will copy the ``rjags-4-6-intel-2017b-R-3.4.3.eb`` file and work from there.
will copy the ``rjags-4-12-foss-2021b-R-4.1.2.eb`` file and work from there.

**Step 1:** Copy similar easyconfig to somewhere in your ``$HOME``, here
``eb-sandbox``:

$ cd eb-sandbox
$ cp $EBROOTEASYBUILD/easybuild/easyconfigs/r/rjags/rjags-4-6-intel-2017b-R-3.4.3.eb .
$ eb --copy-ec rjags-4-12-foss-2021b-R-4.1.2.eb

**Step 2:** Inspect the easyconfig file and check for dependencies; in this
case there are two, ``R`` and ``JAGS``. Next you need to check if any of the
dependencies are available with the toolchain that you want. Here we see that
``R-3.5.1`` *is* available with ``intel-2018b``:
``R-4.2.1`` *is* available with ``foss-2022a``:

$ ls $EBROOTEASYBUILD/easybuild/easyconfigs/r/R/*intel-2018b*
/cluster/software/EasyBuild/4.3.1/easybuild/easyconfigs/r/R/R-3.5.1-intel-2018b.eb
$ ls $EBROOTEASYBUILD/easybuild/easyconfigs/r/R/*foss-2022a*
/cluster/software/EasyBuild/4.9.0/easybuild/easyconfigs/r/R/R-4.2.1-foss-2022a.eb

but ``JAGS`` is not:
Also a never version of ``JAGS``is available, but if we assume that we need to keep the version at 4.3.0 it is not available for the new toolchain

$ ls $EBROOTEASYBUILD/easybuild/easyconfigs/j/JAGS/*intel-2018b*
$ ls $EBROOTEASYBUILD/easybuild/easyconfigs/j/JAGS/JAGS-4.3.0-foss-2022a*
No such file or directory

However, we do have a version with ``intel/2017b`` (which of course is the one
However, we do have a version with ``foss/2021b`` (which of course is the one
used by our original ``rjags``), so we'll copy that one as well and adapt it to
our target toolchain:

$ cp $EBROOTEASYBUILD/easybuild/easyconfigs/j/JAGS/JAGS-4.3.0-intel-2017b.eb .
$ eb --copy-ec JAGS-4.3.0-foss-2021b.eb

You can see that this procedure gets exponentially more complicated when you
have to recursively update all dependencies of your original package, but
thankfully in our case it stops here.

```{note}
The versions do not necessarily have to match *literally*, they just need to
not be *conflicting*. For instance, ``intel/2018b`` includes the compiler
``GCCcore/7.3.0``, so any easyconfig with the ``GCCcore-7.3.0`` suffix would
also be compatible.
The toolchains do not necessarily have to match *literally*, they just need to
not be *conflicting*. For instance, ``foss/2022a`` includes the compiler
``GCCcore/11.3.0``, so any easyconfig with the ``GCCcore-11.3.0`` suffix would
also be compatible. For more information about common toolchains: <https://docs.easybuild.io/common-toolchains/>
```

**Step 3:** Starting with your deepest dependency, edit your new easyconfigs
and change the version specifications. In ``JAGS`` it's just a matter of
changing the toolchain to:

toolchain = {'name': 'intel', 'version': '2018b'}
toolchain = {'name': 'foss', 'version': '2022a'}

and at the same time remove the checksum line. For ``rjags`` you do exactly the
If the software version is changed you also need to update the checksum line.
For ``rjags`` you do exactly the
same, but you should also update the versions of the dependencies. The ``JAGS``
entry does not have to be changed, because we're still using version 4.3.0, but
``R`` has to be changed to version 3.5.1, which was the one we found in **Step
2** to be available for our toolchain. Note that the version suffix ``-X11...``
is no longer applicable for this version of ``R``, so it should be removed.
``R`` has to be changed to version 4.2.1, which was the one we found in **Step
2** to be available for our toolchain.

**Step 4:** Rename the easyconfig files to match the new versions:

$ mv JAGS-4.3.0-intel-2017b.eb JAGS-4.3.0-intel-2018b.eb
$ mv rjags-4-6-intel-2017b-R-3.4.3.eb rjags-4-6-intel-2018b-R-3.5.1.eb
$ mv JAGS-4.3.0-foss-2021b.eb JAGS-4.3.0-foss-2022a.eb
$ mv rjags-4-12-foss-2021b-R-4.1.2.eb rjags-4-12-foss-2022a-R-4.2.1.eb

Our new easyconfigs should now look like this:

**JAGS-4.3.0-intel-2018b.eb:**
**JAGS-4.3.0-foss-2022a.eb:**
```{eval-rst}
.. literalinclude:: files/JAGS-4.3.0-intel-2018b.eb
.. literalinclude:: files/JAGS-4.3.0-foss-2022a.eb
:language: bash
```

**rjags-4-6-intel-2018b-R-3.5.1.eb:**
**rjags-4-6-foss-2022a-R-3.5.1.eb:**
```{eval-rst}
.. literalinclude:: files/rjags-4-6-intel-2018b-R-3.5.1.eb
.. literalinclude:: files/rjags-4-12-foss-2022a-R-4.2.1.eb
:language: bash
```

**Step 5:** Build your new module while adding the current directory to
``--robot`` so that your new `.eb` files are picked up:

$ eb rjags-4-6-intel-2018b-R-3.5.1.eb --robot=. --parallel=2
$ eb rjags-4-12-foss-2022a-R-4.2.1.eb --robot=. --parallel=2

Again, please don't use too many ``--parallel`` threads on login!

Expand All @@ -297,9 +301,9 @@ Again, please don't use too many ``--parallel`` threads on login!
$ module use $HOME/.local/easybuild/modules/all
$ module avail rjags
--------------------------- $HOME/.local/easybuild/modules/all ---------------------------
rjags/4-6-intel-2017b-R-3.4.3 rjags/4-6-intel-2018b-R-3.5.1
rjags/4-12-foss-2021b-R-4.1.2 rjags/4-12-foss-2022a-R-4.2.1

$ module load rjags/4-6-intel-2018b-R-3.5.1
$ module load rjags/4-12-foss-2022a-R-4.2.1

**For more information on how to write easyconfigs:**
<https://easybuild.readthedocs.io/en/latest/Writing_easyconfig_files.html>
36 changes: 36 additions & 0 deletions software/userinstallsw/files/JAGS-4.3.0-foss-2022a.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file is an EasyBuild reciPY as per https://github.com/easybuilders/easybuild
# Author: Pablo Escobar Lopez
# Swiss Institute of Bioinformatics
# Biozentrum - University of Basel

easyblock = 'ConfigureMake'

name = 'JAGS'
version = '4.3.0'

homepage = 'http://mcmc-jags.sourceforge.net/'
description = """JAGS is Just Another Gibbs Sampler. It is a program for analysis
of Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation """

toolchain = {'name': 'foss', 'version': '2022a'}

source_urls = [
('https://sourceforge.net/projects/mcmc-%(namelower)s/files/%(name)s/%(version_major)s.x/Source/', 'download')
]
sources = [SOURCE_TAR_GZ]
checksums = ['8ac5dd57982bfd7d5f0ee384499d62f3e0bb35b5f1660feb368545f1186371fc']

configopts = ' --with-blas="$LIBBLAS" --with-lapack="$LIBLAPACK"'


sanity_check_paths = {
'files': ['bin/%(namelower)s', 'libexec/%(namelower)s-terminal', 'lib/libjags.%s' % SHLIB_EXT],
'dirs': [],
}

modextrapaths = {
'JAGS_INCLUDE': 'include/%(name)s',
'JAGS_LIB': 'lib',
}

moduleclass = 'math'
29 changes: 29 additions & 0 deletions software/userinstallsw/files/rjags-4-12-foss-2022a-R-4.2.1.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
easyblock = 'RPackage'

name = 'rjags'
version = '4-12'
versionsuffix = '-R-%(rver)s'

homepage = 'https://cran.r-project.org/web/packages/rjags'
description = """The rjags package is an interface to the JAGS library."""

toolchain = {'name': 'foss', 'version': '2022a'}

source_urls = [
'https://cran.r-project.org/src/contrib/',
'https://cran.r-project.org/src/contrib/Archive/rjags/',
]
sources = ['%(name)s_%(version)s.tar.gz']
checksums = ['b91f34c3f9ebf78fa44bd661346fbb6f28a01693a7203ac133c98392dd273e10']

dependencies = [
('R', '4.2.1'),
('JAGS', '4.3.0'),
]

sanity_check_paths = {
'files': [],
'dirs': ['rjags'],
}

moduleclass = 'math'

0 comments on commit 14ba922

Please sign in to comment.