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