Skip to content

Conversation

@KevinMenden
Copy link
Contributor

@KevinMenden KevinMenden commented Feb 4, 2021

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

This PR adds the command nf-core modules lint <directory> <module> to nf-core.

There are still some things to do, like adding tests, updating the docs and integrating with nf-core lint , but I felt now is the right time to do at least a draft PR in case a different structure is desired :)

Description

I have added a ModuleLint class in the modules.py file, which takes care of the linting. Given a directory, it checks whether it is a clone of nf-core/modules or a pipeline directory. In the former cases, it makes some checks for every module and also looks for the necessary test files. When additionally given a module name in the for software/tool or software (depending on the module), it only lints this module.
When using on a nf-core pipeline directory, it performs the same checks for all modules installed from nf-core (except for the tests) and also runs some quick checks on the local modules (only issuing warnings here).

The ModuleLint.lint() function returns a dict of {passed, warned, failed} which can be used to integrate the results directly into nf-core lint . When used on it's own it can also print similar results as nf-core lint(I basically copied the _print_results code :) )

Alright, that's the current status. What's left to do:

  • add tests
  • integrate with nf-core lint
  • (add more checks?)
  • (potentially add single module test for local modules?)

I would be glad to get some feedback on further checks that could be implemented (or left-out) and of course let me if I should change something in the overall structure.

@KevinMenden KevinMenden added linting WIP Work in progress labels Feb 4, 2021
@codecov
Copy link

codecov bot commented Feb 4, 2021

Codecov Report

Merging #842 (14da141) into dev (11ea9df) will decrease coverage by 0.71%.
The diff coverage is 63.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #842      +/-   ##
==========================================
- Coverage   70.51%   69.79%   -0.72%     
==========================================
  Files          33       34       +1     
  Lines        3680     4129     +449     
==========================================
+ Hits         2595     2882     +287     
- Misses       1085     1247     +162     
Impacted Files Coverage Δ
nf_core/__main__.py 61.26% <57.14%> (-0.20%) ⬇️
nf_core/modules/lint.py 63.18% <63.18%> (ø)
nf_core/modules/__init__.py 100.00% <100.00%> (ø)
nf_core/modules/pipeline_modules.py 79.26% <100.00%> (+1.20%) ⬆️
nf_core/modules/create.py 63.87% <0.00%> (+0.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11ea9df...14da141. Read the comment docs.

@KevinMenden
Copy link
Contributor Author

KevinMenden commented Feb 18, 2021

By the way I've added the file comparison code as a function of the ModuleLint class and not to the NFCoreModule class, mainly so it's easier to access for the normal linter, where want to run this, too. But since we have to create NFCoreModule objects for all the modules anyway, we could also move it to this class, and then call it in a loop. Don't really have preferences there ...

Or did you plan to have that code within this function:

    def check_modules(self):
        log.error("This command is not yet implemented")
        pass

Copy link
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Made a few changes but generally fairly happy now. I'm sure it'll need a lot more work still but I think it's fine to merge.

  • Changed how lint tests are reported
    • Gave everything a test id, so that we can add in the ability to ignore tests in the future with a config, and link to docs.
    • Print results in a table with a column for file path, much easier to read
  • Added --all and if neither that nor tool name is given, run prompts to ask what to lint
  • Other stuff probably. It's late.

@ewels ewels merged commit 99dafb1 into nf-core:dev Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants