diff --git a/README.new b/README.new index 13f928db5..6dfce9cc2 100644 --- a/README.new +++ b/README.new @@ -1,4 +1,5 @@ Lmod 8.1+ (8.1.1) * Issue #392: include family info in spiderT and all other products based on spiderT like dbT and the software page. - + (8.1.2) * Issue #382: Adding a spider_decoration hook so that sites can modify the output of spider + level 1 output. diff --git a/docs/source/170_hooks.rst b/docs/source/170_hooks.rst index ffed73ecc..fe3f52d57 100644 --- a/docs/source/170_hooks.rst +++ b/docs/source/170_hooks.rst @@ -129,6 +129,13 @@ Hook functions argument is a table containing: fullName, sn (short name), fn (file path) and isVisible (boolean) of the module. +**spider_decoration** (table): + This hook provide a way for a site to add decoration to spider level + 1 output. The table passed in contains the whatis category and the + property table. See *rt/uitSitePkg/mf/site_scripts/SitePackage.lua* + for a complete example. + + Example Hook: msgHook --------------------- diff --git a/rt/softwarePage/err.txt b/rt/softwarePage/err.txt index e0ee6b035..c6686d6db 100644 --- a/rt/softwarePage/err.txt +++ b/rt/softwarePage/err.txt @@ -2,16 +2,19 @@ step 1 lua ProjectDIR/src/lmod.in.lua bash --regression_testing --version =========================== -Modules based on Lua: Version 8.1 2019-05-07 15:35 -05:00 +Modules based on Lua: Version 8.1.1 2019-05-10 11:12 -05:00 by Robert McLay mclay@tacc.utexas.edu =========================== step 2 lua ProjectDIR/src/lmod.in.lua bash --regression_testing avail =========================== ProjectDIR/rt/softwarePage/mf - foo/1.0 foo/1.1 (D) foo/1.3 + foo/1.0 (g) foo/1.1 (m,D) foo/1.3 (T) Where: D: Default Module + T: Testing + g: built for GPU + m: built for host and native MIC Use "module spider" to find all possible modules. Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys". =========================== @@ -26,3 +29,17 @@ runSpiderCmd -o dbT ProjectDIR/rt/softwarePage/mf step 5 runSpiderCmd -o softwarePageLua ProjectDIR/rt/softwarePage/mf =========================== +=========================== +step 6 +lua ProjectDIR/src/lmod.in.lua bash --regression_testing spider foo +=========================== + foo: + Description: + This is a descript + Versions: + foo/1.0 + foo/1.1 + foo/1.3 + For detailed information about a specific "foo" module (including how to load the modules) use the module's full name. + For example: + $ module spider foo/1.3 diff --git a/rt/softwarePage/mf/foo/.2.0.lua b/rt/softwarePage/mf/foo/.2.0.lua index 41b2e8a80..daffac1f5 100644 --- a/rt/softwarePage/mf/foo/.2.0.lua +++ b/rt/softwarePage/mf/foo/.2.0.lua @@ -1,5 +1,5 @@ help([[foo v.2.0]]) whatis("Description: foo description") whatis("Version: 1.0") -whatis("Categories: foo") +whatis("Category: foo") family("bar") diff --git a/rt/softwarePage/mf/foo/1.0.lua b/rt/softwarePage/mf/foo/1.0.lua index 82512ac76..a63de045a 100644 --- a/rt/softwarePage/mf/foo/1.0.lua +++ b/rt/softwarePage/mf/foo/1.0.lua @@ -1,5 +1,6 @@ help([[foo v1.0]]) whatis("Description: foo description") whatis("Version: 1.0") -whatis("Categories: foo") +whatis("Category: foo") family("bar") +add_property("arch","gpu") diff --git a/rt/softwarePage/mf/foo/1.1.lua b/rt/softwarePage/mf/foo/1.1.lua index c156b547e..6ae0ac914 100644 --- a/rt/softwarePage/mf/foo/1.1.lua +++ b/rt/softwarePage/mf/foo/1.1.lua @@ -1,5 +1,6 @@ help([[foo v1.1]]) whatis("Description: foo description") whatis("Version: 1.1") -whatis("Categories: foo") +whatis("Category: foo") family("bar") +add_property("arch","mic") diff --git a/rt/softwarePage/mf/foo/1.3 b/rt/softwarePage/mf/foo/1.3 index 64a194da4..631bdbe65 100644 --- a/rt/softwarePage/mf/foo/1.3 +++ b/rt/softwarePage/mf/foo/1.3 @@ -4,7 +4,7 @@ module-whatis "Version: 1.3" module-whatis "Category: system" module-whatis "Description: This is a descript" family "bar" - +add-property "state" "testing" proc ModulesHelp { } { puts stderr "This is the help message for the foo 1.3 module" puts stderr "And even more help" diff --git a/rt/softwarePage/out.txt b/rt/softwarePage/out.txt index 81a9adf7a..45f3df6fb 100644 --- a/rt/softwarePage/out.txt +++ b/rt/softwarePage/out.txt @@ -88,6 +88,11 @@ spiderT = { ["luaExt"] = 4, ["mpath"] = "ProjectDIR/rt/softwarePage/mf", ["pV"] = "000000001.*zfinal", + propT = { + arch = { + ["gpu"] = 1, + }, + }, ["wV"] = "^00000001.*zfinal", whatis = { "Description: foo description", "Version: 1.0", "Categories: foo", @@ -103,6 +108,11 @@ spiderT = { ["luaExt"] = 4, ["mpath"] = "ProjectDIR/rt/softwarePage/mf", ["pV"] = "000000001.000000001.*zfinal", + propT = { + arch = { + ["mic"] = 1, + }, + }, ["wV"] = "000000001.000000001.*zfinal", whatis = { "Description: foo description", "Version: 1.1", "Categories: foo", @@ -122,6 +132,11 @@ And even more help ]], ["mpath"] = "ProjectDIR/rt/softwarePage/mf", ["pV"] = "000000001.000000003.*zfinal", + propT = { + state = { + ["testing"] = 1, + }, + }, ["wV"] = "000000001.000000003.*zfinal", whatis = { "Name: foo ", "Version: 1.3 ", "Category: system ", "Description: This is a descript ", @@ -184,6 +199,11 @@ dbT = { ["help"] = "foo v1.0", ["hidden"] = false, ["pV"] = "000000001.*zfinal", + propT = { + arch = { + ["gpu"] = 1, + }, + }, ["wV"] = "^00000001.*zfinal", whatis = { "Description: foo description", "Version: 1.0", "Categories: foo", @@ -197,6 +217,11 @@ dbT = { ["help"] = "foo v1.1", ["hidden"] = false, ["pV"] = "000000001.000000001.*zfinal", + propT = { + arch = { + ["mic"] = 1, + }, + }, ["wV"] = "000000001.000000001.*zfinal", whatis = { "Description: foo description", "Version: 1.1", "Categories: foo", @@ -214,6 +239,11 @@ And even more help ]], ["hidden"] = false, ["pV"] = "000000001.000000003.*zfinal", + propT = { + state = { + ["testing"] = 1, + }, + }, ["wV"] = "000000001.000000003.*zfinal", whatis = { "Name: foo ", "Version: 1.3 ", "Category: system ", "Description: This is a descript ", @@ -239,6 +269,11 @@ spA = { ["help"] = "foo v1.1", ["markedDefault"] = false, ["path"] = "ProjectDIR/rt/softwarePage/mf/foo/1.1.lua", + properties = { + arch = { + ["mic"] = 1, + }, + }, ["versionName"] = "1.1", ["wV"] = "000000001.000000001.*zfinal", }, @@ -253,6 +288,11 @@ And even more help ]], ["markedDefault"] = false, ["path"] = "ProjectDIR/rt/softwarePage/mf/foo/1.3", + properties = { + state = { + ["testing"] = 1, + }, + }, ["versionName"] = "1.3 ", ["wV"] = "000000001.000000003.*zfinal", }, @@ -264,9 +304,22 @@ And even more help ["help"] = "foo v1.0", ["markedDefault"] = true, ["path"] = "ProjectDIR/rt/softwarePage/mf/foo/1.0.lua", + properties = { + arch = { + ["gpu"] = 1, + }, + }, ["versionName"] = "1.0", ["wV"] = "^00000001.*zfinal", }, }, }, } +=========================== +step 6 +lua ProjectDIR/src/lmod.in.lua bash --regression_testing spider foo +=========================== +MODULEPATH=ProjectDIR/rt/softwarePage/mf; +export MODULEPATH; +_ModuleTable_='_ModuleTable_={["MTversion"]=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/softwarePage/mf",},["systemBaseMPATH"]="ProjectDIR/rt/softwarePage/mf",}'; +export _ModuleTable_; diff --git a/rt/uitSitePkg/err.txt b/rt/uitSitePkg/err.txt index e2c5c59c3..0ae6ad3c1 100644 --- a/rt/uitSitePkg/err.txt +++ b/rt/uitSitePkg/err.txt @@ -2,7 +2,7 @@ step 1 lua ProjectDIR/src/lmod.in.lua bash --regression_testing --version =========================== -Modules based on Lua: Version 7.7.14 2017-11-16 16:23 -07:00 +Modules based on Lua: Version 8.1.1 2019-05-10 11:12 -05:00 by Robert McLay mclay@tacc.utexas.edu =========================== step 2 @@ -39,3 +39,16 @@ where "Foo" is the name of a module. To find detailed information about a particular package you must specify the version if there is more than one version: $ module spider Foo/11.1 +=========================== +step 7 +lua ProjectDIR/src/lmod.in.lua bash --regression_testing spider python +=========================== + python: + Description: + Python with scientific packages + Versions: + python/2.7.3 (Application) + python/3.3.0 (Application) + For detailed information about a specific "python" module (including how to load the modules) use the module's full name. + For example: + $ module spider python/3.3.0 diff --git a/rt/uitSitePkg/mf/site-scripts/SitePackage.lua b/rt/uitSitePkg/mf/site-scripts/SitePackage.lua index e7f233721..411e54156 100644 --- a/rt/uitSitePkg/mf/site-scripts/SitePackage.lua +++ b/rt/uitSitePkg/mf/site-scripts/SitePackage.lua @@ -3,6 +3,8 @@ -- author: jonas.juselius@uit.no require("lmod_system_execute") +require("string_utils") + local Dbg = require("Dbg") local dbg = Dbg:dbg() local hook = require("Hook") @@ -173,6 +175,13 @@ function loadPkgDefaults() return pkg end +function spdrDecoration(v) + local cat = (v.Category or ""):trim() + return cat +end + +hook.register("spider_decoration", spdrDecoration) + sandbox_registration { getAppRoot = getAppRoot , loadPkgDefaults = loadPkgDefaults diff --git a/rt/uitSitePkg/out.txt b/rt/uitSitePkg/out.txt index 3e2f0a89d..49530c063 100644 --- a/rt/uitSitePkg/out.txt +++ b/rt/uitSitePkg/out.txt @@ -90,3 +90,11 @@ MODULEPATH=ProjectDIR/rt/uitSitePkg/mf/Compiler/gcc/4.7.2:ProjectDIR/rt/uitSiteP export MODULEPATH; _ModuleTable_='_ModuleTable_={["MTversion"]=3,depthT={},family={["compiler"]="gcc",},mT={gcc={["fn"]="ProjectDIR/rt/uitSitePkg/mf/Core/gcc/4.7.2.lua",["fullName"]="gcc/4.7.2",["loadOrder"]=1,propT={},["stackDepth"]=0,["status"]="active",["userName"]="gcc",},python={["fn"]="ProjectDIR/rt/uitSitePkg/mf/Core/python/2.7.3.lua",["fullName"]="python/2.7.3",["loadOrder"]=2,propT={},["stackDepth"]=0,["status"]="active",["userName"]="python",},},mpathA={"ProjectDIR/rt/uitSitePkg/mf/Compiler/gcc/4.7.2","ProjectDIR/rt/uitSitePkg/mf/Core",},["systemBaseMPATH"]="ProjectDIR/rt/uitSitePkg/mf/Core",}'; export _ModuleTable_; +=========================== +step 7 +lua ProjectDIR/src/lmod.in.lua bash --regression_testing spider python +=========================== +MODULEPATH=ProjectDIR/rt/uitSitePkg/mf/Compiler/gcc/4.7.2:ProjectDIR/rt/uitSitePkg/mf/Core; +export MODULEPATH; +_ModuleTable_='_ModuleTable_={["MTversion"]=3,depthT={},family={["compiler"]="gcc",},mT={gcc={["fn"]="ProjectDIR/rt/uitSitePkg/mf/Core/gcc/4.7.2.lua",["fullName"]="gcc/4.7.2",["loadOrder"]=1,propT={},["stackDepth"]=0,["status"]="active",["userName"]="gcc",},python={["fn"]="ProjectDIR/rt/uitSitePkg/mf/Core/python/2.7.3.lua",["fullName"]="python/2.7.3",["loadOrder"]=2,propT={},["stackDepth"]=0,["status"]="active",["userName"]="python",},},mpathA={"ProjectDIR/rt/uitSitePkg/mf/Compiler/gcc/4.7.2","ProjectDIR/rt/uitSitePkg/mf/Core",},["systemBaseMPATH"]="ProjectDIR/rt/uitSitePkg/mf/Core",}'; +export _ModuleTable_; diff --git a/rt/uitSitePkg/uitSitePkg.tdesc b/rt/uitSitePkg/uitSitePkg.tdesc index a94f1fb5e..f7c50a61e 100644 --- a/rt/uitSitePkg/uitSitePkg.tdesc +++ b/rt/uitSitePkg/uitSitePkg.tdesc @@ -31,6 +31,7 @@ testdescript = { runLmod save default # 4 runLmod restore # 5 runLmod spider # 6 + runLmod spider python # 7 HOME=$ORIG_HOME diff --git a/src/Hook.lua b/src/Hook.lua index bba7031b3..4e603cb0e 100644 --- a/src/Hook.lua +++ b/src/Hook.lua @@ -43,31 +43,33 @@ local M={} local validT = { - ['load'] = false, -- This load hook is called after a - -- modulefile is loaded. - unload = false, -- This unload hook is called after a - -- modulefile is unloaded. - parse_updateFn = false, -- This hook returns the time on the - -- timestamp file. - writeCache = false, -- This hook return whether a cache - -- should be written. - SiteName = false, -- Hook to specify Site Name - -- It is used to generate family - -- prefix: site_FAMILY_ - msgHook = false, -- Hook to print messages after: - -- avail, list, spider, - errWarnMsgHook = false, -- Hook to print messages after LmodError - -- LmodWarning, LmodMessage - groupName = false, -- This hook adds the arch and os name - -- to moduleT.lua to make it safe on - -- shared filesystems. - avail = false, -- Map directory names to labels - restore = false, -- This hook is run after restore operation - startup = false, -- This hook is run when Lmod is called - packagebasename = false, -- Hook to find the patterns that spider uses for reverse map - load_spider = false, -- This hook is run evaluating modules for spider/avail - listHook = false, -- This hook gets the list of active modules - isVisibleHook = false, -- Called to evalate if a module should be hidden or not + ['load'] = false, -- This load hook is called after a + -- modulefile is loaded. + unload = false, -- This unload hook is called after a + -- modulefile is unloaded. + parse_updateFn = false, -- This hook returns the time on the + -- timestamp file. + writeCache = false, -- This hook return whether a cache + -- should be written. + SiteName = false, -- Hook to specify Site Name + -- It is used to generate family + -- prefix: site_FAMILY_ + msgHook = false, -- Hook to print messages after: + -- avail, list, spider, + errWarnMsgHook = false, -- Hook to print messages after LmodError + -- LmodWarning, LmodMessage + groupName = false, -- This hook adds the arch and os name + -- to moduleT.lua to make it safe on + -- shared filesystems. + avail = false, -- Map directory names to labels + restore = false, -- This hook is run after restore operation + startup = false, -- This hook is run when Lmod is called + packagebasename = false, -- Hook to find the patterns that spider uses for reverse map + load_spider = false, -- This hook is run evaluating modules for spider/avail + listHook = false, -- This hook gets the list of active modules + isVisibleHook = false, -- Called to evalate if a module should be hidden or not + spider_decoration = false, -- This hook adds decoration to spider level one output. + -- It can be the category or a property. } -------------------------------------------------------------------------- diff --git a/src/Spider.lua b/src/Spider.lua index 24757f98e..60730bee6 100644 --- a/src/Spider.lua +++ b/src/Spider.lua @@ -872,7 +872,7 @@ function M._Level1(self, dbT, possibleA, sn, key, helpFlg) if (fullVT[kk] == nil) then key = sn Description = v.Description - fullVT[kk] = v.fullName + fullVT[kk] = { fullName = v.fullName, Category = v.Category, propT = v.propT } exampleV = v.fullName end end @@ -886,7 +886,7 @@ function M._Level1(self, dbT, possibleA, sn, key, helpFlg) local ia = 0 if (masterTbl.terse) then for k, v in pairsByKeys(fullVT) do - ia = ia + 1; a[ia] = v .. "\n" + ia = ia + 1; a[ia] = v.fullName .. "\n" end return concatTbl(a,"") end @@ -900,7 +900,10 @@ function M._Level1(self, dbT, possibleA, sn, key, helpFlg) end ia = ia + 1; a[ia] = i18n("m_Versions",{}) for k, v in pairsByKeys(fullVT) do - ia = ia + 1; a[ia] = " " .. v .. "\n" + local decoration = hook.apply("spider_decoration",v) + decoration = decoration and " ("..decoration..")" or "" + local str = v.fullName .. decoration + ia = ia + 1; a[ia] = " " .. str .. "\n" end if (next(possibleA) ~= nil) then