-
Notifications
You must be signed in to change notification settings - Fork 119
follow Lmod rules for path updates #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
follow Lmod rules for path updates #598
Conversation
xdelaruelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for your contribution. In addition to the code feedback:
-
We should find a better name for the option. It should not relate to an external software (that could change its name or behavior over the time) and it should concisely express what it does for users to easily get it
-
This option should apply to any kind of path element addition. So
module useis also concerned. I have quickly looked at the code base and it seems that adding code toadd-pathprocedure will cover any kind of path element addition. -
The Add new configuration option document will guide you over all the things to adapt to introduce a new config option
tcl/envmngt.tcl.in
Outdated
| } else { | ||
| set val $dir | ||
| set mpath_list "[lsearch -inline -all -not -exact\ | ||
| $mpath_list $dir] $dir" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent does not seem correct (4 spaces instead of 3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still fighting with the Emacs config for the Tcl-Mode. Setting tcl-continued-indent-level to 3 doesn't work as expected. Example:
set mpath_list [lsearch -inline -all -not -exact\
$mpath_list $dir]
Do you have an idea how I can fix this in Emacs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not an Emacs user so I cannot help here unfortunately.
tcl/envmngt.tcl.in
Outdated
| set mpath_list [split $val $separator] | ||
| foreach dir $path_list { | ||
| if {$bhv eq {prepend}} { | ||
| set mpath_list "$dir [lsearch -inline -all -not -exact\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend having the path removal command separated, as it is the same whether we append or we prepend.
tcl/envmngt.tcl.in
Outdated
| } | ||
| } | ||
| } | ||
| if {[info exists countarr($dir)]} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code to be added should be placed under this if branch instead of duplicating the whole foreach loop. this way --duplicates and --ignore-refcount are already handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the revised code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think code addition would be better located within the if {[info exists countarr($dir)]} { code block as there would be no need to handle duplicates, ignore-refcount mode and also no need to have specific code to increase or not the reference counter.
There would be a small duplication of code to add the path entry into the variable value, but everything else will be already managed.
tcl/envmngt.tcl.in
Outdated
| # Local Variables: | ||
| # Mode: tcl-mode | ||
| # tcl-indent-level: 3 | ||
| # End: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason why changing the whole syntax instead of just adding the indent directive using the existing syntax?
tcl/envmngt.tcl.in
Outdated
| set mpath_list [split $val $separator] | ||
| foreach dir $path_list { | ||
| if {$bhv eq {prepend}} { | ||
| set mpath_list "$dir [lsearch -inline -all -not -exact\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be interesting to have a code comment about the design decision: if the path element is found multiple times, all these entries are replaced by a single occurrence at the beginning or at the end
| # ;;; tcl-indent-level: 3 | ||
| # ;;; tcl-continued-indent-level: 3 | ||
| # ;;; indent-tabs-mode: nil | ||
| # ;;; End: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emacs is not happy with the trailing ***, so I removed them. tcl-continued-indent-level still doesn't work for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that tcl-continued-indent-level do not do we need here but it is ok as this situation does not occur too often.
configure
Outdated
| extendeddefault moduleshome initconfin pager pageropts verbosity color \ | ||
| darkbgcolors lightbgcolors termbg lockedconfigs icase unloadmatchorder \ | ||
| searchmatch modulepath loadedmodules quarantinevars wa277 advversspec ml \ | ||
| searchmatch modulepath loadedmodules quarantinevars wa277 lmodpath advversspec ml \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to adapt the option name here
tcl/init.tcl.in
Outdated
| alias indesym sym tag hidden key} {} {} eltlist}\ | ||
| list_terse_output {MODULES_LIST_TERSE_OUTPUT {@listterseoutput@} 0 l\ | ||
| {header idx variant alias indesym sym tag hidden key} {} {} eltlist}\ | ||
| path_entry_reorder {MODULES_PATH_ENTRY_REORDER 1 0 b {0 1}}\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use @pathentryreorder@ as default value for option
tcl/envmngt.tcl.in
Outdated
| } | ||
| } | ||
| } | ||
| if {[info exists countarr($dir)]} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think code addition would be better located within the if {[info exists countarr($dir)]} { code block as there would be no need to handle duplicates, ignore-refcount mode and also no need to have specific code to increase or not the reference counter.
There would be a small duplication of code to add the path entry into the variable value, but everything else will be already managed.
configure
Outdated
| pythonbin=$(get_package_value "$arg") ;; | ||
| --with-module-path=*) | ||
| echo_warning "Option \`--with-module-path' ignored, use \`--modulepath' instead" ;; | ||
| --enable-path-entry-reorder|--disable-path-entry-reorder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the * character after --enable-path-entry-reorder is missing (to handle --enable-path-entry-reorder=no syntax).
best is to move this code to handle an --enable option next to other option of this kind.
| } | ||
| } else { | ||
| set countarr($dir) 1 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still a bit confused/unsure about the reference counter countarr($dir). If path_entry_reorder is true, are there cases where countarr($dir) is not equal to 1? If it is always 1, the current solution might be the best in terms of readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be greater than one (for instance if two loaded modules add the same path entry)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but if path_entry_reorder is true, all occurrences of $dir are removed and exactly one is added again. Looks like I still don't understand the code. :( Maybe an example would help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
countarr is the reference counter of each entry (how many loaded modules set this entry). It helps when unloading a module to determine if the path entry should be kept (if it is used by other loaded modules) or not.
reference counter should behave the same whether path_entry_reorder is set or not. These 2 concepts are not linked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not hesitate to tell me if it is still not clear.
Changes implemented in this PR:
lmod_path_ruleslmod_path_rulesis set: append/prepend dir to path and remove all other occurrences of dir from path