TACC / Lmod

Lmod: An Environment Module System based on Lua, Reads TCL Modules, Supports a Software Hierarchy
http://lmod.readthedocs.org
Other
499 stars 128 forks source link

is there a modeA that happons before depends_on modules unload? #705

Closed steverweber closed 5 months ago

steverweber commented 5 months ago
<<EOF cat > /usr/share/lmod/lmod/modulefiles/A.lua
execute {cmd="echo A-LOAD", modeA={"load"}}
execute {cmd="echo A-UNLOAD", modeA={"unload"}}
EOF

<<EOF cat > /usr/share/lmod/lmod/modulefiles/B.lua
depends_on('A')
execute {cmd="echo B-LOAD", modeA={"load"}}
execute {cmd="echo B-UNLOAD", modeA={"unload"}}
EOF

# module load B
A-LOAD
B-LOAD
# module unload B
A-UNLOAD
B-UNLOAD

I expected when using module unload B to have B unloaded before A

B-UNLOAD
A-UNLOAD

One hacky workaround I found is to drop using depends_on and force the order during execute

<<EOF cat > /usr/share/lmod/lmod/modulefiles/B.lua
execute {cmd="module load A; echo B-LOAD", modeA={"load"}}
execute {cmd="echo B-UNLOAD; module unload A", modeA={"unload"}}
EOF

Is there a modeA that happens during unload before unloading the depends_on ? perhaps a modeA={"pre-unload"}

thanks!

steverweber commented 5 months ago

ah disregard ...

<<EOF cat > /usr/share/lmod/lmod/modulefiles/B.lua
execute {cmd="echo B-UNLOAD", modeA={"unload"}}
depends_on('A')
execute {cmd="echo B-LOAD", modeA={"load"}}
EOF