Skip to content

Commit 0356029

Browse files
committed
doc: extend Collections desc in module man
1 parent 30599c6 commit 0356029

File tree

3 files changed

+242
-16
lines changed

3 files changed

+242
-16
lines changed

.aspell.en.pws

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 862
1+
personal_ws-1.1 en 870
22
ABBRVLIST
33
ActiveTcl
44
Adrien
@@ -225,6 +225,7 @@ al
225225
alfoo
226226
aliasname
227227
aliastoname
228+
anotherproc
228229
appA
229230
appB
230231
appC
@@ -252,6 +253,7 @@ bashcompletiondir
252253
bashrc
253254
baz
254255
bd
256+
beforeEval
255257
bindir
256258
binpath
257259
bioappA
@@ -299,6 +301,7 @@ cmdModuleSwitch
299301
cmdModuleTest
300302
cmdModuleUnload
301303
cmds
304+
cmdstring
302305
codespell
303306
collectModuleTag
304307
commandexp
@@ -570,9 +573,12 @@ msg
570573
mtreview
571574
multilib
572575
mvapich
576+
mycmd
573577
myhost
574578
mysoftware
575579
mytag
580+
mytarget
581+
myvar
576582
myversion
577583
nF
578584
nL
@@ -606,8 +612,10 @@ openmpi
606612
optionname
607613
os
608614
osVersion
615+
othercmd
609616
othertag
610617
othervalue
618+
othervar
611619
oxymoronic
612620
packagename
613621
parsable

