Skip to content

Commit e348e6f

Browse files
author
Robert McLay
committed
issue #375: support for is-loaded and is-avail added
1 parent c182eff commit e348e6f

File tree

11 files changed

+108
-54
lines changed

11 files changed

+108
-54
lines changed

README.new

+2
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ Lmod 7.7+
6868
(7.7.34) Fix fish shell output for path and infopath. Fix shell function output for zsh/bash
6969
(7.7.35) issue #374: convert ~ to $HOME internally. This allows C-shell users to use ~
7070
inside a modulefile and have it work when unloading.
71+
issue #375: Support for is-loaded and is-avail added.
72+
7173

build.rtm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# -*- shell-script -*-
3-
PKG_VERSION=`(lua src/lmod.in.lua --dumpversion 2>&1)`
3+
PKG_VERSION=`(lua -e "V=require('src/Version'); print(V.tag())")`
44
echo Making Version: $PKG_VERSION
55

66
parallel_make_install()

docs/source/010_user.rst

+15
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ The module avail command has search capabilities::
7676
will list for any modulefile where the name contains the string "cc".
7777

7878

79+
Users may wish to test whether certain modules are already loaded::
80+
81+
$ module is-loaded packageName1 packageName2 ...
82+
83+
Lmod will return true if all modules are loaded and false if one is
84+
not.
85+
86+
Users also may wish to test whether certain modules can be loaded with
87+
the current $MODULEPATH::
88+
89+
$ module is-avail packageName1 packageName2 ...
90+
91+
Lmod will return true if all modules are available and false if one
92+
can not be loaded.
93+
7994

8095

8196
Modulefiles can have a description section known as "whatis". It is

messageDir/en.lua

+2
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ The system default contains no modules
334334
misc2 = "Prepend or Append path to MODULEPATH.",
335335
misc3 = "remove path from MODULEPATH.",
336336
misc4 = "output list of active modules as a lua table.",
337+
misc_isLoaded = "return true if module is loaded",
338+
misc_isAvail = "return true if module can be loaded",
337339

338340

339341
env_title = "Important Environment Variables:\n" ..

rt/help/err.txt

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
step 1
33
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --version
44
===========================
5-
Modules based on Lua: Version 7.7.20 2018-03-14 12:36 -05:00
5+
Modules based on Lua: Version 7.7.34 2018-05-27 17:42 -05:00
66
by Robert McLay [email protected]
77
===========================
88
step 2
@@ -85,6 +85,8 @@ Deprecated commands:
8585
setdefault [name] Save current list of modules to name if given, otherwise save as the default list for you the user.
8686
===> Use "save" instead. <====
8787
Miscellaneous sub-commands:
88+
is-loaded modulefile return true if module is loaded
89+
is-avail modulefile return true if module can be loaded
8890
show modulefile show the commands in the module file.
8991
use [-a] path Prepend or Append path to MODULEPATH.
9092
unuse path remove path from MODULEPATH.
@@ -97,7 +99,7 @@ Lmod Web Sites
9799
Sourceforge: https://lmod.sf.net
98100
TACC Homepage: https://www.tacc.utexas.edu/research-development/tacc-projects/lmod
99101
To report a bug please read http://lmod.readthedocs.io/en/latest/075_bug_reporting.html
100-
Modules based on Lua: Version 7.7.20 2018-03-14 12:36 -05:00
102+
Modules based on Lua: Version 7.7.34 2018-05-27 17:42 -05:00
101103
by Robert McLay [email protected]
102104
===========================
103105
step 3
@@ -180,6 +182,8 @@ Deprecated commands:
180182
setdefault [name] Save current list of modules to name if given, otherwise save as the default list for you the user.
181183
===> Use "save" instead. <====
182184
Miscellaneous sub-commands:
185+
is-loaded modulefile return true if module is loaded
186+
is-avail modulefile return true if module can be loaded
183187
show modulefile show the commands in the module file.
184188
use [-a] path Prepend or Append path to MODULEPATH.
185189
unuse path remove path from MODULEPATH.
@@ -192,7 +196,7 @@ Lmod Web Sites
192196
Sourceforge: https://lmod.sf.net
193197
TACC Homepage: https://www.tacc.utexas.edu/research-development/tacc-projects/lmod
194198
To report a bug please read http://lmod.readthedocs.io/en/latest/075_bug_reporting.html
195-
Modules based on Lua: Version 7.7.20 2018-03-14 12:36 -05:00
199+
Modules based on Lua: Version 7.7.34 2018-05-27 17:42 -05:00
196200
by Robert McLay [email protected]
197201
===========================
198202
step 4
@@ -212,7 +216,7 @@ Version 9
212216
step 5
213217
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --config
214218
===========================
215-
Modules based on Lua: Version 7.7.20 2018-03-14 12:36 -05:00
219+
Modules based on Lua: Version 7.7.34 2018-05-27 17:42 -05:00
216220
by Robert McLay [email protected]
217221
Description Value
218222
Allow TCL modulefiles yes

