Skip to content

ashki23/module-projection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Spack module projection

Spack creates modulefiles in both Lua or Tcl formats. But the generated modulefiles includes hash numbers and located in in the Spack path. We can modify Spack to generate modulefules with no hash but it can cause many problems when there are modules with the same name. Also, Spack creates modulefile for all the depecndencies that many of them not using directly by users. This software orgenizes the namespace of the modulefiles and creates a symbolic link from them to a more familiar path (i.e., /opt/modulefiles/) and let users to exclude modulefiles by using wildcards.


Spack and Lmod installation

## Install Spack at /opt directory
cd /opt
git clone https://github.com/spack/spack.git
cd spack
git fetch origin releases/latest:latest
git checkout latest
source share/spack/setup-env.sh
spack install lmod

Modulefiles config

Create the following module config file (modules.yaml) at /opt/spack/etc/spack/:

modules:
  enable:
    - lmod
    - tcl
  lmod:
    hierarchy:
      - mpi
    core_compilers:
      - gcc@9.3.0
    blacklist:
      - '^lua'
      - autoconf-archive
      - autoconf
      - automake
      - bzip2
      - cairo
      - harfbuzz
      - openssh
      - openssl
    whitelist:
      - gcc
      - openmpi
    all:
      environment:
        set:
          '{name}_ROOT': '{prefix}'
      filter:
        environment_blacklist:
          - 'MODULEPATH'
    hash_length: 4
    projections:
      '^mpi ^cuda': '{name}/{version}-{^mpi.name}-cuda-{^cuda.version}'
      ^mpi: '{name}/{version}-{^mpi.name}'
      all: '{name}/{version}'

To refresh modulefiles run:

spack module lmod refresh --delete-tree -y

This will create modulefiles under /opt/spack/share/spack/lmod/linux-*-x86_64/Core/. Here we keep hashes in the namesapce to prevent possible confilcts. Note that Lmod does not create modulefile for libraries listed under the blacklist which helps to exclude some modulefiles. Later we use setup-modules.sh to censor libraries by using wildcards.

Project modulefiles

Use source setup-modules.sh to project files. By default setup-modules.sh uses /opt/modulefiles/ for destination of modulefiles (modulepath). Modify dest variable if you want a different modulepath. setup-modules.sh does three tasks:

  1. Censors libraries and dependencies by wildcards, eg. ^lib.* ^util-.* .*font.*
  2. Drops hashes
  3. Creates links from actual modulefiles to /opt/modulefiles/

Bashrc

To activat lmod and update the modulepath, add the following to .bashrc file (need to modify lmod path based on your environment):

export MODULEPATH='/opt/modulefiles/'
source /opt/spack/opt/spack/linux-ubuntu20.04*/gcc-9.3.0/lmod-8*/lmod/lmod/init/bash
alias spack-setup-env='git -C /opt/spack checkout latest && git -C /opt/spack fetch origin releases/latest && source /opt/spack/share/spack/setup-env.sh && module unuse /opt/spack/share/spack/modules/*'

Workflow

We are using Spack to install software:

  • Activate Spack env and update the branch: spack-setup-env
  • Check specs: spack spec -I <software>
  • Install: spack install <software>

Now use the following to project modulefiles:

source setup-modules.sh

About

Application for projecting Lmod modulefiles in Spack.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages