From 3ccecf97e9008ddf98640d3a0ab970607c5b5779 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Wed, 3 Apr 2024 12:58:22 +0200 Subject: [PATCH 1/4] Add possibility to ignore certain hooks on local modules. E.g. we don't want to be prevented from loading local CUDA modules because of the EESSI hook. See https://github.com/EESSI/software-layer/issues/523 --- create_lmodsitepackage.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/create_lmodsitepackage.py b/create_lmodsitepackage.py index 29b2d39bd7..ffbe7a1531 100755 --- a/create_lmodsitepackage.py +++ b/create_lmodsitepackage.py @@ -19,6 +19,18 @@ return content end +local function from_eessi_prefix(t) + local eessi_prefix = os.getenv("EESSI_PREFIX") + -- If EESSI_PREFIX wasn't defined, we cannot check if this module was from the EESSI environment + -- In that case, we assume it isn't, otherwise EESSI_PREFIX would (probably) have been set + if eessi_prefix == nil then + return False + else + -- Check if the full modulepath starts with the eessi_prefix + return t.fn:find( "^" .. eessi_prefix) ~= nil + end +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. @@ -152,10 +164,13 @@ -- Combine both functions into a single one, as we can only register one function as load hook in lmod -- Also: make it non-local, so it can be imported and extended by other lmodrc files if needed function eessi_load_hook(t) - eessi_cuda_enabled_load_hook(t) + -- Only apply CUDA hooks if the loaded module is in the EESSI prefix + -- This avoids getting an Lmod Error when trying to load a CUDA module from a local software stack + if from_eessi_prefix(t) then + eessi_cuda_enabled_load_hook(t) + end end - 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 From bb20ab2078b25041011f242673a848b199aedb74 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Wed, 3 Apr 2024 16:36:39 +0200 Subject: [PATCH 2/4] Also use hooks for site extensions in host_injections AND for user extensions in /home/casparl/eessi/... --- create_lmodsitepackage.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/create_lmodsitepackage.py b/create_lmodsitepackage.py index ffbe7a1531..f7d4d06bb9 100755 --- a/create_lmodsitepackage.py +++ b/create_lmodsitepackage.py @@ -20,14 +20,24 @@ end local function from_eessi_prefix(t) + -- eessi_prefix is the prefix with official EESSI modules + -- e.g. /cvmfs/software.eessi.io/versions/2023.06 local eessi_prefix = os.getenv("EESSI_PREFIX") + -- eessi_prefix_host_injections is the prefix with site-extensions (i.e. additional modules) + -- to the official EESSI modules, e.g. /cvmfs/software.eessi.io/host_injections/2023.06 + local eessi_prefix_host_injections = string.gsub(eessi_prefix, 'versions', 'host_injections') + -- eessi_prefix_user_home is the prefix with user-extensions (i.e. additional modules) + -- to the offocial EESSI modules, e.g. $HOME/eessi/versions/2023.06 + local eessi_prefix_user_home = string.gsub(eessi_prefix, os.getenv("EESSI_CVMFS_REPO"), pathJoin(os.getenv("HOME"), "eessi")) -- If EESSI_PREFIX wasn't defined, we cannot check if this module was from the EESSI environment -- In that case, we assume it isn't, otherwise EESSI_PREFIX would (probably) have been set if eessi_prefix == nil then return False else - -- Check if the full modulepath starts with the eessi_prefix - return t.fn:find( "^" .. eessi_prefix) ~= nil + -- Check if the full modulepath starts with the eessi_prefix_* + return string.find(t.fn, "^" .. eessi_prefix) ~= nil or + string.find(t.fn, "^" .. eessi_prefix_host_injections) ~= nil or + string.find(t.fn, "^" .. eessi_prefix_user_home) ~= nil end end From 838920bd332819b1e50706873ee53f2469cf3794 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Wed, 3 Apr 2024 16:38:24 +0200 Subject: [PATCH 3/4] Leave breadcrumb to notify that paths may need to be changed in the future --- create_lmodsitepackage.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/create_lmodsitepackage.py b/create_lmodsitepackage.py index f7d4d06bb9..ce94a7e311 100755 --- a/create_lmodsitepackage.py +++ b/create_lmodsitepackage.py @@ -23,6 +23,10 @@ -- eessi_prefix is the prefix with official EESSI modules -- e.g. /cvmfs/software.eessi.io/versions/2023.06 local eessi_prefix = os.getenv("EESSI_PREFIX") + + -- NOTE: exact paths for site and user extensions aren't final, so may need to be updated later. + -- See https://github.com/EESSI/software-layer/pull/371 + -- eessi_prefix_host_injections is the prefix with site-extensions (i.e. additional modules) -- to the official EESSI modules, e.g. /cvmfs/software.eessi.io/host_injections/2023.06 local eessi_prefix_host_injections = string.gsub(eessi_prefix, 'versions', 'host_injections') From d0229ccb3adb03eac5cdddde76858b00d20832bf Mon Sep 17 00:00:00 2001 From: ocaisa Date: Mon, 29 Apr 2024 14:40:50 +0200 Subject: [PATCH 4/4] Update create_lmodsitepackage.py --- create_lmodsitepackage.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/create_lmodsitepackage.py b/create_lmodsitepackage.py index ce94a7e311..862902d80e 100755 --- a/create_lmodsitepackage.py +++ b/create_lmodsitepackage.py @@ -24,24 +24,20 @@ -- e.g. /cvmfs/software.eessi.io/versions/2023.06 local eessi_prefix = os.getenv("EESSI_PREFIX") - -- NOTE: exact paths for site and user extensions aren't final, so may need to be updated later. - -- See https://github.com/EESSI/software-layer/pull/371 - - -- eessi_prefix_host_injections is the prefix with site-extensions (i.e. additional modules) - -- to the official EESSI modules, e.g. /cvmfs/software.eessi.io/host_injections/2023.06 - local eessi_prefix_host_injections = string.gsub(eessi_prefix, 'versions', 'host_injections') - -- eessi_prefix_user_home is the prefix with user-extensions (i.e. additional modules) - -- to the offocial EESSI modules, e.g. $HOME/eessi/versions/2023.06 - local eessi_prefix_user_home = string.gsub(eessi_prefix, os.getenv("EESSI_CVMFS_REPO"), pathJoin(os.getenv("HOME"), "eessi")) -- If EESSI_PREFIX wasn't defined, we cannot check if this module was from the EESSI environment -- In that case, we assume it isn't, otherwise EESSI_PREFIX would (probably) have been set if eessi_prefix == nil then return False else - -- Check if the full modulepath starts with the eessi_prefix_* - return string.find(t.fn, "^" .. eessi_prefix) ~= nil or - string.find(t.fn, "^" .. eessi_prefix_host_injections) ~= nil or - string.find(t.fn, "^" .. eessi_prefix_user_home) ~= nil + -- NOTE: exact paths for site so may need to be updated later. + -- See https://github.com/EESSI/software-layer/pull/371 + + -- eessi_prefix_host_injections is the prefix with site-extensions (i.e. additional modules) + -- to the official EESSI modules, e.g. /cvmfs/software.eessi.io/host_injections/2023.06 + local eessi_prefix_host_injections = string.gsub(eessi_prefix, 'versions', 'host_injections') + + -- Check if the full modulepath starts with the eessi_prefix_* + return string.find(t.fn, "^" .. eessi_prefix) ~= nil or string.find(t.fn, "^" .. eessi_prefix_host_injections) ~= nil end end