Skip to content

Commit

Permalink
Add skylab-1.0.0-public template to avoid license issues, complete do…
Browse files Browse the repository at this point in the history
…cumentation on chaining spack environments (#233)

* Add instructions for building [email protected] with [email protected] on Discover
* Add configs/templates/skylab-1.0.0-public/spack.yaml
* Complete documentation for spack-stack-1.0.0 release
* [skip ci] Update version numbers of solo, r2d2, ewok
* [skip-ci] Update .gitmodules and submodule pointer for spack
  • Loading branch information
climbfuji authored Jun 29, 2022
1 parent b929046 commit c097d16
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#url = https://github.com/spack/spack
#branch = develop
url = https://github.com/NOAA-EMC/spack
branch = release/jcsda_emc_release_v1
branch = spack-stack-1.0.0
[submodule "doc/CMakeModules"]
path = doc/CMakeModules
url = https://github.com/noaa-emc/cmakemodules
Expand Down
84 changes: 84 additions & 0 deletions configs/templates/skylab-1.0.0-public/spack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
spack:
concretizer:
unify: when_possible

view: false

#packages:
# fiat:
# version: [1.0.0]
# ectrans:
# version: [1.0.0]

include: []

specs:

# Virtual environment packages
- [email protected]
- [email protected] ~fftw
- [email protected]
- [email protected]
- [email protected]
- [email protected]
#- [email protected]
#- [email protected]
- [email protected]

# Individual packages
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- ecflow@5
- [email protected]
- [email protected] ~trans ~fftw
# DH* fake version number
#- [email protected]
- [email protected]
- [email protected]
# DH* fake version number
- [email protected]
- [email protected]
# DH* fake version number
#- [email protected]
- [email protected]
- [email protected]
# DH* fake version number
- fms@release-jcsda
- [email protected]
- [email protected]
#- [email protected]
#- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
# DH* fake version number
- [email protected]
# DH* fake version number
#- shumlib@macos_clang_linux_intel_port
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
5 changes: 2 additions & 3 deletions configs/templates/skylab-1.0.0/spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spack:
- [email protected]
- [email protected]
# DH* fake version number
- ewok@1.0.0
- [email protected].1
- [email protected]
# DH* fake version number
- [email protected]
Expand Down Expand Up @@ -73,10 +73,9 @@ spack:
- [email protected]
- [email protected]
# DH* fake version number
- r2d2@1.0.0
- [email protected].1
# DH* fake version number
- shumlib@macos_clang_linux_intel_port
# DH* fake version number
- [email protected]
- [email protected]
- [email protected]
Expand Down
2 changes: 1 addition & 1 deletion doc/source/Environments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Environments can be constructed in two ways in spack-stack:

- Configure the environment as shown in :numref:`Sections %s <Quickstart>` and :numref:`%s <Platforms>`.

- Add spack packages (also referred to as ``specs``) to the environment using ``spack add``. These packages can be virtual environments described in :numref:`Section %s <EnvironmentsVirtualEnvironments>` below, or individual packages, e.g. ``esmf`` or ``atlas``. Examples:
- Add spack packages (also referred to as ``specs``) to the environment using ``spack add``. These packages can be virtual environments described in :numref:`Section %s <EnvironmentsVirtualPackages>` below, or individual packages, e.g. ``esmf`` or ``atlas``. Examples:

.. code-block:: console
Expand Down
89 changes: 71 additions & 18 deletions doc/source/MaintainersSection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ On Gaea, ``qt`` needs to be installed as a one-off before spack can be used.

qt (qt@5)
The default ``qt@5`` in ``/usr`` is incomplete and thus insufficient for building ``ecflow``. After loading/unloading the modules as shown below, refer to
:numref:`Section %s <Prerequisites_Qt5>` to install ``[email protected].3`` in ``/lustre/f2/pdata/esrl/gsd/spack-stack/qt-5.15.3``.
:numref:`Section %s <Prerequisites_Qt5>` to install ``[email protected].2`` in ``/lustre/f2/pdata/esrl/gsd/spack-stack/qt-5.15.2``.

.. code-block:: console
Expand All @@ -127,7 +127,7 @@ miniconda

qt (qt@5)
The default ``qt@5`` in ``/usr`` is incomplete and thus insufficient for building ``ecflow``. After loading/unloading the modules as shown below, refer to
:numref:`Section %s <Prerequisites_Qt5>` to install ``[email protected].3`` in ``/scratch1/NCEPDEV/jcsda/jedipara/spack-stack/qt-5.15.3``.
:numref:`Section %s <Prerequisites_Qt5>` to install ``[email protected].2`` in ``/scratch1/NCEPDEV/jcsda/jedipara/spack-stack/qt-5.15.2``.

.. code-block:: console
Expand All @@ -153,17 +153,6 @@ TACC Stampede2

Several packages need to be installed as a one-off before spack can be used.

Intel oneAPI compilers
The latest version of the Intel compiler on Stampede2 is 19.1.1, and the default modulefile created by the system administrators ties it to `gcc-9.1.0`. The way the module file has been written is incompatible with spack. We therefore recommend installing the latest Intel oneAPI compiler suite (Intel oneAPI Base and HPC Toolkits). The following instructions install Intel oneAPI 2022.2 in ``/work2/06146/tg854455/stampede2/spack-stack``.

.. code-block:: console
wget https://registrationcenter-download.intel.com/akdlm/irc_nas/18679/l_HPCKit_p_2022.2.0.191.sh
wget https://registrationcenter-download.intel.com/akdlm/irc_nas/18673/l_BaseKit_p_2022.2.0.262.sh
# Customize the installations to install in /work2/06146/tg854455/stampede2/spack-stack/intel-oneapi-2022.2
sh l_BaseKit_p_2022.2.0.262.sh
sh l_HPCKit_p_2022.2.0.191.sh
miniconda
Follow the instructions in :numref:`Section %s <Prerequisites_Miniconda>` to create a basic ``miniconda`` installation and associated modulefile for working with spack. Don't forget to log off and back on to forget about the conda environment.

Expand All @@ -180,7 +169,7 @@ git-lfs
rpm2cpio git-lfs-1.2.1-1.el7.x86_64.rpm | cpio -idmv
mv usr/* ../
Create modulefile ``/work2/06146/tg854455/stampede2/spack-stack/modulefiles/git-lfs/1.2.1`` from template ``doc/modulefile_templates/git-lfs`` and update ``GITLFS_PATH`` in this file.
Create modulefile ``/work2/06146/tg854455/stampede2/spack-stack/modulefiles/git-lfs/1.2.1`` from template ``doc/modulefile_templates/git-lfs`` and update ``GITLFS_PATH`` in this file.

.. _MaintainersSection_S4:

Expand All @@ -193,7 +182,7 @@ miniconda

qt (qt@5)
The default ``qt@5`` in ``/usr`` is incomplete and thus insufficient for building ``ecflow``. After loading/unloading the modules as shown below, refer to
:numref:`Section %s <Prerequisites_Qt5>` to install ``[email protected].3`` in ``/data/prod/jedi/spack-stack/qt-5.15.3``.
:numref:`Section %s <Prerequisites_Qt5>` to install ``[email protected].2`` in ``/data/prod/jedi/spack-stack/qt-5.15.2``.

.. code-block:: console
Expand All @@ -217,9 +206,60 @@ Using spack to test/add packages

The simplest case of adding new packages that are available in spack-stack is described in :numref:`Section %s <QuickstartExtendingEnvironments>`. As mentioned there, it is advised to take a backup of the spack environment (and install directories if outside the spack environment directory tree). It is also possible to chain spack installations, which means creating a test environment that uses installed packages and modulefiles from another (e.g. authoritative) spack environment and build the packages to be tested in isolation.

**WORK IN PROGRESS**
Chaining spack-stack installations
----------------------------------

Chaining spack-stack installations is a powerful way to test adding new packages without affecting the existing packages. The idea is to define one or more upstream spack installations that the environment can use as dependencies. One possible way to do this is:

1. Mirror the environment config of the upstream repository, i.e. copy the entire directory without the ``install`` and ``.spack_env`` directories and without `spack.lock`. For example:

.. code-block:: console
rsync -av --exclude='install' --exclude='.spack-env' --exclude='spack.lock' \
envs/jedi-ufs/ \
envs/jedi-ufs-chain-test/
More details and a few words of caution can be found in the `Spack documentation <https://spack.readthedocs.io/en/latest/chain.html?highlight=chaining%20spack%20installations>`_
2. Edit `envs/jedi-ufs-chain-test/spack.yaml`` and add an upstream configuration entry directly under the ``spack:`` config so that the contents looks like:

.. code-block:: console
spack:
upstreams:
spack-instance-1:
install_tree: /path/to/spack-stack-1.0.0/envs/jedi-ufs/install
concretizer:
unify: when_possible
...
3. Activate the environment

4. Install the new packages, for example:

.. code-block:: console
spack install -v --reuse [email protected]+debug
5. Create modulefiles

.. code-block:: console
spack module [lmod|tcl] refresh
6. When using ``tcl`` module files, run the ``spack stack setup-meta-modules`` script. This is not needed when using ``lmod`` modulefiles, because the meta modules in ``/path/to/spack-stack-1.0.0/envs/jedi-ufs-chain-test/install/modulefiles/Core`` will be ignored entirely.

To use the chained spack environment, first load the usual modules from the upstream spack environment. Then add the full path to the newly created modules manually, ignoring the meta modules (``.../Core``), for example:

.. code-block:: console
module use /path/to/spack-stack-1.0.0/envs/jedi-ufs-chain-test/install/modulefiles/openmpi/4.1.3/apple-clang/13.1.6
7. Load the newly created modules. When using `tcl` module files, make sure that conflicting modules are unloaded (`lmod` takes care of this).

.. note::
After activating the chained environment, ``spack find`` doesn't show the packages installed in upstream, unfortunately.

.. note::
More details and a few words of caution can be found in the `Spack documentation <https://spack.readthedocs.io/en/latest/chain.html?highlight=chaining%20spack%20installations>`_. Those words of caution need to be taken seriously, especially those referring to not deleting modulefiles and dependencies in the upstream spack environment (if having permissions to do so)!

----------------------------------------
Testing/adding packages outside of spack
Expand All @@ -233,6 +273,7 @@ Sometimes, users may want to build new versions of packages frequently without u
Users can build multiple packages outside of spack and install them in a separate install tree, for example ``MY_INSTALL_TREE``. In order to find these packages, users must extend their environment as required for the system/the packages to be installed:

.. code-block:: console
export PATH="$MY_INSTALL_TREE/bin:$PATH"
export CPATH="$MY_INSTALL_TREE/include:$PATH"
export LD_LIBRARY_PATH="$MY_INSTALL_TREE/lib64:$MY_INSTALL_TREE/lib:$LD_LIBRARY_PATH"
Expand All @@ -241,5 +282,17 @@ Users can build multiple packages outside of spack and install them in a separat
# Python packages, use correct lib/lib64 and correct python version
export PYTHONPATH="$MY_INSTALL_TREE/lib/pythonX.Y/site-packages:$PYTHONPATH"
Python packages can be added using ``python setup.py install --prefix=...`` or ``python3 -m pip install --no-deps --prefix=...``. The ``--no-deps`` options is very important, because ``pip`` may otherwise attempt to install dependencies that already exist in spack-stack. These dependencies are not only duplicates, they may also be different versions and/or compiled with different compilers/libraries (because they are wheels).
Python packages can be added in various ways:

1. Using ``python setup.py install --prefix=$MY_INSTALL_TREE ...`` or ``python3 -m pip install --no-deps --prefix=$MY_INSTALL_TREE ...``. The ``--no-deps`` options is very important, because ``pip`` may otherwise attempt to install dependencies that already exist in spack-stack. These dependencies are not only duplicates, they may also be different versions and/or compiled with different compilers/libraries (because they are wheels). This approach requires adding the appropriate subdirectories of ``$MY_INSTALL_TREE`` to the different search paths, as shown above.

2. Using Python virtual environments. Two important flags need to be passed to the command that creates the environment ``--system-site-packages`` and ``--without-pip``. After activating the environment, packages can be installed using `python3 -m pip` without having to specify ``--no-deps`` or ``--prefix``, and without having to manually modify ``PATH``, ``PYTHONPATH``, etc.

.. code-block:: console
python3 -m venv --system-site-packages --without-pip $MY_INSTALL_TREE
source $MY_INSTALL_TREE/bin/activate
python3 -m pip install ...
.. note::
Users are equally strongly advised to not use ``conda`` or ``miniconda`` in combination with Python modules provided by spack-stack, as well as not installing packages other than ``poetry`` in the basic ``miniconda`` installation for spack-stack (if using such a setup).
2 changes: 1 addition & 1 deletion doc/source/Overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spack-stack is a collaborative effort between the NOAA Environmental Modeling Ce

`Spack <https://github.com/spack/spack>`_ is a community-supported, multi-platform, Python-based package manager originally developed by the Lawrence Livermore National Laboratory (LLNL; https://computing.llnl.gov/projects/spack-hpc-package-manager). It is provided as a submodule so that a stable version can be referenced. See the `Spack Documentation <https://spack.readthedocs.io/en/latest>`_ for more information.

spack-stack is mainly a collection of Spack configuration files, but provides a Spack extension to simplify the installation process (see :numref:`Section %s <SpackStackExtension` for details):
spack-stack is mainly a collection of Spack configuration files, but provides a Spack extension to simplify the installation process (see :numref:`Section %s <SpackStackExtension>` for details):

- ``spack stack create`` is provided to copy common, site-specific, and application-specific configuration files into a coherent Spack environment and to create container recipes

Expand Down
Loading

0 comments on commit c097d16

Please sign in to comment.