Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions MIGRATING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,37 @@ kept across module evaluations. The ``--priority`` option is also available on
the :subcmd:`prepend-path`, :subcmd:`append-path` and :subcmd:`use`
sub-commands.

Selecting modules with regular expression
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The :mfcmd:`module-hide`, :mfcmd:`module-forbid`, :mfcmd:`module-tag` and
:mfcmd:`module-warn` modulefile commands accept a new ``--regexp`` option to
designate the modules they apply to with regular expressions. They are
matched against the name and version of modules, which helps to target modules
that do not share the same name or version prefix.

.. parsed-literal::

:ps:`$` cat /path/to/modulefiles/.modulerc
#%Module
module-hide --regexp {-debug$}
module-forbid --regexp {^(foo|bar)/1\\.} --message {Version 1 is retired}
:ps:`$` module avail -a
--------------- /path/to/modulefiles ---------------
bar/1.4 <F> bar/2.0-debug <H> foo/1.0 <F> foo/2.1
bar/2.0 baz/3.2 foo/2.0 foo/2.1-debug <H>
:ps:`$` module load foo/1.0
:sgrer:`ERROR`: Access to module foo/1.0 is denied
Version 1 is retired

When ``--regexp`` option is set, all the module arguments of the command are
regular expressions. See the :ref:`Regular expression module selection`
section for details.

The :mfcmd:`module-hide-regex` and :mfcmd:`module-forbid-regex` commands are
also introduced as aliases of :mfcmd:`module-hide` and :mfcmd:`module-forbid`
with ``--regexp`` option set.


v5.7
----
Expand Down
8 changes: 8 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ Modules 5.8.0 (not yet released)
of the module providing a family in addition to its name. For compatibility
with Lmod, the :envvar:`LMOD_FAMILY_\<NAME\>_VERSION` environment variable
is also defined and set to the same value.
* Add ``--regexp`` option to :mfcmd:`module-forbid`, :mfcmd:`module-hide`,
:mfcmd:`module-tag` and :mfcmd:`module-warn` modulefile commands to
designate the modules they apply to with a regular expression matched
against module name and version.
* Add :mfcmd:`module-forbid-regex` and :mfcmd:`module-hide-regex` modulerc
commands to support modulerc files written for Lmod. They are aliases of
:mfcmd:`module-forbid` and :mfcmd:`module-hide` with ``--regexp`` option
set.


.. _5.7 release notes:
Expand Down
7 changes: 6 additions & 1 deletion doc/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,8 @@ The following modulefile Tcl commands appeared on Modules 5.
| 5.7 | :mfcmd:`modulepath-ignore` |
+------------+-----------------------------------------------------------------+
| 5.8 | :mfcmd:`module-info modulename<module-info>`, |
| | :mfcmd:`module-info moduleversion<module-info>` |
| | :mfcmd:`module-info moduleversion<module-info>`, |
| | :mfcmd:`module-forbid-regex`, :mfcmd:`module-hide-regex` |
+------------+-----------------------------------------------------------------+

:mfcmd:`system`, :mfcmd:`is-used`
Expand Down Expand Up @@ -1303,6 +1304,10 @@ The following modulefile Tcl commands appeared on Modules 5.
environment.
* options ``--user`` and ``--group`` are added.

Starting with version ``5.8``, the ``--regexp`` option is added to designate
the modules these commands apply to with a regular expression. This option
is also added to :mfcmd:`module-warn`.

:mfcmd:`break`

Starting with version 5.4, a modulefile using :mfcmd:`break` may be unloaded
Expand Down
7 changes: 7 additions & 0 deletions doc/source/design/hide-or-forbid-modulefile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ Specification
- ``--group``: specify a list of groups whose member are specifically affected by hide mechanism
- ``--before``: enables hide mechanism until a given date
- ``--after``: enables hide mechanism after a given date
- ``--regexp``: module arguments are regular expressions designating the modules to hide

- ``module-forbid`` accepts options that change its behavior:

Expand All @@ -240,6 +241,12 @@ Specification
- ``--after``: enables forbid mechanism after a given date
- ``--message``: supplements error message obtained when trying to evaluate a forbidden module with given text message
- ``--nearly-message``: supplements warning message obtained when evaluating a nearly forbidden module with given text message
- ``--regexp``: module arguments are regular expressions designating the modules to forbid

- ``--regexp`` option selects modules with regular expressions rather than module specifications

- See :ref:`module-tags` design notes for the description of this option, as it is shared by ``module-hide``, ``module-forbid``, ``module-tag`` and ``module-warn``
- Hiding level set through regular expressions is compared to the levels set on module specifications and on full path designation: the strongest matching level is retained

- Each use case expressed above are covered by following command:

Expand Down
35 changes: 35 additions & 0 deletions doc/source/design/lmod-tcl-modulefile-compat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Lmod Tcl modulefile compatibility
- ``family``
- ``hide-version``
- ``hide-modulefile``
- ``module-hide-regex``
- ``module-forbid-regex``

