urn:noticeable:projects:cbzeG7wTvAIqj21zbUmxEnvironment Modules Updatescea-hpc.github.io/modules2021-01-05T06:48:27.043ZCopyright © Environment ModulesNoticeablehttps://storage.noticeable.io/projects/cbzeG7wTvAIqj21zbUmx/newspages/UPOFxJbXsysxyt1L7iHB/01h55ta3gsp13j52cdnky8js2v-header-logo.pnghttps://storage.noticeable.io/projects/cbzeG7wTvAIqj21zbUmx/newspages/UPOFxJbXsysxyt1L7iHB/01h55ta3gsp13j52cdnky8js2v-header-logo.png#b70e0burn:noticeable:publications:sgRyDqAt3RJ3QltP84mu2021-01-05T05:59:00.001Z2021-01-05T06:48:27.043ZSymbolic version to designate module loaded versionWhen the Advanced module version specifiers is enabled, the loaded symbolic version may be used to designate the currently loaded version of specified module. $ ml display foo@loaded...<p>When the <a href="https://modules.readthedocs.io/en/latest/module.html?utm_source=noticeable&amp;utm_campaign=cbzeg7wtvaiqj21zbumx.symbolic-version-to-designate-module-loaded-version&amp;utm_content=publication+link&amp;utm_id=cbzeG7wTvAIqj21zbUmx.UPOFxJbXsysxyt1L7iHB.sgRyDqAt3RJ3QltP84mu&amp;utm_medium=newspage#advanced-module-version-specifiers" target="_blank" rel="noopener">Advanced module version specifiers</a> is enabled, the <code>loaded</code> symbolic version may be used to designate the currently loaded version of specified module.</p> <pre><code>$ ml display foo@loaded ------------------------------------------------------------------- /path/to/modulefiles/foo/1.0: module-whatis foo/1.0 ------------------------------------------------------------------- </code></pre> <p>If no version of specified module can be found loaded, an error is returned.</p> <pre><code>$ ml display foo@loaded ERROR: No loaded version found for 'foo' module </code></pre> Xavier Delaruelle[email protected]urn:noticeable:publications:caQ04KEApvo5WpZsPwkV2020-12-29T09:37:00.001Z2020-12-29T09:44:57.653ZDetermining module implementation and versionNew Modules variables are introduced to determine during the evaluation of a modulefile or a modulerc what module implementation is currently in use. The ModuleTool variable corresponds to the name of the module implementation and is set...<p>New Modules variables are introduced to determine during the evaluation of a modulefile or a modulerc what <em>module</em> implementation is currently in use. The <code>ModuleTool</code> variable corresponds to the name of the <em>module</em> implementation and is set to <code>Modules</code> for this project. The <code>ModuleToolVersion</code> variable corresponds to the version number of the implementation (e.g. <code>4.7.0</code>).</p> <p>With these new variables it is possible to precisely know what <em>module</em> command is in use then adapt modulefile code to handle a specific behavior or leverage a new feature.</p> <p>The modulefile command <code>versioncmp</code> is also introduced to provide a simple way to compare two version strings and return if first version string is less than, equal to or greater than second one.</p> <pre><code>if {[info exists ModuleTool] &amp;&amp; $ModuleTool eq {Modules} &amp;&amp; [versioncmp $ModuleToolVersion 4.7] &gt;= 0} { # here some code specific for Modules 4.7 and later versions } </code></pre> <p>The <code>ModuleTool</code> and <code>ModuleToolVersion</code> variables and the <code>versioncmp</code> modulefile command are supported by the <a href="https://github.com/TACC/Lmod/?utm_source=noticeable&amp;utm_campaign=cbzeg7wtvaiqj21zbumx.determining-module-implementation-and-version&amp;utm_content=publication+link&amp;utm_id=cbzeG7wTvAIqj21zbUmx.UPOFxJbXsysxyt1L7iHB.caQ04KEApvo5WpZsPwkV&amp;utm_medium=newspage" target="_blank" rel="noopener">Lmod</a> project starting version <code>8.4.8</code>.</p> Xavier Delaruelle[email protected]urn:noticeable:publications:achutQdKS8OfUCfFK5wM2020-09-15T04:21:00.001Z2020-09-15T04:22:58.181ZTracing module executionThe trace verbosity is introduced between the verbose and debug levels to report details on module searches, resolutions, selections and evaluations. Trace mode can be enabled by setting the verbosity config to the trace value or by...<p>The <code>trace</code> verbosity is introduced between the <code>verbose</code> and <code>debug</code> levels to report details on module searches, resolutions, selections and evaluations. Trace mode can be enabled by setting the <code>verbosity</code> config to the <code>trace</code> value or by using the <code>-T</code>/<code>--trace</code> command-line switches.</p> <p>To specifically render trace messages, the <code>tr</code> key is added to the color palette with a default value of <code>2</code> (decreased intensity).</p> <pre><code>$ ml -T foo Evaluate modulerc: '/path/to/modulefiles/.modulerc' Get modules: {foo} matching 'foo' in '/path/to/modulefiles' Resolve: 'foo' into 'bar' Get modules: {bar bar/1.0} matching 'bar' in '/path/to/modulefiles' Select module: 'bar/1.0' (/path/to/modulefiles/bar/1.0) matching 'bar/1.0' Loading bar/1.0 Evaluate modulefile: '/path/to/modulefiles/bar/1.0' as 'bar/1.0' </code></pre> Xavier Delaruelle[email protected]urn:noticeable:publications:EW741DsigBK1PSdQmrsU2020-09-08T19:04:00.001Z2020-09-09T06:26:49.548ZForbidding use of modulesThe module-forbid modulefile command is added to dynamically forbid the evaluation of modulefiles it specifies. When forbidden, a module cannot be loaded and an access error is returned when an attempt is made to evaluate it. $ cat...<p>The <code>module-forbid</code> modulefile command is added to dynamically forbid the evaluation of modulefiles it specifies. When forbidden, a module cannot be loaded and an access error is returned when an attempt is made to evaluate it.</p> <pre><code>$ cat /path/to/modulefiles/foo/.modulerc #%Module4.6 module-forbid foo@1: $ ml foo/1.0 ERROR: Access to module 'foo/1.0' is denied $ ml No Modulefiles Currently Loaded. </code></pre> <p><code>module-forbid</code> statements can be coupled with :mfcmd:<code>module-hide</code> statements to hide modules in addition to forbid their use. <code>module-forbid</code> supports the <code>--not-user</code>, <code>--not-group</code>, <code>--before</code> and <code>--after</code> options to still allow some users or forbid modules before or after a given date time.</p> <p>An additional error message can be defined with the <code>--message</code> option to guide for instance users when they try to evaluate a forbidden module:</p> <pre><code>$ cat /path/to/modulefiles/bar/.modulerc #%Module4.6 module-forbid --message {Software bar/1.0 is decommissioned, please now use\ bar/2.0} --after 2020-09-01 bar/1.0 $ ml bar/1.0 ERROR: Access to module 'bar/1.0' is denied Software bar/1.0 is decommissioned, please now use bar/2.0 </code></pre> <p>When an evaluated module will soon be forbidden, a message is returned to the user to warn him/her of the near limit. An additional warning message can also be defined here with the <code>--nearly-message</code> option to guide users.</p> <pre><code>$ cat /path/to/modulefiles/qux/.modulerc #%Module4.6 module-forbid --nearly-message {Version 1.0 will soon expire, please now use\ version 2.0} --after 2020-09-15 qux/1.0 $ date Tue 08 Sep 2020 06:49:43 AM CEST $ ml qux/1.0 Loading qux/1.0 WARNING: Access to module will be denied starting '2020-09-15' Version 1.0 will soon expire, please now use version 2.0 </code></pre> <p>The range of time the <em>nearly forbidden</em> warning appears can be controlled with the <code>nearly_forbidden_days</code> configuration option, whose value equals to the number of days prior the module starts to be forbidden. This configuration is set to <code>14</code> (days) by default and this value can be controlled at <code>configure</code> time with <code>--with-nearly-forbidden-days</code> option. When the <code>nearly_forbidden_days</code> configuration is set through the <code>config</code> sub-command, the <code>MODULES_NEARLY_FORBIDDEN_DAYS</code> environment variable is set.</p> Xavier Delaruelle[email protected]urn:noticeable:publications:hfjsEtXrUBaej7bhVPih2020-09-03T06:17:00.001Z2020-09-04T05:20:56.996ZHiding modulesThe newly introduced module-hide modulefile command enables to dynamically hide modulefiles, module aliases or symbolic versions specified to it: $ cat /path/to/modulefiles/bar/.modulerc #%Module4.6 module-version bar/1.0...<p>The newly introduced <code>module-hide</code> modulefile command enables to dynamically hide modulefiles, module aliases or symbolic versions specified to it:</p> <pre><code>$ cat /path/to/modulefiles/bar/.modulerc #%Module4.6 module-version bar/1.0 old # hide 'old' symbolic version module-hide bar/old # hide all version 2 and above module-hide bar@2: $ cat /path/to/modulefiles/.modulerc #%Module4.6 # hide all versions of foo module module-hide foo </code></pre> <p><code>module-hide</code> commands should be placed in module rc files and can leverage the <a href="https://timeline.noticeable.io/cbzeG7wTvAIqj21zbUmx/posts/advanced-module-version-specifiers?utm_source=noticeable&amp;utm_campaign=cbzeg7wtvaiqj21zbumx.hiding-modules&amp;utm_content=publication+link&amp;utm_id=cbzeG7wTvAIqj21zbUmx.UPOFxJbXsysxyt1L7iHB.hfjsEtXrUBaej7bhVPih&amp;utm_medium=newspage" target="_blank" rel="noopener">Advanced module version specifiers</a> syntax as shown in the above example.</p> <p>Hidden modules are excluded from available module search or module selection unless query refers to hidden module by its exact name:</p> <pre><code>$ ml av --------------- /path/to/modulefiles --------------- bar/1.0 bar/2.0 $ module load -v foo ERROR: Unable to locate a modulefile for 'foo' $ module load -v foo/1.0 Loading foo/1.0 $ module avail bar/old --------------- /path/to/modulefiles --------------- bar/1.0(old) </code></pre> <p><code>module-hide</code> command accepts a <code>--soft</code> option to apply a lighter of hiding to modules:</p> <pre><code>$ cat /path/to/modulefiles/qux/.modulerc #%Module4.6 # softly hide all qux modules module-hide --soft qux </code></pre> <p>The soft hiding mode enables to hide modules from full availability listing yet keeping the ability to select such module for load without having to use module exact name:</p> <pre><code>$ ml av --------------- /path/to/modulefiles --------------- bar/1.0 bar/2.0 $ ml av qux --------------- /path/to/modulefiles --------------- qux/1.0 qux/2.0 $ module load -v qux Loading qux/2.0 </code></pre> <p>Alternatively, a <code>--hard</code> option can be set on <code>module-hide</code> command to ensure designated modules do not unveil even if referred by their exact name:</p> <pre><code>$ cat /path/to/modulefiles/qux/.modulerc #%Module4.6 # softly hide all qux modules module-hide --soft qux # set highest version of qux hard hidden module-hide --hard qux/3.0 $ ml av qux/3.0 $ ml qux/3.0 ERROR: Unable to locate a modulefile for 'qux/3.0' </code></pre> <p>Some users or groups can be set unaffected by hiding mechanism with the <code>--not-user</code> or <code>--not-group</code> options:</p> <pre><code>$ cat /path/to/modulefiles/quuz/.modulerc #%Module4.6 # hiding does not apply to grp1 and grp2 groups module-hide --not-group {grp1 grp2} quuz $ id --groups --name grp1 grp7 $ ml av quuz --------------- /path/to/modulefiles --------------- quuz/1.0 quuz/2.0 $ ml -v quuz Loading quuz/2.0 </code></pre> <p>Hiding mechanism can also be set effective only before or after a given date time with the <code>--before</code> and <code>--after</code> options. Accepted date time format is <code>YYYY-MM-DD[THH:MM]</code>.</p> <pre><code>$ cat /path/to/modulefiles/fum/.modulerc #%Module4.6 # hide only before a given date module-hide --hard --before 2020-09-01T12:00 fum/1.0 # hide only after a given date module-hide --hard --after 2020-09-01 fum/2.0 $ date Fri 04 Sep 2020 06:21:48 AM CEST $ ml av fum --------------- /path/to/modulefiles --------------- fum/1.0 </code></pre> <p>Hidden modules can be included in available module searches if option <code>--all</code>/<code>-a</code> is set on <code>avail</code>, <code>aliases</code>, <code>whatis</code> or <code>search</code> sub-commands. Hard hidden modules are unaffected by this option and stay hidden.</p> <pre><code>$ ml av -a --------------- /path/to/modulefiles --------------- bar/1.0(old) foo/1.0 fum/1.0 quuz/2.0 qux/2.0 bar/2.0 foo/2.0 quuz/1.0 qux/1.0</code></pre> Xavier Delaruelle[email protected]urn:noticeable:publications:VN2cgrhpPvUwC2sifEEP2020-07-24T12:52:00.001Z2020-07-24T12:54:29.015ZQuerying user's name and groups membershipTwo new sub-commands are introduced for the module-info modulefile command: username and usergroups. They respectively fetch the name of the user currently running modulecmd.tcl or the name of all the groups this user is member of...<p>Two new sub-commands are introduced for the <code>module-info</code> modulefile command: <code>username</code> and <code>usergroups</code>. They respectively fetch the name of the user currently running modulecmd.tcl or the name of all the groups this user is member of.</p> <p>These two new modulefile commands can help to adapt code to specific users or groups. Like for instance to instantiate a modulefile for each group the user is member of:</p> <pre><code>$ cat /path/to/modulefiles/foo/.modulerc #%Module foreach grp [module-info usergroups] { module-virtual foo/$grp .common } $ id -G -n grp1 grp2 grp3 $ module avail --------------- /path/to/modulefiles --------------- foo/grp1 foo/grp2 foo/grp3 </code></pre> <p><code>username</code> and <code>usergroups</code> sub-commands of <code>module-info</code> modulefile command are only supported on Unix platform.</p> Xavier Delaruelle[email protected]urn:noticeable:publications:QNWvVvNvYmyPnbi818n32020-07-16T15:09:00.001Z2020-07-16T15:11:30.947ZEmbed shell scripts in modulefilesThe source-sh modulefile command is introduced to source environment changes done by the evaluation of a shell script passed as argument. With newly introduced sh-to-mod sub-command resulting environment changes done by script are output...<p>The <code>source-sh</code> modulefile command is introduced to source environment changes done by the evaluation of a shell script passed as argument. With newly introduced <code>sh-to-mod</code> sub-command resulting environment changes done by script are output as modulefile commands. <code>source-sh</code> applies those modulefile commands as if they were directly written in loading modulefile.</p> <p><code>source-sh</code> is useful for software providing a shell script for their enablement. If you want to enable such software with <code>module</code> yet using shell script provided by software for this task, just write a modulefile using <code>source-sh</code> command to call the shell script.</p> <p>Keeping the same example used to describe <code>sh-to-mod</code> sub-command: <em>foo</em> software provides a <code>foo-setup.sh</code> script for its activation. Create a modulefile <code>foo/1.2</code> that calls this script:</p> <pre><code>$ cat /path/to/modulefiles/foo/1.2 #%Module source-sh sh /path/to/foo-1.2/foo-setup.sh arg1 </code></pre> <p>Displaying this modulefile indicates the environment changes done by script:</p> <pre><code>$ module display foo/1.2 ------------------------------------------------------------------- /path/to/modulefiles/foo/1.2: prepend-path PATH /path/to/foo-1.2/bin set-alias foo {foobin -q -l} setenv FOOENV arg1 ------------------------------------------------------------------- </code></pre> <p>Loading the modulefile applies the environment changes seen above:</p> <pre><code>$ module load -v foo/1.2 Loading foo/1.2 $ echo $FOOENV arg1 $ alias foo alias foo='foobin -q -l' </code></pre> <p>Track of these changes is kept in user environment to be able to undo them when modulefile is unloaded:</p> <pre><code>$ module unload -v foo/1.2 Unloading foo/1.2 $ echo $FOOENV $ alias foo bash: alias: foo: not found </code></pre> <p>Changes on environment variables, shell aliases, shell functions and current working directory are tracked. The following shells are supported: <em>sh</em>, <em>dash</em>, <em>csh</em>, <em>tcsh</em>, <em>bash</em>, <em>ksh</em>, <em>ksh93</em>, <em>zsh</em> and <em>fish</em>.</p> Xavier Delaruelle[email protected]urn:noticeable:publications:CIbV259hRjBmfBkOhg3F2020-07-07T13:17:00.001Z2020-07-07T13:34:15.381ZTranslating shell scripts into modulefilesThe sh-to-mod sub-command is added to output as a modulefile content the environment changes done by the evaluation of a shell script passed as argument. sh-to-mod is especially useful for software providing a shell script for their...<p>The <code>sh-to-mod</code> sub-command is added to output as a modulefile content the environment changes done by the evaluation of a shell script passed as argument. <code>sh-to-mod</code> is especially useful for software providing a shell script for their enablement in shell session: it can convert these scripts into modulefiles.</p> <p>Say for instance, a <em>foo</em> software has been installed and it provides a <code>foo-setup.sh</code> script to activate <em>foo</em> software in user environment:</p> <pre><code>$ cat /path/to/foo-1.2/foo-setup.sh #!/bin/sh export FOOENV="$1" export PATH=/path/to/foo-1.2/bin:$PATH alias foo='foobin -q -l' </code></pre> <p>Calling <code>module sh-to-mod</code> on this shell script outputs the environment changes it performs as a modulefile content:</p> <pre><code>$ module sh-to-mod sh /path/to/foo-1.2/foo-setup.sh arg1 #%Module prepend-path PATH /path/to/foo-1.2/bin set-alias foo {foobin -q -l} setenv FOOENV arg1 </code></pre> <p>Changes on environment variables, shell aliases, shell functions and current working directory are tracked. The following shells are supported: <em>sh</em>, <em>dash</em>, <em>csh</em>, <em>tcsh</em>, <em>bash</em>, <em>ksh</em>, <em>ksh93</em>, <em>zsh</em> and <em>fish</em>.</p> <p><code>sh-to-mod</code> acts as a full replacement for the standalone <code>createmodule.sh</code> and <code>createmodule.py</code> scripts. However those two scripts are currently still provided for compatibility purpose.</p> <p>This new feature is available in git repository and will be included in next release (v4.6).</p> Xavier Delaruelle[email protected]urn:noticeable:publications:m19DVBnxa763nDG2cwq62020-04-07T07:39:00.001Z2020-04-07T07:42:09.162ZAutomatic default and latest symbolic versionsWhen the implicit default mechanism and the advanced module version specifiers are both enabled, a default and a latest symbolic versions are automatically defined for each module name. This new feature gives the ability to select the...<p>When the implicit default mechanism and the <a href="https://modules.readthedocs.io/en/latest/MIGRATING.html?utm_source=noticeable&amp;utm_campaign=cbzeg7wtvaiqj21zbumx.automatic-default-and-latest-symbolic-versions&amp;utm_content=publication+link&amp;utm_id=cbzeG7wTvAIqj21zbUmx.UPOFxJbXsysxyt1L7iHB.m19DVBnxa763nDG2cwq6&amp;utm_medium=newspage#advanced-module-version-specifiers" target="_blank" rel="noopener">advanced module version specifiers</a> are both enabled, a <code>default</code> and a <code>latest</code> symbolic versions are automatically defined for each module name.</p> <p>This new feature gives the ability to select the highest version available for a module, without knowing beforehand this version name:</p> <pre><code>$ module load -v foo@latest Loading foo/1.10 </code></pre> <p>The symbolic versions are automatically defined unless a symbolic version, an alias or a regular module version already exists for these <code>default</code> or <code>latest</code> version names.</p> Xavier Delaruelle[email protected]urn:noticeable:publications:7cOl5OIanrcgpGEpvXBo2020-03-31T13:20:00.001Z2020-03-31T13:23:09.505ZError stack traceError messages will now embed a stack trace for unknown errors to help localize the root cause of issues. This change applies to modulefile evaluation: Loading foo/1.2 Module ERROR: add-path cannot handle path equals to...<p>Error messages will now embed a stack trace for unknown errors to help localize the root cause of issues. This change applies to modulefile evaluation:</p> <pre><code>Loading foo/1.2 Module ERROR: add-path cannot handle path equals to separator string while executing "append-path PATH :" (file "/path/to/modulefiles/foo/1.2" line 24) Please contact &lt;root@localhost&gt; </code></pre> <p>A stack trace is also returned when an unknown error occurs in <code>modulecmd.tcl</code> script, which facilitates issue report and analysis:</p> <pre><code>$ module load bar ERROR: invalid command name "badcommand" while executing "badcommand" (procedure "module" line 14) invoked from within "module load bar" ("eval" body line 1) invoked from within "eval $execcmdlist" Please report this issue at https://github.com/cea-hpc/modules/issues </code></pre> <p>This new feature is available in git repository and will be included into the upcoming v4.5 release.</p> Xavier Delaruelle[email protected]