Collections

Collections allow users to save a particular set of module loads and swaps, effectively creating a custom environment setup. This can include specific versions of compilers, libraries, and applications. Users can then reload this environment setup easily, ensuring consistency across sessions or projects. For more information, check the user collection tutorial.

Save Modules into a Collection

Once users have the desired modules load in their environments, then they can save the current state of loaded modules as a named collection using the following command:

module save <collection_name>

This stores the current list of loaded modules under the specified name. If the user didn’t specify the collection name, the list will be stored under default.

If you created a default collection, this means that the modules of it will be loaded anytime you login to your account.

For example, if you need to configure your environment with a list of modules, and instead of loading Modules one-by-one, can create a collection that lists all desired Modules.

First, you need to load all desired modules in your environment:

module load spack/2022a  gcc/12.1.0-2022a-gcc_8.5.0-ivitefn perl/5.34.1-2022a-gcc_12.1.0-ioconer openmpi/4.1.3-2022a-gcc_12.1.0-slurm-pmix_v4-crduqhh

Then, store the current list of loaded modules under the specified collection name:

$ module save mycollection
Saved current collection of modules to: "mycollection"

Restore a Collection

When users load the environment configuration saved under a collection name, they can restore the collection and get it loaded to their environment. This configuration includes specific versions of software packages, libraries, and tools that were active at the time the collection was saved.

To restore a collection, use the following syntax:

module restore <collection_name>

For example, to restore the collection created above (mycollection), run:

module restore mycollection

You check the loaded model models in your environment, and you should find the modules loaded before saving the collection.

$ module list

Currently Loaded Modules:
  1) os/rhel_8                            (S)   6) numactl/2.0.14-2022a-gcc_12.1.0-la7tqfj         11) rdma-core/39.1-2022a-gcc_12.1.0-7vbs2pj
  2) spack/2022a                                7) openjdk/1.8.0_265-b01-2022a-gcc_12.1.0-leujkhw  12) ucx/1.12.1-2022a-gcc_12.1.0-bqfrajc
  3) gcc/12.1.0-2022a-gcc_8.5.0-ivitefn         8) openssh/9.0p1-2022a-gcc_12.1.0-ty4peys          13) zlib/1.2.12-2022a-gcc_12.1.0-7h2btk3
  4) perl/5.34.1-2022a-gcc_12.1.0-ioconer       9) maven/3.8.4-2022a-gcc_12.1.0-jwd4jwt            14) openmpi/4.1.3-2022a-gcc_12.1.0-slurm-pmix_v4-crduqhh
  5) hwloc/2.7.1-2022a-gcc_12.1.0-uomsar5      10) libnl/3.3.0-2022a-gcc_12.1.0-nlkk7ay

  Where:
   S:  Module is Sticky, requires --force to unload or purge
You can show the describtion of a collection to get an idea what modules included in the collection using module restore <collection_name>.

Disable a Collection

You can disable a collection at any time if the collection is no use. To disable a collection, use the following syntax:

module disable <collection_name>
If no collection name is given then the default is disabled.

For example, to disable mycollection, run:

$ module disable mycollection
Disabling mycollection collection by renaming with a "~"

Disabling a collection doesn’t mean that the collection is removed. It only renames the collection by adding ~ in the end of the collection name. For example, after disabling mycollection, it’s renamed to mycollection~. To restore the collection, you need to do the following:

cd ~/.config/lmod;  mv mycollection~ mycollection