Closed camillescott closed 1 year ago
You are correct. isloaded() returns true if a module is pending or loaded. Please use isPending() to separate between the two cases. I have updated the docs to point this out.
Thanks for the response. I was hoping to give my users some feedback similar to environment modules on module load and reload; in particular, it appears that lmod unloads and reloads the module every time you run module load nameofmodule
, as opposed to environment modules which no-ops unless you explicitly unload or call reload, and I was hoping to produce a "module reloaded" message when they call module load a second time. Is there a good way to differentiate whether the module is being reloaded short of defining an environment variable for each module and checking it at the beginning?
I know of no way to do that inside a module. Even setting a unique env. var inside a module won't work. If A/1.0 is loaded and a user does:
$ module load A/1.0
All env vars set in A/1.0 would have been unset by the time A/1.0 is reloaded. You'd have to modify Lmod to print a message to do that. Consider submitting a PR to provide an optional message to report reloading an already loaded module. See src/Hub.lua for where you might to this.
Describe the bug
When checking
isloaded
within a module file, the result appears to betrue
even when the module was not previously loaded.To Reproduce
Using this simple modulefile:
Produces no output. Removing the
not
produces output every time; in fact, after the first load, it produces the output twice. Same behavior when also wrapped in anif mode() == "load"
clause.Expected behavior
I was under the impression that the
loaded
status wasn't set until after the module had completed its load. I've seen the above example use ofisloaded
in a bunch of places, so perhaps I'm simply misunderstanding something.Desktop (please complete the following information):
Additional context
Our
lmod
is installed by spack; the spack package applies no patches to this version oflmod
.