-
Notifications
You must be signed in to change notification settings - Fork 203
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
allow including easyblocks from multiple locations #3311
allow including easyblocks from multiple locations #3311
Conversation
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.
lgtm
@zao Can you confirm that the problem you ran into with |
well, it won't fix @zao's problem, merely output a better error message to fix it we would need to make a decision: should easyblocks included from a PR always take precedence over the others? |
@migueldiascosta Oh, OK. I'd say the easyblocks from the PR should get preference, otherwise what's the point of using it if local easyblocks can get the upper hand? Would you agree @zao? |
easybuild/tools/options.py
Outdated
@@ -1432,7 +1433,8 @@ def set_up_configuration(args=None, logfile=None, testing=False, silent=False): | |||
if eb_go.options.include_easyblocks: | |||
# make sure we're not including the same easyblock twice | |||
included_from_pr = set([os.path.basename(eb) for eb in easyblocks_from_pr]) | |||
included_from_file = set([os.path.basename(eb) for eb in eb_go.options.include_easyblocks]) | |||
included_paths = expand_glob_paths(eb_go.options.include_easyblocks) | |||
included_from_file = set([os.path.basename(eb) for eb in included_paths]) | |||
included_twice = included_from_pr & included_from_file | |||
if included_twice: | |||
raise EasyBuildError("Multiple inclusion of %s, check your --include-easyblocks options", |
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.
@migueldiascosta Rather than raising an error, I think we should let the easyblocks that are included from the PR win over any local easyblocks included with --include-easyblocks
. That makes perfect sense to me, since I don't see a use case where you would be using --include-easyblocks-from-pr
but you would still like to see local easyblocks get precedence?
It's probably also a good idea to print a message for the easyblocks that get pulled in from a PR, to make that a bit more visible?
== easyblock example.py included from PR #1234
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.
Actually, the easyblocks included from the PR should already take precedence, because they are included later and their path is prepended.
I hadn't realised this before but when the local easyblocks are included, they are immediately imported in verify_imports
and they remain in sys.modules
. When the same easyblock is included later from a PR, verify_imports
fails because it continues to use previously imported module.
Not sure if this would be the best approach, but at least to demonstrate what is happening, if we add sys.modules.pop(pymod_spec)
at the end of the loop in verify_imports
, then the error reported by @zao goes away, the easyblocks from a PR take precedence, and we can stop raising this error
I'd agree at least. |
@migueldiascosta Need a conflict resolution now. |
I moved this to the next milestone, it needs a bit of work (not much though I think), and I don't think this should block the v4.2.1 release. |
@migueldiascosta still needs conflict resolution and according to @boegel some more work... |
the actual problem that @zao reported, which occurs when the same easyblock is included both from in order to let the easyblocks included from a PR win over any local easyblock, as @boegel suggested, I think we need to either a) at the end of b) delay calling To me it seems that a) would be best because I hadn't anticipated this behaviour from |
otoh, if the goal of |
@migueldiascosta I think simply cleaning up after doing the verification in The intent of |
easybuild/tools/options.py
Outdated
','.join(included_twice)) | ||
|
||
for easyblock in included_from_pr: | ||
log.info("== easyblock %s included from PR #%s", easyblock, eb_go.options.include_easyblocks_from_pr) |
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.
@migueldiascosta Let's make this more verbose by using print_msg
, so it's not just included in the log file but also shown in the output produced by eb
?
print_msg("== easyblock %s included from PR #%s" % (easyblock, eb_go.options.include_easyblocks_from_pr)), log=self.log)
It's probably also worth introducing a local variable for eb_go.options.include_easyblocks_from_pr
?
pr_easyblocks = eb_go.options.include_easyblocks_from_pr
if pr_easyblocks:
...
easybuild/tools/options.py
Outdated
included_twice = included_from_pr & included_from_file | ||
if included_twice: | ||
raise EasyBuildError("Multiple inclusion of %s, check your --include-easyblocks options", | ||
','.join(included_twice)) | ||
log.info("EasyBlock(s) %s are included from multiple locations, the one from a PR will be used", |
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.
Maybe making this print_warning
makes sense, to avoid surprises?
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.
@migueldiascosta fixed with migueldiascosta#14
mention PR id in warning message when easyblocks are included from multiple locations + catch output in test
(created using
eb --new-pr
)