available_software.py is a script that generates an overview of all software modules that are available on an HPC system.
It also generates a detailed overview per software that includes specific software versions.
To do this, it generates 3 things:
json_data.json: This JSON file is used to populate the global overview table.json_data_detail.json: This JSON file is used to automatically generate all the detailed markdown pages.- A lot of MarkDown files: These are the detailed overview pages per software.
The generated files will be placed in the available_software directory, more specifically the data and detail subdirectories.
- Required Python packages are listed in
requirements.txtandrequirements_tests.txt - Lmod must be available, and
$LMOD_CMDmust specify the path to thelmodbinary.
If the required Python packages are not available in your Python setup, you can easily create a dedicated virtual environment as follows:
python -m venv module_overview_venv
source module_overview_venv/bin/activate
pip install -r requirements.txt
pip install -r requirements_tests.txt
# to exit the virtual environment, run 'deactivate'You can run the script with following command:
python available_software.pyYou can run the tests by running the test.sh script.
./test.shThe tests make use of a mocked $LMOD_CMD script, which you can find here.
If you want to write additional tests and use the script effectively, follow these guidelines:
-
Setting up mocked Lmod:
Before each test, ensure that you set the path to the script that mocks the
lmodbinary. This can be done within the setup_class function.path = os.path.dirname(os.path.realpath(__file__)) @classmethod def setup_class(cls): os.environ["LMOD_CMD"] = cls.path + "/data/lmod_mock.sh"
An example of a possible setup_class function is given below.
import os
@classmethod
def setup_class(cls):
os.environ["TESTS_PATH"] = cls.path
os.environ["LMOD_CMD"] = cls.path + "/data/lmod_mock.sh"
os.environ["SHELL"] = cls.path + "/data/bash_mock.sh"
os.environ["MOCK_FILE_SWAP"] = cls.path + "/data/data_swap_TARGET.txt"
os.environ["MOCK_FILE_AVAIL_TARGET"] = cls.path + "/data/data_avail_target_simple.txt"
os.environ["MOCK_FILE_AVAIL_TARGET_AMD_INTEL"] = cls.path + "/data/data_avail_target_amd_intel.txt"This does multiple things:
- Set the path of the tests folder in
$TESTS_PATH - Set the path to the
lmod_mock.shscript in the environment variable$LMOD_CMD - set the path to the
bash_mock.shscript in the environment variable$SHELL - Set the output file for the
module swapto theMOCK_FILE_SWAPvariable. For example,data/data_swap_generic.txtcould be a possible file. - Set the output file for the
module availto theMOCK_FILE_AVAIL_TARGETvariable. The actual output can be found in thedata/data_avail_target_simple.txtfile or/data/data_avail_target_amd_intel.txtfile.