Repository navigation
Add --priority option to prepend-path, append-path and use - #735
Merged
Merged
Conversation
Describe how a priority can be assigned to the elements added to a path-like variable with prepend-path and append-path, so that a given directory persists at the first or last position of the variable whatever the modules loaded afterward (issue envmodules#185). Priority values get the same meaning than on Lmod, so people knowing Lmod directly understand them: elements are grouped by priority, the prepended elements with the highest priority come first and the appended elements with the highest priority come last. Priority is however set through a --priority option rather than a trailing positional argument as on Lmod, since prepend-path and append-path accept multiple path elements on Modules. Each priority set on an element is recorded across evaluations in a __MODULES_PRIORITY_<VAR> environment variable along with the name of the module setting it, so the priority set by another module applies again once this module is unloaded. The priority applying to an element prioritized several times follows the path_entry_reorder configuration, like the position of an element added several times does. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Introduce a --priority option on prepend-path and append-path modulefile commands and sub-commands, and on the use sub-command, to assign a priority to the added path elements. Elements of the path-like variable are ordered by priority: prepended elements with the highest priority stay first and appended elements with the highest priority stay last, whatever the modulefiles loaded afterward. Elements without priority are placed in between and keep their usual ordering, so existing modulefiles are not affected as long as no priority is set. Priority values get the same meaning than on Lmod. The option form is used rather than the trailing positional argument of Lmod, as these commands accept multiple path elements on Modules. Each priority set on an element is recorded in the __MODULES_PRIORITY_<VAR> environment variable along with the name of the module setting it. A priority set on an element already in the variable is ignored unless path_entry_reorder is enabled, in which case it replaces the applying one and the element is moved, like the position of an element added several times is handled. The priorities set by a module are withdrawn when it is unloaded, so the priority previously set by another module, if any, applies again: the element is moved at once when path_entry_reorder is enabled, at the next addition to the variable otherwise. Priority value is bounded to 1000000. The record is cleared like the reference counter record by setenv, unsetenv and pushenv and pruned when elements are removed from the variable. A priority on MODULEPATH changes the order modulepaths are searched, not the mechanisms reacting to modulepaths being enabled or disabled: a prioritized core modulepath keeps shadowing the branches enabled by a compiler module, while the modules loaded from these branches are still unloaded when the compiler module is. Fixes envmodules#185 Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a
--priorityoption to theprepend-pathandappend-pathmodulefile commands and sub-commands, and to theusesub-command, to assign a priority to the added path elements. Prepended elements with the highest priority stay first in the path-like variable and appended elements with the highest priority stay last, whatever the modulefiles loaded afterward. Elements without priority are placed in between and keep their usual ordering, so existing modulefiles are not affected as long as no priority is set.Priority values get the same meaning as on Lmod (
0means no priority, value bounded to1000000). The option form is used rather than the trailing positional argument of Lmod, as these commands accept multiple path elements on Modules.Priorities are recorded in the
__MODULES_PRIORITY_<VAR>environment variable along with the name of the module setting them, so the ordering is kept across modulefile evaluations and the demands of a module are withdrawn when it is unloaded. A priority set on an element already in the variable is ignored unlesspath_entry_reorderis enabled, in which case it replaces the applying one and the element is moved, like the position of an element added several times is handled.A priority on
MODULEPATHchanges the order modulepaths are searched, not the mechanisms reacting to modulepaths being enabled or disabled: a prioritized core modulepath keeps shadowing the branches enabled by a compiler module, while the modules loaded from these branches are still unloaded when the compiler module is.The first commit adds a design note (
doc/source/design/path-priority.rst) describing the ordering rule, the priority record, the interactions with the other features and the collection handling kept as future work.Fixes #185