Skip to content

Commit a6249f3

Browse files
committed
doc: add mode-select design doc
1 parent 8192199 commit a6249f3

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

NEWS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Modules 5.6.0 (not yet released)
3838
evaluations when variable initial value is an invalid list. (fix issue #570)
3939
* Fix :mfcmd:`source-sh` and :subcmd:`sh-to-mod` shell translation when used
4040
with new *fish* shell version (4.0).
41+
* Doc: add :ref:`mode-select` design notes.
4142

4243
.. _Security policy: https://github.com/envmodules/modules/blob/main/SECURITY.md
4344
.. _Modules chat room: https://matrix.to/#/#modules:matrix.org

doc/source/design/control-mode-behaviors.rst

+3
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,7 @@ Misc
171171
- ``module use`` may also be interesting for ``module load``
172172
- ``module unuse`` may also be interesting for ``module unload``
173173

174+
- See also :ref:`mode-select` design which corresponds to a different approach
175+
to the same kind of feature
176+
174177
.. vim:set tabstop=2 shiftwidth=2 expandtab autoindent:

doc/source/design/mode-select.rst

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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

Comments
 (0)