-
Notifications
You must be signed in to change notification settings - Fork 190
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
Improve process label linting #2227
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.
Nice work! I left a few comments. You should probably add a test based on the scenario described in #2205 as well.
nf_core/modules/lint/main_nf.py
Outdated
process_label = re.search("'([A-Za-z_-]+)'", process_label[0]).group(0) | ||
finally: | ||
if not process_label in correct_process_labels: | ||
all_labels = [l for l in lines if l.lstrip().startswith("label ")] |
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 might be a good idea to extract this into a function. Something like get_process_label
. That would make things more readable and testable. And also have tests.
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 whole method is now getting quite bloated. If the code here is accepted then I think a next step could be to split out the whole label section rather than just splitting out the list comprehension. Similarly it may be worth considering splitting out the container parsing part.
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.
That was then less clear than I hoped. I meant taking out the whole label selection as you propose - not just a list comprehension.
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.
And I think it would be ideal to do it as part of this PR.
…d for every label
Codecov Report
@@ Coverage Diff @@
## dev #2227 +/- ##
==========================================
+ Coverage 73.09% 73.19% +0.09%
==========================================
Files 77 77
Lines 8408 8423 +15
==========================================
+ Hits 6146 6165 +19
+ Misses 2262 2258 -4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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! but agree with @fabianegli's comment, it would be good to put this code in a separate function check_labels()
for example
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 still think it would be good to add at least one test based on #2205 and I agree with @fabianegli that it would be good to extract this part of the code into it's own function (would make testing easier too!).
@mirpedrol I am going to try and write test(s) now but just wondering whether some of the warnings need to be "new" tests? For example right now all these warnings go under
I'm not sure whether |
I would say it's the expected behaviour to have |
Test added in a kind of unique way as no previous tests check for individual failure/pass cases but this should! |
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.
Thanks for taking the time to add the tests, I only have one comment
tests/modules/lint.py
Outdated
|
||
|
||
@pytest.mark.parametrize("lines,passed,warned,failed", PROCESS_LABEL_TEST_CASES) | ||
def test_modules_lint_check_process_labels(self, lines, passed, warned, failed): |
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 the test is not executed, should be added to test_modules.py
, but I'm not sure how to do this when using the @pytest.mark.parametrize
decorator.
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.
So it turns out you were right but also because we use unittest.TestCase
I cannot parametrize that function. I've just added the test cases as a loop in the test for now. I think it's OK like this for now (to make the release) but we might want to refactor that in future.
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 like this 🙂
#2226 could be the way to refactor this in the future
Arising from #2205
Current behaviour is to look for
label
declarations but only lint the first one occuring.This PR aims to lint each label and check for any conflicts and the presence of 1 standard label.
Non-standard labels are currently not warned about.
PR checklist
CHANGELOG.md
is updateddocs
is updated