-
Notifications
You must be signed in to change notification settings - Fork 211
Ignore other classes if software specific easyblock class was found #4769
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
Ignore other classes if software specific easyblock class was found #4769
Conversation
If we have other classes next to a software specific easyblock class in an easyblock file they are likely supplemental. So ignore them in `avail_easyblocks`.
- Reduce indentation - Assign directly to dict
if len(class_names) > 1: | ||
# If there is exactly one software specific easyblock we use that | ||
sw_specific_class_names = [name for name in class_names | ||
if not is_generic_easyblock(name)] | ||
if len(sw_specific_class_names) == 1: | ||
class_names = sw_specific_class_names |
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.
This could possibly be improved to allow additional classes in a generic easyblock by checking if pkg is easybuild.easyblocks.generic and comparing the class_names with the filename
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.
Good point. Implemented. By testing I also found that our (for some reason multi-line regex) would match:
class Foo:
pass
class Bar(EasyBlock):
pass
Resulting in the "class_names" Foo:\n pass\n\n\nclass Bar
because it finishes only at parentheses not the colon
That was fine for Python2 where the parentheses were mandatory in all cases
The class name regex is MULTILINE and hence might start a match at a class name without a super-class and match until another class name with a super-class Restrict by excluding colons in addition to parentheses Also add test for this and the multi-class case to a generic easyblock
Unrelated class in an easyblock file have the same package name as the easyblock and hence the filter doesn't remove them. Instead of the package name check if the class derives from `EasyBlock` which is a much more reliable check whether the class is an EasyBlock.
Through the latest error I've found a duplication of the logic:
I'd say we should only use the logic from |
992e175
to
94b9a72
Compare
@akesandgren Shall we fix the duplication issue here, in a separate PR or not at all? I'd say in a follow-up |
I assume you meant If so let's push that to a separate PR |
Indeed. It's seemingly C&P-mistake-monday ;-) Fixed so the description makes sense |
This now looks good to me |
…asyblocks based on 'EB_' prefix
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
@boegel Shall I do that PR? |
If we have other classes next to a software specific easyblock class in an easyblock file they are likely supplemental.
So ignore them in
avail_easyblocks
.Also 2 cleanups:
EB_
in all places