Skip to content

Commit

Permalink
Issue #511: Only rebuild spider cache when there are modules loaded o…
Browse files Browse the repository at this point in the history
…r pending
  • Loading branch information
Robert McLay committed Apr 15, 2021
1 parent 794eb47 commit f434d56
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
3 changes: 1 addition & 2 deletions rt/broken_modulerc/err.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
step 1
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --version
===========================
Modules based on Lua: Version 8.4.19 2020-12-13 13:58 -06:00
Modules based on Lua: Version 8.4.28 2021-03-20 19:48 -05:00
by Robert McLay [email protected]
===========================
step 2
lua ProjectDIR/src/lmod.in.lua bash --regression_testing use ProjectDIR/rt/broken_modulerc/mf/Core
===========================
Lmod Warning: Badly formed module-version line: module-name must be fully qualified: hdf5 is not.
===========================
step 3
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load git hdf5/1.8.15
Expand Down
1 change: 0 additions & 1 deletion rt/broken_modulerc/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ MODULEPATH=ProjectDIR/rt/broken_modulerc/mf/Core;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={["MTversion"]=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/broken_modulerc/mf/Core",},}';
export _ModuleTable_;
false
===========================
step 3
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load git hdf5/1.8.15
Expand Down
4 changes: 2 additions & 2 deletions rt/extended_default/err.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lua ProjectDIR/src/lmod.in.lua bash --regression_testing load intel/1
Lmod has detected the following error: The following module(s) are unknown: "intel/1"
Please check the spelling or version number. Also try "module spider ..."
It is also possible your cache file is out-of-date; it may help to try:
$ module --ignore-cache load "intel/1"
$ module --ignore_cache load "intel/1"
Also make sure that all modulefiles written in TCL start with the string #%Module
===========================
step 3
Expand All @@ -20,7 +20,7 @@ lua ProjectDIR/src/lmod.in.lua bash --regression_testing load mcr/64/1
Lmod has detected the following error: The following module(s) are unknown: "mcr/64/1"
Please check the spelling or version number. Also try "module spider ..."
It is also possible your cache file is out-of-date; it may help to try:
$ module --ignore-cache load "mcr/64/1"
$ module --ignore_cache load "mcr/64/1"
Also make sure that all modulefiles written in TCL start with the string #%Module
===========================
step 4
Expand Down
16 changes: 8 additions & 8 deletions rt/use_unuse/use_unuse.tdesc
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ testdescript = {
rm -fr _stderr.* _stdout.* err.* out.* .lmod.d
runLmod --version # 1
runLmod load a
runLmod unuse $(testDir)/mf/Core # 2
runLmod load a # 2
runLmod unuse $(testDir)/mf/Core # 3
runLmod use $(testDir)/mf/RTM # 3
runLmod unuse $(testDir)/mf/RTM # 4
runLmod use $(testDir)/mf/RTM # 4
runLmod unuse $(testDir)/mf/RTM # 5
runLmod use ../../mf/RTM # 5
runLmod use ../../mf/RTM # 6
unsetMT
export MODULEPATH=$(testDir)/mf/RTM
runLmod unuse $(testDir)/mf/RTM # 6
runLmod unuse $(testDir)/mf/RTM # 7
unsetMT
runLmod use $(testDir)/mf/RTM2
runLmod unuse $(testDir)/mf/RTM2 # 7
runLmod use $(testDir)/mf/RTM2 # 8
runLmod unuse $(testDir)/mf/RTM2 # 9
HOME=$ORIG_HOME
Expand Down
9 changes: 8 additions & 1 deletion src/MT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,13 @@ function M.list(self, kind, status)
return B
end

function M.empty(self)
local mT = self.mT
return next(mT) == nil
end



--------------------------------------------------------------------------
-- add a property to an active module.
-- @param self An MT object.
Expand Down Expand Up @@ -666,7 +673,7 @@ function M.updateMPathA(self, value)
elseif (type(value) == "table") then
self.mpathA = value
elseif (type(value) == "nil") then
self.mpathA = path2pathA("")
self.mpathA = {} -- path2pathA("")
end
end

Expand Down
15 changes: 11 additions & 4 deletions src/Var.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,17 @@ local function chkMP(name, value, adding)
local mt = require("FrameStk"):singleton():mt()
mt:set_MPATH_change_flag()
mt:updateMPathA(value)
local cached_loads = cosmic:value("LMOD_CACHED_LOADS")
local spider_cache = (cached_loads ~= 'no')
local moduleA = require("ModuleA"):singleton{spider_cache = spider_cache}
moduleA:update{spider_cache = spider_cache}

-- Check to see if there are any currently loaded modules before looking to
-- rebuild the caches.

dbg.print{"mt:empty(): ",mt:empty(), "\n"}
if (not mt:empty()) then
local cached_loads = cosmic:value("LMOD_CACHED_LOADS")
local spider_cache = (cached_loads ~= 'no')
local moduleA = require("ModuleA"):singleton{spider_cache = spider_cache}
moduleA:update{spider_cache = spider_cache}
end
dbg.fini("chkMP")
end
end
Expand Down

0 comments on commit f434d56

Please sign in to comment.