mirror of
https://github.com/envmodules/modules.git
synced 2026-06-10 00:56:30 +08:00
Introduce MODULES_COLLECTION_PIN_VERSION
Add the ability to always record module name + version even if this version corresponds to the default one. By default, version number is omitted if it corresponds to the implicit or explicitly set default version. If MODULES_COLLECTION_PIN_VERSION environment variable is set to 1, version number is always recorded. When restoring a collection, we do not know for sure if it was saved with pinned versions or not, so module load and unload movements are determined on both simplified or raw module list. Results with less module to load or unload (means with more matches between module lists) are kept. Acknowledgment: this development has been made and funded within the framework of the PRACE Fifth Implementation Phase (PRACE-5IP) project (http://www.prace-ri.eu/). PRACE-5IP receives funding from the EU's Horizon 2020 research and innovation programme (2014-2020) under grant agreement no. 730913. Closes #89
This commit is contained in:
@@ -162,7 +162,7 @@ switches are accepted:
|
||||
**--default**, **-d**
|
||||
|
||||
On **avail** sub-command, display only the default version of each module
|
||||
name. Default version is either the explicitely set default version or
|
||||
name. Default version is either the explicitly set default version or
|
||||
the highest numerically sorted *modulefile* if no default version set
|
||||
(see Locating Modulefiles section in the :ref:`modulefile(4)` man page).
|
||||
|
||||
@@ -327,6 +327,11 @@ Module Sub-Commands
|
||||
If **MODULES_COLLECTION_TARGET** is set, a suffix equivalent to the value
|
||||
of this variable will be appended to the *collection* file name.
|
||||
|
||||
By default, if loaded modulefile corresponds to the default module version,
|
||||
the bare module name is recorded. If **MODULES_COLLECTION_PIN_VERSION** is
|
||||
set to **1**, module version is always recorded even if it is the default
|
||||
version.
|
||||
|
||||
**restore** [collection]
|
||||
|
||||
Restore the environment state as defined in *collection*. If *collection*
|
||||
@@ -547,6 +552,12 @@ ENVIRONMENT
|
||||
command initialization scripts, the executable program **modulecmd.tcl**,
|
||||
and a directory containing a collection of master *modulefiles*.
|
||||
|
||||
**MODULES_COLLECTION_PIN_VERSION**
|
||||
|
||||
If set to **1**, register exact version number of modulefiles when saving a
|
||||
collection. Elsewhere modulefile version number is omitted if it corresponds
|
||||
to the implicit or explicitly set default version.
|
||||
|
||||
**MODULES_COLLECTION_TARGET**
|
||||
|
||||
The collection target that determines what collections are valid thus
|
||||
|
||||
@@ -4566,6 +4566,18 @@ proc getCollectionTarget {} {
|
||||
}
|
||||
}
|
||||
|
||||
# should modulefile version be pinned when saving collection?
|
||||
proc pinVersionInCollection {} {
|
||||
global env
|
||||
|
||||
if {[info exists env(MODULES_COLLECTION_PIN_VERSION)] &&\
|
||||
$env(MODULES_COLLECTION_PIN_VERSION) eq "1"} {
|
||||
return 1
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
# return saved collections found in user directory which corresponds to
|
||||
# enabled collection target if any set.
|
||||
proc findCollections {} {
|
||||
@@ -5023,9 +5035,14 @@ proc cmdModuleSave {{coll {}}} {
|
||||
}
|
||||
reportDebug "cmdModuleSave: $coll"
|
||||
|
||||
# format collection content
|
||||
set save [formatCollectionContent [getModulePathList] \
|
||||
[getSimplifiedLoadedModuleList]]
|
||||
# format collection content, version number of modulefile are saved if
|
||||
# version pinning is enabled
|
||||
if {[pinVersionInCollection]} {
|
||||
set curr_mod_list [getLoadedModuleList]
|
||||
} else {
|
||||
set curr_mod_list [getSimplifiedLoadedModuleList]
|
||||
}
|
||||
set save [formatCollectionContent [getModulePathList] $curr_mod_list]
|
||||
|
||||
if { [string length $save] == 0} {
|
||||
reportErrorAndExit "Nothing to save in a collection"
|
||||
@@ -5087,6 +5104,13 @@ proc cmdModuleRestore {{coll {}}} {
|
||||
# from current situation with preservation of the load order
|
||||
lassign [getMovementBetweenList $curr_mod_list $coll_mod_list] \
|
||||
mod_to_unload mod_to_load
|
||||
# determine unload movement with raw loaded list in case versions are
|
||||
# pinning in saved collection
|
||||
lassign [getMovementBetweenList $curr_mod_list_raw $coll_mod_list] \
|
||||
mod_to_unload_raw mod_to_load_raw
|
||||
if {[llength $mod_to_unload] > [llength $mod_to_unload_raw]} {
|
||||
set mod_to_unload $mod_to_unload_raw
|
||||
}
|
||||
|
||||
# proceed as well for modulepath
|
||||
lassign [getMovementBetweenList $curr_path_list $coll_path_list] \
|
||||
@@ -5115,11 +5139,19 @@ proc cmdModuleRestore {{coll {}}} {
|
||||
# before starting to unload modules
|
||||
set curr_mod_list [getSimplifiedLoadedModuleList\
|
||||
$curr_mod_list_raw $curr_mod_list]
|
||||
set curr_mod_list_raw [getLoadedModuleList]
|
||||
|
||||
# determine what module to load to restore collection
|
||||
# from current situation with preservation of the load order
|
||||
lassign [getMovementBetweenList $curr_mod_list $coll_mod_list] \
|
||||
mod_to_unload mod_to_load
|
||||
# determine load movement with raw loaded list in case versions are
|
||||
# pinning in saved collection
|
||||
lassign [getMovementBetweenList $curr_mod_list_raw $coll_mod_list] \
|
||||
mod_to_unload_raw mod_to_load_raw
|
||||
if {[llength $mod_to_load] > [llength $mod_to_load_raw]} {
|
||||
set mod_to_load $mod_to_load_raw
|
||||
}
|
||||
|
||||
# proceed as well for modulepath
|
||||
lassign [getMovementBetweenList $curr_path_list $coll_path_list] \
|
||||
|
||||
Reference in New Issue
Block a user