NEWS.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ Modules 5.2.0 (not yet released)
163163
:file:`siteconfig.tcl` file to define specific variables in modulerc
164164
interpreter context. :sitevar:`modulerc_extra_vars` is a list of variable
165165
name and value pairs. (fix issue #286)
166-
* Add :ref:`Site-specific configuration` section in :ref:`module(1)` man page.
166+
* Doc: Add :ref:`Site-specific configuration` section in :ref:`module(1)` man
167+
page.
168+
* Doc: extend :ref:`Collections` section with examples in :ref:`module(1)` man
169+
page.
167170

168171
.. _Nagelfar: http://nagelfar.sourceforge.net/
169172
.. _ShellCheck: https://www.shellcheck.net/

doc/source/module.rst

Lines changed: 229 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,31 +2572,246 @@ Collections
25722572
Collections describe a sequence of :subcmd:`module use<use>` then
25732573
:subcmd:`module load<load>` commands that are interpreted by
25742574
:file:`modulecmd.tcl` to set the user environment as described by this
2575-
sequence. When a collection is activated, with the :subcmd:`restore`
2576-
sub-command, module paths and loaded modules are unused or unloaded if they
2577-
are not part or if they are not ordered the same way as in the collection.
2575+
sequence.
25782576

25792577
Collections are generated by the :subcmd:`save` sub-command that dumps the
25802578
current user environment state in terms of module paths and loaded modules. By
25812579
default collections are saved under the :file:`$HOME/.module` directory.
25822580

2583-
Collections may be valid for a given target if they are suffixed. In this
2584-
case these collections can only be restored if their suffix correspond to
2585-
the current value of the :envvar:`MODULES_COLLECTION_TARGET` environment
2586-
variable (see the dedicated section of this topic below).
2581+
.. parsed-literal::
2582+
2583+
:ps:`$` module list
2584+
Currently Loaded Modulefiles:
2585+
1) foo/1.2 2) bar/2.0 3) qux/3.5
2586+
:ps:`$` module save foo
2587+
:ps:`$` cat $HOME/.module/foo
2588+
module use --append /path/to/modulefiles
2589+
module load foo
2590+
module load bar/2.0
2591+
module load qux/3.5
2592+
2593+
The content of a collection can also be displayed with the :subcmd:`saveshow`
2594+
sub-command. Note that in the above example, bare module name is recorded for
2595+
``foo`` modulefile as loaded version is the implicit default. Loaded version
2596+
recording can be enforced by enabling :mconfig:`collection_pin_version`
2597+
configuration option.
2598+
2599+
.. parsed-literal::
2600+
2601+
:ps:`$` module config collection_pin_version 1
2602+
:ps:`$` module save foo
2603+
:ps:`$` module saveshow foo
2604+
-------------------------------------------------------------------
2605+
:sgrhi:`/home/user/.module/foo`:
2606+
2607+
:sgrcm:`module` use --append /path/to/modulefiles
2608+
:sgrcm:`module` load foo/1.2
2609+
:sgrcm:`module` load bar/2.0
2610+
:sgrcm:`module` load qux/3.5
2611+
2612+
-------------------------------------------------------------------
2613+
2614+
When a collection is activated, with the :subcmd:`restore`
2615+
sub-command, module paths and loaded modules are unused or unloaded if they
2616+
are not part or if they are not ordered the same way as in the collection.
2617+
2618+
.. parsed-literal::
2619+
2620+
:ps:`$` module list
2621+
Currently Loaded Modulefiles:
2622+
1) foo/1.2 2) bar/2.1 3) qux/3.5
2623+
:ps:`$` module restore foo
2624+
Unloading :sgrhi:`qux/3.5`
2625+
Unloading :sgrhi:`bar/2.1`
2626+
Loading :sgrhi:`bar/2.0`
2627+
Loading :sgrhi:`qux/3.5`
2628+
:ps:`$` module list
2629+
Currently Loaded Modulefiles:
2630+
1) foo/1.2 2) bar/2.0 3) qux/3.5
2631+
2632+
In the above example, second and third module loaded are changed. First loaded
2633+
module is not changed or reloaded as it is the same module between current
2634+
environment and collection. As second loaded module was different, this module
2635+
and all those loaded afterward are unloaded to then load the sequence
2636+
described by collection. As a result, third loaded module is reloaded, even if
2637+
is was the same module between current environment and collection.
2638+
2639+
Existing collections can be listed with :subcmd:`savelist` sub-command. They
2640+
can be deleted with :subcmd:`saverm` sub-command.
2641+
2642+
.. parsed-literal::
2643+
2644+
:ps:`$` module savelist
2645+
Named collection list:
2646+
1) default 2) foo
2647+
:ps:`$` module saverm default
2648+
:ps:`$` module savelist
2649+
Named collection list:
2650+
1) foo
2651+
2652+
When no argument is provided to :subcmd:`save`, :subcmd:`restore`,
2653+
:subcmd:`saveshow` or :subcmd:`saverm` sub-commands, the ``default``
2654+
collection is assumed.
2655+
2656+
Collection can also be specified as a full pathname:
2657+
2658+
.. parsed-literal::
2659+
2660+
:ps:`$` module save /path/to/collections/bar
2661+
:ps:`$` module saveshow /path/to/collections/bar
2662+
-------------------------------------------------------------------
2663+
:sgrhi:`/path/to/collections/bar`:
2664+
2665+
:sgrcm:`module` use --append /path/to/modulefiles
2666+
:sgrcm:`module` load foo/1.2
2667+
:sgrcm:`module` load bar/2.0
2668+
:sgrcm:`module` load qux/3.5
2669+
2670+
-------------------------------------------------------------------
2671+
2672+
Initial environment
2673+
"""""""""""""""""""
2674+
2675+
Initial environment state, which corresponds to modulepaths enabled and
2676+
modules loaded during :ref:`Modules initialization<Package Initialization>`,
2677+
is referred as the ``__init__`` collection. This collection is virtual as
2678+
its content is stored in the :envvar:`__MODULES_LMINIT` and not in a file. It
2679+
can be displayed with :subcmd:`saveshow` and restored with :subcmd:`restore`
2680+
sub-command.
2681+
2682+
.. parsed-literal::
2683+
2684+
:ps:`$` module saveshow __init__
2685+
-------------------------------------------------------------------
2686+
:sgrhi:`initial environment`:
2687+
2688+
:sgrcm:`module` use --append /path/to/modulefiles
2689+
:sgrcm:`module` load foo/1.2
2690+
2691+
-------------------------------------------------------------------
25872692
2588-
Stash collections are created and restored respectively with :subcmd:`stash`
2589-
and :subcmd:`stashpop` sub-commands. When created, current environment state
2590-
is dumped in a collection then environment is :subcmd:`reset` to the defined
2591-
initial state. When restored, environment is updated to match stash collection
2592-
definition, then stash collection file is deleted. Stash collections have same
2593-
format and are saved in the same location than other collections. Collection
2594-
target also applies to stash collection.
2693+
If the ``default`` collection does not exist, :subcmd:`saveshow` and
2694+
:subcmd:`restore` sub-commands assume ``__init__`` collection when no argument
2695+
provided to them.
2696+
2697+
.. parsed-literal::
2698+
2699+
:ps:`$` module list
2700+
Currently Loaded Modulefiles:
2701+
1) foo/1.2 2) bar/2.1 3) qux/3.5
2702+
:ps:`$` module savelist
2703+
Named collection list:
2704+
1) foo
2705+
:ps:`$` module restore
2706+
Unloading :sgrhi:`qux/3.5`
2707+
Unloading :sgrhi:`bar/2.1`
2708+
2709+
Initial environment state can also be restored with the :subcmd:`reset`
2710+
sub-command. This sub-command behavior can be changed with
2711+
:mconfig:`reset_target_state` configuration option to choose to just purge
2712+
loaded modules or to restore a specific collection.
2713+
2714+
Collection targets
2715+
""""""""""""""""""
2716+
2717+
A collection target can be defined for current environment session with the
2718+
:mconfig:`collection_target` configuration option. When set, available
2719+
collections are reduced to those suffixed with target name. Which means
2720+
:subcmd:`restore`, :subcmd:`saveshow`, :subcmd:`savelist` and :subcmd:`saverm`
2721+
only find collections matching currently set target.
2722+
2723+
.. parsed-literal::
2724+
2725+
:ps:`$` module savelist
2726+
Named collection list:
2727+
1) foo
2728+
:ps:`$` module config collection_target mytarget
2729+
:ps:`$` module savelist
2730+
No named collection (for target "mytarget").
2731+
:ps:`$` module restore foo
2732+
:sgrer:`ERROR`: Collection foo (for target "mytarget") cannot be found
2733+
2734+
When saving a new collection, generated file is suffixed with currently set
2735+
target name.
2736+
2737+
.. parsed-literal::
2738+
2739+
:ps:`$` module save bar
2740+
:ps:`$` module savelist
2741+
Named collection list (for target "mytarget"):
2742+
1) bar
2743+
:ps:`$` ls $HOME/.module
2744+
bar.mytarget foo
2745+
2746+
Collection targets help to distinguish contexts and make collection reachable
2747+
only from the context they have been made for. For instance the same user
2748+
account may be used to access different OSes or machine architectures. With a
2749+
target set, users are ensured to only access collections built for the context
2750+
they are currently connected to. See also :envvar:`MODULES_COLLECTION_TARGET`
2751+
section.
2752+
2753+
Stash collections
2754+
"""""""""""""""""
2755+
2756+
Current user environment can be stashed with :subcmd:`stash` sub-command. When
2757+
this sub-command is called, current module environment is saved in a stash
2758+
collection then `initial environment`_ is restored.
2759+
2760+
.. parsed-literal::
2761+
2762+
:ps:`$` module list
2763+
Currently Loaded Modulefiles:
2764+
1) foo/1.2 2) qux/4.2
2765+
:ps:`$` module stash
2766+
Unloading :sgrhi:`qux/4.2`
2767+
2768+
Specific sub-commands are available to handle stash collections:
2769+
:subcmd:`stashpop`, :subcmd:`stashlist`, :subcmd:`stashshow`,
2770+
:subcmd:`stashrm` and :subcmd:`stashclear`. A stash collection is restored
2771+
with :subcmd:`stashpop` which also deletes the collection once restored.
2772+
2773+
.. parsed-literal::
2774+
2775+
:ps:`$` module stashlist
2776+
Stash collection list (for target "mytarget"):
2777+
0) stash-1667669750191
2778+
:ps:`$` module stashpop
2779+
Loading :sgrhi:`qux/4.2`
2780+
:ps:`$` module stashlist
2781+
No stash collection (for target "mytarget").
2782+
2783+
Stash collections have same format and are saved in the same location than
2784+
other collections. Collection target also applies to stash collection.
2785+
Creation timestamp is saved in stash collection name.
2786+
2787+
Stash collection can be designated by their full collection name (i.e.,
2788+
*stash-<creation_timestamp>*) or a stash index. Most recent stash
2789+
collection has index *0*, *1* is the one before it. When no argument is
2790+
provided on stash sub-commands, the latest stash collection is assumed (that
2791+
is stash index *0*).
2792+
2793+
.. parsed-literal::
2794+
2795+
:ps:`$` module stashlist
2796+
Stash collection list (for target "mytarget"):
2797+
0) stash-1667669750783 1) stash-1667669750253
2798+
:ps:`$` module stashshow 1
2799+
-------------------------------------------------------------------
2800+
:sgrhi:`/home/user/.module/stash-1667669750253.mytarget:`
2801+
2802+
:sgrcm:`module` use --append /path/to/modulefiles
2803+
:sgrcm:`module` load foo/1.2
2804+
:sgrcm:`module` load bar/2.0
2805+
2806+
-------------------------------------------------------------------
25952807
25962808
.. only:: html
25972809

25982810
.. versionadded:: 4.0
25992811

2812+
.. versionchanged:: 5.2
2813+
Initial environment state introduced
2814+
26002815
.. versionchanged:: 5.2
26012816
Stash collection introduced
26022817

0 commit comments

Comments
 (0)