|
| 1 | +.. _mode-select: |
| 2 | + |
| 3 | +Mode select: irreversible module actions |
| 4 | +======================================== |
| 5 | + |
| 6 | +This design document describes how the `Lmod mode select`_ feature could be |
| 7 | +implemented in Tcl modulefiles. |
| 8 | + |
| 9 | +.. _Lmod mode select: https://lmod.readthedocs.io/en/latest/370_irreversible.html |
| 10 | + |
| 11 | +Goal is to describe a solution that could be the same over the different |
| 12 | +``module`` implementations. This way the Tcl modulefiles relying on such |
| 13 | +feature will be processed the same way whatever the ``module`` implementation. |
| 14 | + |
| 15 | +Feature description |
| 16 | +------------------- |
| 17 | + |
| 18 | +*The mode select feature allows modulefiles to specify actions that should |
| 19 | +only be executed in specific modes (load or unload). This is particularly |
| 20 | +useful for operations that are irreversible or need special handling during |
| 21 | +module load/unload cycles.* |
| 22 | + |
| 23 | +When mode select is used, the command is executed as-is if current evaluation |
| 24 | +mode corresponds to one set. Which means a ``setenv`` with a mode select for |
| 25 | +``unload`` evaluation, is evaluated as a ``setenv`` command when unloading |
| 26 | +modulefile. |
| 27 | + |
| 28 | +Such feature does not cope with module dependency definition. |
| 29 | + |
| 30 | +Proposed interface for Tcl modulefile |
| 31 | +------------------------------------- |
| 32 | + |
| 33 | +Proposition is to add a ``--mode`` option on concerned Tcl modulefile |
| 34 | +commands. This ``--mode`` option accepts a Tcl as value, for instance: |
| 35 | + |
| 36 | +* ``--mode load`` |
| 37 | +* ``--module {load unload}`` |
| 38 | + |
| 39 | +Concerned Tcl modulefile commands are: |
| 40 | + |
| 41 | +* ``setenv`` |
| 42 | +* ``unsetenv`` |
| 43 | +* ``prepend-path`` |
| 44 | +* ``append-path`` |
| 45 | +* ``remove-path`` |
| 46 | +* ``pushenv`` |
| 47 | +* ``module load`` |
| 48 | + |
| 49 | +Support in Modules |
| 50 | +------------------ |
| 51 | + |
| 52 | +*Mode select* is not supported at the moment in Modules. Support can be added |
| 53 | +if someone shows up and expresses a need. |
| 54 | + |
| 55 | +The implementation of this feature for the ``module load`` command may be |
| 56 | +non-trivial: currently when unloading modules, only modulefile unloads are |
| 57 | +expected.. Dependency resolution mechanism is expecting to have all the |
| 58 | +properties of the system when starting by looking at the loaded environment. |
| 59 | +Adding the ability to throw modulefile loads during this unload process |
| 60 | +requires to revise the current dependency resolution mechanism. |
| 61 | + |
| 62 | +Due to that, implementation if asked may first be done only for modulefile Tcl |
| 63 | +commands others than ``module load``. |
| 64 | + |
| 65 | +.. vim:set tabstop=2 shiftwidth=2 expandtab autoindent: |
0 commit comments