diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index b1d2426774..4944d9beaa 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -5,6 +5,7 @@ on: paths: - build_container.sh - create_directory_tarballs.sh + - create_lmodsitepackage.py - EESSI-install-software.sh - install_software_layer.sh - load_easybuild_module.sh @@ -16,6 +17,7 @@ on: paths: - build_container.sh - create_directory_tarballs.sh + - create_lmodsitepackage.py - EESSI-install-software.sh - install_software_layer.sh - load_easybuild_module.sh @@ -96,3 +98,24 @@ jobs: ./eessi_container.sh --mode run --verbose /software-layer/create_directory_tarballs.sh 2023.06 # check if tarballs have been produced ls -l *.tar.gz + + - name: test create_lmodsitepackage.py script + run: | + # bind current directory into container as /software-layer + export SINGULARITY_BIND="${PWD}:/software-layer" + + # Creates .lmod/SitePackage.lua in current dir, which then gets bind-mounted into /software-layer + python3 create_lmodsitepackage.py . + # run some commands to make sure that generated Lmod SitePackage file works + test_script="${PWD}/test_lmod_sitepackage.sh" + echo '#!/bin/bash' > ${test_script} + echo 'export LMOD_PACKAGE_PATH="/software-layer/.lmod"' > ${test_script} + echo 'ml --config' >> ${test_script} + + chmod u+x ${test_script} + + out="${PWD}/test_create_lmodsitepackage.out" + ./eessi_container.sh --mode run --verbose /software-layer/run_in_compat_layer_env.sh /software-layer/test_lmod_sitepackage.sh 2>&1 | tee ${out} + for pattern in "^Site Pkg location.*/software-layer/.lmod/SitePackage.lua" "LMOD_SITEPACKAGE_LOCATION.*/software-layer/.lmod/SitePackage.lua"; do + grep "${pattern}" ${out} || (echo "Pattern '${pattern}' not found in output!" && exit 1) + done diff --git a/create_lmodsitepackage.py b/create_lmodsitepackage.py index 5a7a915494..29b2d39bd7 100755 --- a/create_lmodsitepackage.py +++ b/create_lmodsitepackage.py @@ -19,6 +19,71 @@ return content end +local function load_site_specific_hooks() + -- This function will be run after the EESSI hooks are registered + -- It will load a local SitePackage.lua that is architecture independent (if it exists) from e.g. + -- /cvmfs/software.eessi.io/host_injections/2023.06/.lmod/SitePackage.lua + -- That can define a new hook + -- + -- function site_specific_load_hook(t) + -- + -- end + -- + -- And the either append to the existing hook: + -- + -- local function final_load_hook(t) + -- eessi_load_hook(t) + -- site_specific_load_hook(t) + -- end + -- + -- Over overwrite the EESSI hook entirely: + -- + -- hook.register("load", final_load_hook) + -- + -- Note that the appending procedure can be simplified once we have an lmod >= 8.7.36 + -- See https://github.com/TACC/Lmod/pull/696#issuecomment-1998765722 + -- + -- Subsequently, this function will look for an architecture-specific SitePackage.lua, e.g. from + -- /cvmfs/software.eessi.io/host_injections/2023.06/software/linux/x86_64/amd/zen2/.lmod/SitePackage.lua + -- This can then register an additional hook, e.g. + -- + -- function arch_specific_load_hook(t) + -- + -- end + -- + -- local function final_load_hook(t) + -- eessi_load_hook(t) + -- site_specific_load_hook(t) + -- arch_specific_load_hook(t) + -- end + -- + -- hook.register("load", final_load_hook) + -- + -- Again, the host site could also decide to overwrite by simply doing + -- + -- hook.register("load", arch_specific_load_hook) + + -- get path to to architecture independent SitePackage.lua + local prefixHostInjections = string.gsub(os.getenv('EESSI_PREFIX') or "", 'versions', 'host_injections') + local hostSitePackage = prefixHostInjections .. "/.lmod/SitePackage.lua" + + -- If the file exists, run it + if isFile(hostSitePackage) then + dofile(hostSitePackage) + end + + -- build the full architecture specific path in host_injections + local archHostInjections = string.gsub(os.getenv('EESSI_SOFTWARE_PATH') or "", 'versions', 'host_injections') + local archSitePackage = archHostInjections .. "/.lmod/SitePackage.lua" + + -- If the file exists, run it + if isFile(archSitePackage) then + dofile(archSitePackage) + end + +end + + local function eessi_cuda_enabled_load_hook(t) local frameStk = require("FrameStk"):singleton() local mt = frameStk:mt() @@ -92,6 +157,9 @@ hook.register("load", eessi_load_hook) + +-- Note that this needs to happen at the end, so that any EESSI specific hooks can be overwritten by the site +load_site_specific_hooks() """ def error(msg):