Skip to content

Commit

Permalink
Adding MName:isVisible()
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Oct 13, 2024
1 parent a1d73ae commit 1b17cfb
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.new
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,5 @@ Lmod 8.7+
* Do not reset BASH_ENV if already set for profile.in
* Issue #690: Support for the functions hide{} and forbid{}
(8.7.51) * Fix bug in load test.
(8.7.52) * Add MName:isVisible() so that load hooks can figure out if a loaded module is is visible or not.

4 changes: 4 additions & 0 deletions docs/source/025_new.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
New Features in Lmod
====================

**Accessing isVisible status from load hook**
(Lmod 8.7.52+) The mname object is passed to the load hook. Sites
can access the isVisible status by t.mname:isVisible()

**hide** {} and **forbid** {}
(Lmod 8.8+) The *hide* {} function provides a more powerful way to
hide modules. The *forbid* {} function provides a way to mark
Expand Down
3 changes: 3 additions & 0 deletions docs/source/300_tracking_module_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Use SitePackage.lua to send a message to syslog.::
-- the arg t is a table:
-- t.modFullName: the module full name: (i.e: gcc/4.7.2)
-- t.fn: The file name: (i.e /apps/modulefiles/Core/gcc/4.7.2.lua)
-- t.mname: The Module Name object.

local isVisible = t.mname:isVisible()


