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

applying "sticky" property on load? #709

Closed alextruong closed 4 months ago

alextruong commented 4 months ago

Hello, I was wondering if there's any way for a user to set a module to be sticky for just their environment/current session, on load? I know there's the ability to add the property to the modulefile, but that's too global for what I'm looking for. For example, for my current terminal session (or init scripts), I could do something like module load app/version --sticky, and app/version would resist module purge commands for the duration of the session.

Is this possible currently? I couldn't find anything in the docs for this, so I figured I'd ask here. Thanks!

rtmclay commented 4 months ago

The short answer is no. There is no command line option to do what you want. The long answer is you can get the action you want with some work.

You can copy these modules to your account add the path to $MODULEPATH and load those instead with your modifications. Or you could use the inherit() function. You can read about inherit here:

https://lmod.readthedocs.io/en/latest/340_inherit.html

alextruong commented 4 months ago

Hmm, okay, thanks. Is there anywhere on a potential roadmap for this feature to be added in the future? I feel like it could be useful for if you have some subsection of your environment that's constantly changing (different projects, context switching, etc.), but you'd still like to have your underlying core module set persist, for example.

rtmclay commented 4 months ago

I can think about this but this seems to me to be easily solved with current tools. Have you tried collections? Unless you are using a HPE/Cray computer, collections might be a better solution.

I can see that getting a collection correct might take some iterations to get it correctly. Why not have a shell function that does:

reset_env ()
{
    module purge
    module load A B C
}

Thoughts?

alextruong commented 4 months ago

I suppose that could work, but would have to be configured by individual users. We could make this a global function, but then its contents would still need to be customizable, which may be something we'd have to live with. The use case I had in mind would be that any user could designate any module (or set of modules) to be sticky for a given session. Perhaps the feature would be more relevant if this set of modules would be consistent across multiple sessions instead of just the current one, which would be where I could see the collection method being more useful.

I guess the logical extension would then be to make the shell function take your prospective "sticky" modules as arguments and reload those instead of hard-coding A B and C (etc.) to be reloaded specifically, in which case I suppose that's my question answered.

rtmclay commented 4 months ago

Thanks for your comments. One thing that you probably have thought of was that you could make a modulefile define the shell routine reset_env.

O.K. to close?

alextruong commented 4 months ago

yep, thanks!