- See :ref:`Compatibility with Lmod Tcl modulefile` section in
:ref:`modulefile(5)` man page for the current state of support.
Expand Down Expand Up @@ -398,6 +400,39 @@ Lmod Tcl modulefile compatibility
(not within modulefile)


``module-hide-regex``/``module-forbid-regex``
---------------------------------------------

- Hide or forbid the modules whose name and version match a regular
expression.

- Accept the same options than :mfcmd:`module-hide` and
:mfcmd:`module-forbid` respectively, and one or several regular expressions

- These two commands are implemented by simply calling :mfcmd:`module-hide`
or :mfcmd:`module-forbid` with their ``--regexp`` option set

- No specific code, behavior is the one described for ``--regexp`` option in
:ref:`module-tags` design notes
- As a consequence, an argument starting with ``-`` that is not a known
option is considered a regular expression, which is also the behavior of
Lmod for these commands

- Regular expressions are Tcl regular expressions on Modules whereas they are
Lua patterns on Lmod

- No translation is attempted between the two syntaxes
- Simple expressions have the same meaning on both tools: literal
characters, ``^`` and ``$`` anchors, ``.``, ``*``, ``+``, ``?`` and
bracket expressions like ``[Ff]``
- Others have to be adapted: Lua escapes special characters with ``%``
where Tcl uses ``\``, ``-`` is a quantifier in Lua, ``|`` alternation and
``{}`` bounds do not exist in Lua

- These commands are intended for use only within modulerc evaluation context
(not within modulefile)


``--mode`` option
-----------------

Expand Down
45 changes: 45 additions & 0 deletions doc/source/design/module-tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,51 @@ Defining
- ``--not-group``: specify a list of groups whose member are unaffected by specified tagging
- ``--user``: specify a list of users specifically affected by specified tagging
- ``--group``: specify a list of groups whose member are specifically affected by specified tagging
- ``--regexp``: module arguments are regular expressions designating the modules to tag

- ``--regexp`` option designates target modules with regular expressions

- Useful to target with a single statement modules that have no name or version prefix in common (e.g., all the ``-debug`` versions)
- Option is available on all the commands relying on the tag mechanism to select modules: ``module-tag``, ``module-forbid``, ``module-hide`` and ``module-warn``
- Implemented as a flag that changes the meaning of all the ``modspec`` arguments of the command

- Wherever the flag is positioned on the command line
- Regular expressions and module specifications cannot be mixed on the same command
- At least one ``modspec`` argument is still required
- For ``module-tag``, first argument that does not start with ``-`` is still the tag name

- A regular expression may start with a ``-`` character (e.g., ``-debug$``)

- When ``--regexp`` is set, an argument starting with ``-`` that is not an option known by the command is considered a regular expression
- Rather than raising an *invalid option* error
- Drawback: a misspelled option is silently taken as a regular expression when ``--regexp`` is set
- A regular expression equal to an option name of the command cannot be expressed as is (``[-]-hard`` should be written instead of ``--hard``)
- Nagelfar linter reports such argument as a bad option: lint plugins remove the leading ``-`` of the arguments that do not look like a long option when ``--regexp`` is set

- Regular expressions are Tcl regular expressions

- Matched with ``regexp`` Tcl command against the name and version of module
- Variants of loaded modules are not part of the tested string
- Not anchored: ``^`` and ``$`` have to be used to match the whole module name and version
- Case insensitive match is applied when ``icase`` option enables it for the current context
- Validity is checked when regular expressions are recorded, an error is raised if one is incorrect
- Like module specifications, they are not checked if application criteria of the command (user, group, time frame) are not met

- No module root name can be extracted from a regular expression

- Tags defined on module specifications are stored per module root name to only test the specifications that may match a given module
- Regular expressions are stored in a separate list and each of them is tested against every module looked at
- Cost is thus proportional to the number of regular expressions defined, which is expected to be small

- When both module specifications and regular expressions match a module for a given tag, properties (e.g., message) defined for the module specification are retained

- Among regular expressions, the first one defined that matches wins
- Same precedence principle than full path designation over module specification: the more precise designation wins

- Regular expressions are not recorded as stickiness rule in loaded environment

- Stickiness set through a regular expression is satisfied only if the same module is reloaded
- Recording them would require to distinguish regular expressions from module specifications in ``__MODULES_LMSTICKYRULE``

- ``--user``, ``--group``, ``--not-user`` and ``--not-group`` specification is only supported on Unix platform

Expand Down
2 changes: 2 additions & 0 deletions doc/source/design/module-warn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ inhibit or enable specifically the warning mechanism.
* ``--before``: enables warn mechanism until a given date
* ``--after``: enables warn mechanism after a given date
* ``--message``: warning message to print
* ``--regexp``: module arguments are regular expressions designating the
modules to warn about (see :ref:`module-tags`)

``warning`` tag
---------------
Expand Down
Loading
Loading