-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1149 from KevinMenden/lint-modules-json
Lint the `modules.json` for uninstalled modules
- Loading branch information
Showing
6 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
nextflow_config | ||
=============== | ||
|
||
.. automethod:: nf_core.lint.PipelineLint.modules_json |
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python | ||
|
||
from logging import warn | ||
from nf_core.modules.modules_command import ModuleCommand | ||
|
||
|
||
def modules_json(self): | ||
"""Make sure all modules described in the ``modules.json`` file are actually installed | ||
Every module installed from ``nf-core/modules`` must have an entry in the ``modules.json`` file | ||
with an associated version git_sha hash. | ||
* Failure: If module entries are found in ``modules.json`` for modules that are not installed | ||
""" | ||
passed = [] | ||
warned = [] | ||
failed = [] | ||
|
||
# Load pipeline modules and modules.json | ||
modules_command = ModuleCommand(self.wf_path) | ||
modules_json = modules_command.load_modules_json() | ||
|
||
if modules_json: | ||
modules_command.get_pipeline_modules() | ||
|
||
all_modules_passed = True | ||
|
||
for key in modules_json["modules"].keys(): | ||
if not key in modules_command.module_names: | ||
failed.append(f"Entry for `{key}` found in `modules.json` but module is not installed in pipeline.") | ||
all_modules_passed = False | ||
|
||
if all_modules_passed: | ||
passed.append("Only installed modules found in `modules.json`") | ||
else: | ||
warned.append("Could not open `modules.json` file.") | ||
|
||
return {"passed": passed, "warned": warned, "failed": failed} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import nf_core.lint | ||
|
||
|
||
def test_modules_json_fail(self): | ||
self.lint_obj._load() | ||
results = self.lint_obj.modules_json() | ||
assert len(results.get("warned", [])) == 0 | ||
assert len(results.get("failed", [])) == 0 | ||
assert len(results.get("passed", [])) == 1 |
This file contains 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