Skip to content

Commit

Permalink
Merge pull request EESSI#316 from trz42/sync_allow_lmod_hook_injections
Browse files Browse the repository at this point in the history
Allow defining lmod hooks in host injections
  • Loading branch information
poksumdo authored Apr 11, 2024
2 parents ef3543d + cb38e23 commit 544d211
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 3 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/tests_scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -108,3 +110,21 @@ jobs:
./eessi_container.sh --mode run --verbose --repository nessi.no-2023.06-software /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
70 changes: 67 additions & 3 deletions create_lmodsitepackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,67 @@
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)
-- <some_action_on_load>
-- 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)
-- <some_action_on_load>
-- 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()
Expand Down Expand Up @@ -95,12 +156,12 @@
if (moduleName == "OpenMPI") and (cpuTarget == "aarch64/neoverse_v1") then
local msg = "Adding '^smcuda' to $OMPI_MCA_btl to work around bug in OpenMPI"
LmodMessage(msg .. " (see https://gitlab.com/eessi/support/-/issues/41)")
local ompiMcaBtl = os.getenv("OMPI_MCA_btl")
if ompiMcaBtl == nil then
local ompiMcaBtl = os.getenv("OMPI_MCA_btl")
if ompiMcaBtl == nil then
setenv("OMPI_MCA_btl", "^smcuda")
else
setenv("OMPI_MCA_btl", ompiMcaBtl .. ",^smcuda")
end
end
end
end
Expand All @@ -113,6 +174,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):
Expand Down

0 comments on commit 544d211

Please sign in to comment.