module_list
module_list
module_list
A command-line utility to display information about currently loaded environment modules.
This script interacts with the system’s module management system (e.g., Lmod or Environment Modules) to retrieve and display information about loaded modules. It supports two primary modes of operation:
List All Loaded Modules: When executed without any arguments, the script lists all currently loaded modules, presenting each module’s name and version in a structured JSON format.
Check Specific Module: When provided with a single module name as an argument, the script checks whether that module is currently loaded:
- If the module is loaded, its version is printed.
- If the module is not loaded, the script outputs “not_loaded”.
Usage
module_list Lists all currently loaded modules in JSON format.
module_list
module_list -h | –help Displays this help message.
Note
- The script relies on the ‘module’ command-line utility to fetch information about loaded modules. Ensure that this utility is available in your system’s PATH.
- The ‘module list’ command typically outputs to stderr; this script captures that output to parse module information.
- The script is designed to work in environments where modules are managed using systems like Lmod or Environment Modules, commonly found in HPC environments.
Example
$ module_list [ { “name”: “rclone”, “version”: “1.70.0-beta” }, { “name”: “ccbrpipeliner”, “version”: “7” }, { “name”: “snakemake”, “version”: “7.32.4” }, { “name”: “singularity”, “version”: “4.2.2” }]
$ module_list snakemake 7.32.4
$ module_list python not_loaded
Functions
Name | Description |
---|---|
module_list | Get the list of loaded modules or the version of a specific module. |
module_list
='') module_list.module_list(module
Get the list of loaded modules or the version of a specific module.
Parameters
Name | Type | Description | Default |
---|---|---|---|
module | str | The name of the module to check. If empty, all loaded modules are listed. | '' |
Returns: output (str): JSON string of loaded modules or the version of the specified module.