-
Notifications
You must be signed in to change notification settings - Fork 221
skip lines that start with 'module-version' when determining whether a module exists in ModulesTool.exist #3379
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
32fefa9
skip lines that start with 'module-version' when determining whether …
boegel 012edac
fix long line
boegel f237afe
check for errors before skipping lines that start with 'module-' in M…
boegel a56bc4c
fix long line
boegel d8db740
also skip WARNING lines in output of 'module show' + more logging
boegel e483fe4
add missing single quote in log message
boegel b63c952
don't use space in if statement to skip 'module-version' lines in 'mo…
boegel 03fbb3a
clean up log messages in ModulesTool.exist
boegel def5d3f
enhance test for ModulesTool.exist to catch bug fixes in #3379
boegel 4b8137a
revisit log messages in ModulesTool.exist w.r.t. debug/info
boegel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -547,6 +547,7 @@ def mod_exists_via_show(mod_name): | |
|
|
||
| :param mod_name: module name | ||
| """ | ||
| self.log.info("Checking whether %s exists based on output of 'module show'", mod_name) | ||
| stderr = self.show(mod_name) | ||
| res = False | ||
| # Parse the output: | ||
|
|
@@ -555,13 +556,35 @@ def mod_exists_via_show(mod_name): | |
| # - Check first non-whitespace line for something that looks like an absolute path terminated by a colon | ||
| mod_exists_regex = r'\s*/.+:\s*' | ||
| for line in stderr.split('\n'): | ||
| # skip whitespace lines | ||
| self.log.debug("Checking line '%s' to determine whether %s exists...", line, mod_name) | ||
| if OUTPUT_MATCHES['whitespace'].search(line): | ||
| self.log.debug("Treating line '%s' as whitespace, so skipping it", line) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this overly verbose, even for debugging?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It helped a lot with figuring out the problem reported in #3376, so no. |
||
| continue | ||
|
|
||
| # if any errors occured, conclude that module doesn't exist | ||
| if OUTPUT_MATCHES['error'].search(line): | ||
| self.log.debug("Line '%s' looks like an error, so concluding that %s doesn't exist", mod_name) | ||
|
boegel marked this conversation as resolved.
Outdated
|
||
| break | ||
| if re.match(mod_exists_regex, line): | ||
| res = True | ||
|
|
||
| # skip warning lines, which may be produced by modules tool but should not be used | ||
| # to determine whether a module file exists | ||
| if line.startswith('WARNING: '): | ||
|
boegel marked this conversation as resolved.
|
||
| self.log.debug("Skipping warning line '%s'", line) | ||
| continue | ||
|
|
||
| # skip lines that start with 'module-' (like 'module-version'), | ||
| # see https://github.com/easybuilders/easybuild-framework/issues/3376 | ||
| if line.startswith('module- '): | ||
| self.log.debug("Skipping line '%s' since it starts with 'module-version'", line) | ||
|
boegel marked this conversation as resolved.
Outdated
|
||
| continue | ||
|
|
||
| # if line matches pattern that indicates an existing module file, the module file exists | ||
| self.log.debug("Determining whether module %s exists using line '%s'", mod_name, line) | ||
| res = bool(re.match(mod_exists_regex, line)) | ||
| self.log.debug("Result for existence check of %s based on 'module show' output: %s", mod_name, res) | ||
|
boegel marked this conversation as resolved.
Outdated
|
||
| break | ||
|
|
||
| return res | ||
|
|
||
| if skip_avail: | ||
|
|
@@ -577,10 +600,15 @@ def mod_exists_via_show(mod_name): | |
|
|
||
| mods_exist = [] | ||
| for (mod_name, visible) in mod_names: | ||
| self.log.info("Checking whether %s exists...", mod_name) | ||
| if visible: | ||
| mod_exists = mod_name in avail_mod_names | ||
| # module name may be partial, so also check via 'module show' as fallback | ||
| if not mod_exists and maybe_partial: | ||
| if mod_exists: | ||
| self.log.info("Module %s exists (found in list of available modules)", mod_name) | ||
| elif not mod_exists and maybe_partial: | ||
|
boegel marked this conversation as resolved.
Outdated
|
||
| self.log.info("Module %s not found in list of available modules, checking via 'module show'...", | ||
|
boegel marked this conversation as resolved.
|
||
| mod_name) | ||
| mod_exists = mod_exists_via_show(mod_name) | ||
| else: | ||
| # hidden modules are not visible in 'avail', need to use 'show' instead | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.