rt/i18n/err.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
step 1
33
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --version
44
===========================
5-
Modules based on Lua: Version 7.7.14 2017-11-16 16:23 -07:00
5+
Modules based on Lua: Version 7.7.34 2018-05-27 17:42 -05:00
66
by Robert McLay [email protected]
77
===========================
88
step 2
@@ -127,6 +127,8 @@ Sous-commandes désuètes :
127127
setdefault [name] sauvegarde liste actuelle de modules dans la collection "name" si un nom est donné. Si aucun nom n'est donné, sauvegarde la liste en tant que liste par défaut pour l'usager.
128128
===> Utilisez plutôt "save". <====
129129
Sous-commandes diverses:
130+
is-loaded modulefile return true if module is loaded
131+
is-avail modulefile return true if module can be loaded
130132
show modulefile affiche les commandes contenues dans le fichier de module.
131133
use [-a] path Ajoute un chemin au début (prepend) ou à la fin (append) de la variable d'environnement MODULEPATH.
132134
unuse path Enlève le chemin de la variable d'environnement MODULEPATH.
@@ -139,5 +141,5 @@ Sites web de Lmod
139141
Sourceforge: https://lmod.sf.net
140142
TACC Homepage: https://www.tacc.utexas.edu/research-development/tacc-projects/lmod
141143
Pour rapporter un bogue, veuillez lire http://lmod.readthedocs.io/en/latest/075_bug_reporting.html
142-
Modules based on Lua: Version 7.7.14 2017-11-16 16:23 -07:00
144+
Modules based on Lua: Version 7.7.34 2018-05-27 17:42 -05:00
143145
by Robert McLay [email protected]

rt/use_w_sticky/err.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
step 1
33
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --version
44
===========================
5-
Modules based on Lua: Version 7.7.14 2017-11-16 16:23 -07:00
5+
Modules based on Lua: Version 7.7.34 2018-05-27 17:42 -05:00
66
by Robert McLay [email protected]
77
===========================
88
step 2
@@ -32,7 +32,6 @@ running: module --regression_testing -T use ProjectDIR/rt/use_w_sticky/mf/Other
3232
Prepending: ProjectDIR/rt/use_w_sticky/mf/A to MODULEPATH
3333
Unloading: HPCBIOS (fn: ProjectDIR/rt/use_w_sticky/mf/Core/HPCBIOS/2016q2.lua)
3434
Removing: ProjectDIR/rt/use_w_sticky/mf/Other from MODULEPATH
35-
Loading: HPCBIOS (fn: nil)
3635
Inactive Modules:
3736
1) HPCBIOS
3837
===========================

src/MName.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function M.valid(self)
227227
if (not self.__sn) then
228228
lazyEval(self)
229229
end
230-
return self.__sn ~= false
230+
return self.__fn
231231
end
232232

233233

src/cmdfuncs.lua

+22
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,28 @@ function Help(...)
206206
Access("help",...)
207207
end
208208

209+
function IsAvail(...)
210+
local arg = pack(...)
211+
for i = 1, arg.n do
212+
local mname = MName:new("load", arg[i])
213+
if (not mname:valid()) then
214+
setWarningFlag()
215+
break
216+
end
217+
end
218+
end
219+
220+
function IsLoaded(...)
221+
local arg = pack(...)
222+
for i = 1, arg.n do
223+
local mname = MName:new("mt", arg[i])
224+
if (not mname:isloaded()) then
225+
setWarningFlag()
226+
break
227+
end
228+
end
229+
end
230+
209231
--------------------------------------------------------------------------
210232
-- Use the list of user requested keywords to be searched
211233
-- through the spider cache.

src/lmod.in.lua