-- use syshost from configuration if set
Expand Down
2 changes: 1 addition & 1 deletion rt/hook_avail/hook_avail.tdesc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testdescript = {
owner = "rtm",
product = "modules",
description = [[
Test always_load, always_unload
Test hook_avail"
]],
keywords = {testName },

Expand Down
11 changes: 11 additions & 0 deletions rt/modulerc/SitePackage.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
local hook = require("Hook")
local function load_hook(t)
-- the arg t is a table:
-- t.modFullName: the module full name: (i.e: gcc/4.7.2)
-- t.fn: The file name: (i.e /apps/modulefiles/Core/gcc/4.7.2.lua)
-- t.mname: The Module Name object.

local isVisible = t.mname:isVisible()
io.stderr:write("module: ",t.modFullName," isVisible statue: ",tostring(isVisible),"\n")
end
hook.register("load", load_hook)
46 changes: 35 additions & 11 deletions rt/modulerc/err.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
step 1
lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version
===========================
Modules based on Lua: Version 8.7.49 2024-08-30 13:55 -06:00
Modules based on Lua: Version 8.7.51 2024-10-09 15:58 -05:00
by Robert McLay [email protected]
===========================
step 2
Expand Down Expand Up @@ -910,11 +910,12 @@ step 74
lua ProjectDIR/src/lmod.in.lua shell --regression_testing -A avail
===========================
ProjectDIR/rt/modulerc/mfD/Core
C/1.0 G/1.0 (H) cluster/c
C/2.0 G/2.0 (D) cluster/.defaultCluster (H,F,D)
C/3.0 (F,D) H/1.0 (s) hard/1.0
D/3.0 (NF) cluster/a hard/3.0 (D)
F/1.0 (NF) cluster/b
C/1.0 G/2.0 (D) hard/1.0
C/2.0 H/1.0 (s) hard/3.0 (D)
C/3.0 (F,D) cluster/a soft/1.0 (s,D)
D/3.0 (NF) cluster/b soft/2.0 (H)
F/1.0 (NF) cluster/c
G/1.0 (H) cluster/.defaultCluster (H,F,D)
Where:
D: Default Module
F: Forbidden Module
Expand Down Expand Up @@ -952,6 +953,9 @@ cluster/.defaultCluster <H> <F>
hard/
hard/1.0
hard/3.0
soft/
soft/1.0 <H>
soft/2.0 <H>
===========================
step 76
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load C
Expand Down Expand Up @@ -1059,6 +1063,7 @@ The following is a list of the modules and extensions currently available:
H: H/1.0
cluster: cluster/a, cluster/b, cluster/c, cluster/.defaultCluster
hard: hard/1.0, hard/3.0
soft: soft/1.0, soft/2.0
To learn more about a package execute:
$ module spider Foo
where "Foo" is the name of a module.
Expand Down Expand Up @@ -1111,16 +1116,20 @@ cluster/.defaultCluster <H> <F>
hard/
hard/1.0
hard/3.0
soft/
soft/1.0 <H>
soft/2.0 <H>
===========================
step 87
lua ProjectDIR/src/lmod.in.lua shell --regression_testing -A avail
===========================
ProjectDIR/rt/modulerc/mfD/Core
C/1.0 G/1.0 (H) cluster/c
C/2.0 G/2.0 (D) cluster/.defaultCluster (H,F,D)
C/3.0 (F,D) H/1.0 (s,L) hard/1.0
D/3.0 (NF,L) cluster/a hard/3.0 (D)
F/1.0 (NF) cluster/b
C/1.0 G/2.0 (D) hard/1.0
C/2.0 H/1.0 (s,L) hard/3.0 (D)
C/3.0 (F,D) cluster/a soft/1.0 (s,D)
D/3.0 (NF,L) cluster/b soft/2.0 (H)
F/1.0 (NF) cluster/c
G/1.0 (H) cluster/.defaultCluster (H,F,D)
Where:
D: Default Module
F: Forbidden Module
Expand All @@ -1133,3 +1142,18 @@ If the avail list is too long consider trying:
"module overview" or "ml ov" to display the number of modules for each name.
Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".
===========================
step 88
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load soft/1.0
===========================
module: soft/1.0 isVisible statue: false
===========================
step 89
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load G/1.0
===========================
module: G/1.0 isVisible statue: false
===========================
step 90
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load C/1.0
===========================
module: C/1.0 isVisible statue: true
2 changes: 1 addition & 1 deletion rt/modulerc/mfD/Core/B/.modulerc.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hide{name="B/1.0", kind="hidden"}
hide{name="B/1.0"}
2 changes: 2 additions & 0 deletions rt/modulerc/mfD/Core/soft/.modulerc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hide{name="soft/1.0",kind="soft"}
hide{name="soft/2.0",kind="hidden"}
Empty file.
Empty file.
10 changes: 9 additions & 1 deletion rt/modulerc/modulerc.tdesc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,15 @@ EOF
mkdir -p $HOME/.cache/lmod
buildSpiderT $MODULEPATH > $HOME/.cache/lmod/spiderT.lua
runLmod -A avail #87
export LMOD_PACKAGE_PATH=$(testDir)
runLmod load soft/1.0 #88
runLmod load G/1.0 #89
runLmod load C/1.0 #90
HOME=$ORIG_HOME
cat _stdout.[0-9][0-9][0-9] > _stdout.orig
joinBase64Results -bash _stdout.orig _stdout.new
Expand Down
89 changes: 89 additions & 0 deletions rt/modulerc/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,16 @@ mrcMpathT = {
kind = "hard",
name = "hardAll",
},
["soft/1.0"] = {
action = "hide",
kind = "soft",
name = "soft/1.0",
},
["soft/2.0"] = {
action = "hide",
kind = "hidden",
name = "soft/2.0",
},
},
},
}
Expand Down Expand Up @@ -2633,6 +2643,49 @@ spiderT = {
},
},
},
soft = {
defaultA = {
{
barefn = ".modulerc.lua",
defaultIdx = 2,
fn = "ProjectDIR/rt/modulerc/mfD/Core/soft/.modulerc.lua",
fullName = "soft/.modulerc",
luaExt = 10,
mpath = "ProjectDIR/rt/modulerc/mfD/Core",
value = false,
},
},
defaultT = {
barefn = ".modulerc.lua",
defaultIdx = 2,
fn = "ProjectDIR/rt/modulerc/mfD/Core/soft/.modulerc.lua",
fullName = "soft/.modulerc",
luaExt = 10,
mpath = "ProjectDIR/rt/modulerc/mfD/Core",
value = false,
},
dirT = {},
fileT = {
["soft/1.0"] = {
Version = "1.0",
canonical = "1.0",
fn = "ProjectDIR/rt/modulerc/mfD/Core/soft/1.0.lua",
luaExt = 4,
mpath = "ProjectDIR/rt/modulerc/mfD/Core",
pV = "000000001.*zfinal",
wV = "000000001.*zfinal",
},
["soft/2.0"] = {
Version = "2.0",
canonical = "2.0",
fn = "ProjectDIR/rt/modulerc/mfD/Core/soft/2.0.lua",
luaExt = 4,
mpath = "ProjectDIR/rt/modulerc/mfD/Core",
pV = "000000002.*zfinal",
wV = "000000002.*zfinal",
},
},
},
},
version = 5,
}
Expand Down Expand Up @@ -2677,3 +2730,39 @@ MODULEPATH=ProjectDIR/rt/modulerc/mfD/Core;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={D={fn="ProjectDIR/rt/modulerc/mfD/Core/D/3.0.lua",forbiddenT={after="YYYY-MM-DD",forbiddenState="nearly",},fullName="D/3.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="D",wV="000000003.*zfinal",},H={fn="ProjectDIR/rt/modulerc/mfD/Core/H/1.0.lua",fullName="H/1.0",loadOrder=2,moduleKindT={kind="soft",},propT={},stackDepth=0,status="active",userName="H/1.0",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/modulerc/mfD/Core",},systemBaseMPATH="ProjectDIR/rt/modulerc/mfD/Core",}';
export _ModuleTable_;
===========================
step 88
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load soft/1.0
===========================
LOADEDMODULES=D/3.0:H/1.0:soft/1.0;
export LOADEDMODULES;
MODULEPATH=ProjectDIR/rt/modulerc/mfD/Core;
export MODULEPATH;
_LMFILES_=ProjectDIR/rt/modulerc/mfD/Core/D/3.0.lua:ProjectDIR/rt/modulerc/mfD/Core/H/1.0.lua:ProjectDIR/rt/modulerc/mfD/Core/soft/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={D={fn="ProjectDIR/rt/modulerc/mfD/Core/D/3.0.lua",forbiddenT={after="YYYY-MM-DD",forbiddenState="nearly",},fullName="D/3.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="D",wV="000000003.*zfinal",},H={fn="ProjectDIR/rt/modulerc/mfD/Core/H/1.0.lua",fullName="H/1.0",loadOrder=2,moduleKindT={kind="soft",},propT={},stackDepth=0,status="active",userName="H/1.0",wV="000000001.*zfinal",},soft={fn="ProjectDIR/rt/modulerc/mfD/Core/soft/1.0.lua",fullName="soft/1.0",loadOrder=3,moduleKindT={kind="soft",},propT={},stackDepth=0,status="active",userName="soft/1.0",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/modulerc/mfD/Core",},systemBaseMPATH="ProjectDIR/rt/modulerc/mfD/Core",}';
export _ModuleTable_;
===========================
step 89
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load G/1.0
===========================
LOADEDMODULES=D/3.0:H/1.0:soft/1.0:G/1.0;
export LOADEDMODULES;
MODULEPATH=ProjectDIR/rt/modulerc/mfD/Core;
export MODULEPATH;
_LMFILES_=ProjectDIR/rt/modulerc/mfD/Core/D/3.0.lua:ProjectDIR/rt/modulerc/mfD/Core/H/1.0.lua:ProjectDIR/rt/modulerc/mfD/Core/soft/1.0.lua:ProjectDIR/rt/modulerc/mfD/Core/G/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={D={fn="ProjectDIR/rt/modulerc/mfD/Core/D/3.0.lua",forbiddenT={after="YYYY-MM-DD",forbiddenState="nearly",},fullName="D/3.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="D",wV="000000003.*zfinal",},G={fn="ProjectDIR/rt/modulerc/mfD/Core/G/1.0.lua",fullName="G/1.0",loadOrder=4,moduleKindT={kind="hidden",},propT={},stackDepth=0,status="active",userName="G/1.0",wV="000000001.*zfinal",},H={fn="ProjectDIR/rt/modulerc/mfD/Core/H/1.0.lua",fullName="H/1.0",loadOrder=2,moduleKindT={kind="soft",},propT={},stackDepth=0,status="active",userName="H/1.0",wV="000000001.*zfinal",},soft={fn="ProjectDIR/rt/modulerc/mfD/Core/soft/1.0.lua",fullName="soft/1.0",loadOrder=3,moduleKindT={kind="soft",},propT={},stackDepth=0,status="active",userName="soft/1.0",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/modulerc/mfD/Core",},systemBaseMPATH="ProjectDIR/rt/modulerc/mfD/Core",}';
export _ModuleTable_;
===========================
step 90
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load C/1.0
===========================
LOADEDMODULES=D/3.0:H/1.0:soft/1.0:G/1.0:C/1.0;
export LOADEDMODULES;
MODULEPATH=ProjectDIR/rt/modulerc/mfD/Core;
export MODULEPATH;
_LMFILES_=ProjectDIR/rt/modulerc/mfD/Core/D/3.0.lua:ProjectDIR/rt/modulerc/mfD/Core/H/1.0.lua:ProjectDIR/rt/modulerc/mfD/Core/soft/1.0.lua:ProjectDIR/rt/modulerc/mfD/Core/G/1.0.lua:ProjectDIR/rt/modulerc/mfD/Core/C/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={C={fn="ProjectDIR/rt/modulerc/mfD/Core/C/1.0.lua",fullName="C/1.0",loadOrder=5,propT={},stackDepth=0,status="active",userName="C/1.0",wV="000000001.*zfinal",},D={fn="ProjectDIR/rt/modulerc/mfD/Core/D/3.0.lua",forbiddenT={after="YYYY-MM-DD",forbiddenState="nearly",},fullName="D/3.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="D",wV="000000003.*zfinal",},G={fn="ProjectDIR/rt/modulerc/mfD/Core/G/1.0.lua",fullName="G/1.0",loadOrder=4,moduleKindT={kind="hidden",},propT={},stackDepth=0,status="active",userName="G/1.0",wV="000000001.*zfinal",},H={fn="ProjectDIR/rt/modulerc/mfD/Core/H/1.0.lua",fullName="H/1.0",loadOrder=2,moduleKindT={kind="soft",},propT={},stackDepth=0,status="active",userName="H/1.0",wV="000000001.*zfinal",},soft={fn="ProjectDIR/rt/modulerc/mfD/Core/soft/1.0.lua",fullName="soft/1.0",loadOrder=3,moduleKindT={kind="soft",},propT={},stackDepth=0,status="active",userName="soft/1.0",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/modulerc/mfD/Core",},systemBaseMPATH="ProjectDIR/rt/modulerc/mfD/Core",}';
export _ModuleTable_;
7 changes: 7 additions & 0 deletions src/MName.lua
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,13 @@ function M.moduleKindT(self)
return t
end

function M.isVisible(self)
if (not self.__moduleKindT) then
return true
end
local moduleKindT = self.__moduleKindT
return moduleKindT.kind == "normal"
end

function M.userName(self)
return self.__userName
Expand Down

0 comments on commit 1b17cfb

Please sign in to comment.