Lmod icon indicating copy to clipboard operation
Lmod copied to clipboard

Should module aliases be dereferenced on listing?

Open lgorenstein opened this issue 3 years ago • 7 comments

Describe the bug Not a bug per se, more of a question. Currently, if a module_alias("myalias", "xyz/1.2.3") is defined, and the user does:

module load myalias
module list

Lmod would list the true dereferenced name (i.e. xyz/1.2.3). Would it make more sense to list the myalias name instead (akin to symlinks behavior)?

To Reproduce

  1. Define a module_alias in a ~/.modulerc.lua or a system-wide MODULERC
  2. module load by the alias name
  3. module list to see the actual name

Expected behavior Frankly, I was expecting to see myalias in the listing ("because that's what I loaded"), not the underlying name. But I could think of pros and cons of both approaches, so this is more of a "what should it do?" question and not a bug report.

Desktop (please complete the following information):

  • OS: Linux
  • Linux distribution: Rocky 8.6
  • Lmod Version: 8.7.14
  • For Lmod Versions 8.7.7+, please run "module --miniConfig" and include the output here.
lev@login00 ~ 78$ module --miniConfig

Modules based on Lua: Version 8.7.14  2022-11-01 10:59 -05:00
    by Robert McLay [email protected]

Changes from Default Configuration
----------------------------------

Name                         Where Set  Default                   Value
----                         ---------  -------                   -----
LMOD_ADMIN_FILE              E          /opt/lmod/etc/admin.list  /opt/lmod/lmod/admin.list
LMOD_ALLOW_ROOT_USE          E          yes                       no
LMOD_AVAIL_STYLE             E          <system>                  grouped:system
LMOD_HAVE_LUA_TERM           C          no                        yes
LMOD_MODULERCFILE            E          /opt/lmod/etc/rc          /opt/lmod/lmod/rc.lua
LMOD_PACKAGE_PATH            D          nil                       <empty>
LMOD_PAGER                   C          less                      /usr/bin/less
LMOD_SYSTEM_DEFAULT_MODULES  E          __unknown__               rcac
LMOD_TCLSH                   C          tclsh                     /usr/bin/tclsh
LMOD_USE_DOT_CONFIG_ONLY     E          no                        yes
MODULEPATH_ROOT              E                                    /opt/spack/cpu
PATH_TO_LUA                  C          lua                       /usr/bin/lua

lgorenstein avatar Dec 15 '22 08:12 lgorenstein

Yes, this feature request is possible. I would not just list myalias, I would list both. Something like:

$ ml
Currently loaded modules:

  1) TACC   2) myalias -> xyz/1.2.3  3) cmake/3.20.4 

No timeline on when this might be available for testing.

rtmclay avatar Dec 19 '22 21:12 rtmclay

Thank you fro considering, this would be great!

Personally, I was thinking more along the lines of "always show the exact name that was explicitly or implicitly loaded (myalias if it was myalias, xyz/1.2.3 if it was xyz/1.2.3"), but can see how showing both in the default prettified output would be a useful approach as well.

That said, for the '--terse' format I think the logic of "show exactly the one that was loaded" (and no multiple entries per line) would be important.

lgorenstein avatar Dec 19 '22 21:12 lgorenstein

You need to explain why you want the --terse case to be the alias and not the real modulefile. That is a major change in how Lmod works for tools like spack, EB and lmodule. I can see where they might want either way. @boegel do you have any thoughts on this possible change to module --terse list?

rtmclay avatar Dec 21 '22 21:12 rtmclay

Frankly, I can see arguments for both behaviors. In my view, it boils down to a choice and difference between "what was loaded?" vs. "what ended up being loaded?". Both are valid questions (and in different situations I may have needed one answered as opposed to the other). So which one of them module --terse list sets to answer?

I am happy to defer and am not really insisting on any one specific interpretation (especially if one of them happen to break established patterns). Rather just want to make sure that there is one consistent answer (and that I learn the question).

lgorenstein avatar Dec 22 '22 03:12 lgorenstein

For EasyBuild specifically, I don't think it matters much (since EB may define aliases for users, but it would always use real module files).

Since --terse is intended to be machine-consumable, I would say that it could have an entry for both: the alias, and the actual module that was loaded.

So, to use the same example as above:

$ ml --terse
TACC
xyz/1.2.3
myalias
cmake/3.20.4 

boegel avatar Dec 22 '22 06:12 boegel

This was a harder project than it would first appear. Please test Lmod 8.7.27 to see if the new listing work for you. The regression tests show how the listing would appear where intel/15 is an alias for intel/15.0.2

===========================
step 5
lua ProjectDIR/src/lmod.in.lua shell --regression_testing list
===========================
Currently Loaded Modules:
  1) intel/15 -> intel/15.0.2
===========================
step 6
lua ProjectDIR/src/lmod.in.lua shell --regression_testing -t list
===========================
intel/15.0.2
intel/15
===========================

The first block shows how "module list" works and the second block shows how "module -t list" works.

rtmclay avatar Jun 12 '23 21:06 rtmclay

Closing this issue

rtmclay avatar Mar 12 '24 22:03 rtmclay