+50-44
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,12 @@ function Usage()
198198
a[#a+1] = { "", "", i18n("depr4") }
199199
a[#a+1] = { "" }
200200
a[#a+1] = { i18n("misc_title") }
201-
a[#a+1] = { " show", "modulefile", i18n("misc1") }
202-
a[#a+1] = { " use [-a]", "path", i18n("misc2") }
203-
a[#a+1] = { " unuse", "path", i18n("misc3") }
204-
a[#a+1] = { " tablelist","", i18n("misc4") }
201+
a[#a+1] = { " is-loaded", "modulefile", i18n("misc_isLoaded") }
202+
a[#a+1] = { " is-avail", "modulefile", i18n("misc_isAvail") }
203+
a[#a+1] = { " show", "modulefile", i18n("misc1") }
204+
a[#a+1] = { " use [-a]", "path", i18n("misc2") }
205+
a[#a+1] = { " unuse", "path", i18n("misc3") }
206+
a[#a+1] = { " tablelist", "", i18n("misc4") }
205207
a[#a+1] = { "" }
206208
a[#a+1] = { i18n("env_title") }
207209
a[#a+1] = { " LMOD_COLORIZE", "", i18n("env1") }
@@ -269,48 +271,52 @@ function main()
269271
local useTbl = { name = "use", checkMPATH = true, cmd = Use }
270272
local disableTbl = { name = "disable", checkMPATH = false, cmd = Disable }
271273
local whatisTbl = { name = "whatis", checkMPATH = false, cmd = Whatis }
274+
local isLoadedTbl = { name = "isLoaded", checkMPATH = false, cmd = IsLoaded }
275+
local isAvailTbl = { name = "isAvail", checkMPATH = false, cmd = IsAvail }
272276

273277
local lmodCmdA = {
274-
{'^ad' , loadTbl },
275-
{'^ap' , keywordTbl },
276-
{'^av' , availTbl },
277-
{'^del' , unloadTbl },
278-
{'^des' , mcTbl },
279-
{'^disable' , disableTbl },
280-
{'^dis' , showTbl },
281-
{'^era' , unloadTbl },
282-
{'^gd' , gdTbl },
283-
{'^getd' , gdTbl },
284-
{'^h' , helpTbl },
285-
{'^k' , keywordTbl },
286-
{'^ld' , savelistTbl },
287-
{'^listd' , savelistTbl },
288-
{'^lo' , loadTbl },
289-
{'^l' , listTbl },
290-
{'^mc' , mcTbl },
291-
{'^pu' , purgeTbl },
292-
{'^refr' , refreshTbl },
293-
{'^rel' , updateTbl },
294-
{'^rem' , unloadTbl },
295-
{'^rese' , resetTbl },
296-
{'^rm' , unloadTbl },
297-
{'^r' , restoreTbl },
298-
{'^savel' , savelistTbl },
299-
{'^sd' , saveTbl },
300-
{'^sea' , searchTbl },
301-
{'^setd' , saveTbl },
302-
{'^sh' , showTbl },
303-
{'^sl' , savelistTbl },
304-
{'^sp' , spiderTbl },
305-
{'^sw' , swapTbl },
306-
{'^s' , saveTbl },
307-
{'^table' , tblLstTbl },
308-
{'^try' , tryAddTbl },
309-
{'^unuse$' , unuseTbl },
310-
{'^unl' , unloadTbl },
311-
{'^up' , updateTbl },
312-
{'^use$' , useTbl },
313-
{'^w' , whatisTbl },
278+
{'^ad' , loadTbl },
279+
{'^ap' , keywordTbl },
280+
{'^av' , availTbl },
281+
{'^del' , unloadTbl },
282+
{'^des' , mcTbl },
283+
{'^disable' , disableTbl },
284+
{'^dis' , showTbl },
285+
{'^era' , unloadTbl },
286+
{'^gd' , gdTbl },
287+
{'^getd' , gdTbl },
288+
{'^h' , helpTbl },
289+
{'^is[_-]avail' , isAvailTbl },
290+
{'^is[_-]loaded', isLoadedTbl },
291+
{'^k' , keywordTbl },
292+
{'^ld' , savelistTbl },
293+
{'^listd' , savelistTbl },
294+
{'^lo' , loadTbl },
295+
{'^l' , listTbl },
296+
{'^mc' , mcTbl },
297+
{'^pu' , purgeTbl },
298+
{'^refr' , refreshTbl },
299+
{'^rel' , updateTbl },
300+
{'^rem' , unloadTbl },
301+
{'^rese' , resetTbl },
302+
{'^rm' , unloadTbl },
303+
{'^r' , restoreTbl },
304+
{'^savel' , savelistTbl },
305+
{'^sd' , saveTbl },
306+
{'^sea' , searchTbl },
307+
{'^setd' , saveTbl },
308+
{'^sh' , showTbl },
309+
{'^sl' , savelistTbl },
310+
{'^sp' , spiderTbl },
311+
{'^sw' , swapTbl },
312+
{'^s' , saveTbl },
313+
{'^table' , tblLstTbl },
314+
{'^try' , tryAddTbl },
315+
{'^unuse$' , unuseTbl },
316+
{'^unl' , unloadTbl },
317+
{'^up' , updateTbl },
318+
{'^use$' , useTbl },
319+
{'^w' , whatisTbl },
314320
}
315321

316322
build_i18n_messages()

src/ml_cmd.in.lua

+2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ function main()
198198
swap="swap", sw="swap",
199199
tablelist="tablelist",
200200
['try-load'] = "try-load",
201+
['is-loaded'] = "is-loaded",
202+
['is-avail'] = "is-avail",
201203
unload="unload", rm = "unload", del = "unload", delete="unload", unuse="unuse",
202204
update="update",
203205
use="use",

0 commit comments

Comments
 (0)