Debian Codegraph @

doc/source/design/mode-select.rst

raw
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 * ``--mode {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 * ``module load-any``
49 * ``module try-load``
50 * ``module unload``
51
52 Support in Modules
53 ------------------
54
55 *Mode select* is not supported at the moment in Modules. Support can be added
56 if someone shows up and expresses a need.
57
58 The implementation of this feature for the ``module load`` command may be
59 non-trivial: currently when unloading modules, only modulefile unloads are
60 expected. Dependency resolution mechanism is expecting to have all the
61 properties of the system when starting by looking at the loaded environment.
62 Adding the ability to throw modulefile loads during this unload process
63 requires to revise the current dependency resolution mechanism.
64
65 Due to that, implementation if asked may first be done only for modulefile Tcl
66 commands others than ``module``.
67
68 .. vim:set tabstop=2 shiftwidth=2 expandtab autoindent: