From f434d56ebb9f6f7298011d6e4741a56398c8dbf1 Mon Sep 17 00:00:00 2001 From: Robert McLay Date: Thu, 15 Apr 2021 15:16:37 -0500 Subject: [PATCH] Issue #511: Only rebuild spider cache when there are modules loaded or pending --- rt/broken_modulerc/err.txt | 3 +-- rt/broken_modulerc/out.txt | 1 - rt/extended_default/err.txt | 4 ++-- rt/use_unuse/use_unuse.tdesc | 16 ++++++++-------- src/MT.lua | 9 ++++++++- src/Var.lua | 15 +++++++++++---- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/rt/broken_modulerc/err.txt b/rt/broken_modulerc/err.txt index 19f248e51..10faab54e 100644 --- a/rt/broken_modulerc/err.txt +++ b/rt/broken_modulerc/err.txt @@ -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 mclay@tacc.utexas.edu =========================== 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 diff --git a/rt/broken_modulerc/out.txt b/rt/broken_modulerc/out.txt index f41c62125..736bbaa1e 100644 --- a/rt/broken_modulerc/out.txt +++ b/rt/broken_modulerc/out.txt @@ -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 diff --git a/rt/extended_default/err.txt b/rt/extended_default/err.txt index 2fa53f306..6dd3ff8f5 100644 --- a/rt/extended_default/err.txt +++ b/rt/extended_default/err.txt @@ -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 @@ -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 diff --git a/rt/use_unuse/use_unuse.tdesc b/rt/use_unuse/use_unuse.tdesc index d7b4c4edf..3ade23fb2 100644 --- a/rt/use_unuse/use_unuse.tdesc +++ b/rt/use_unuse/use_unuse.tdesc @@ -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 diff --git a/src/MT.lua b/src/MT.lua index 7b2644f46..b65c50b7c 100644 --- a/src/MT.lua +++ b/src/MT.lua @@ -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. @@ -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 diff --git a/src/Var.lua b/src/Var.lua index 9a59baf98..07ebd59f8 100644 --- a/src/Var.lua +++ b/src/Var.lua @@ -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