Skip to content

Commit

Permalink
use param --fix to update the meta.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Jul 4, 2024
1 parent b7410cd commit 611f8f4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
8 changes: 3 additions & 5 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1579,10 +1579,8 @@ def test_module(ctx, tool, dir, no_prompts, update, once, profile):
is_flag=True,
help="Fix the module version if a newer version is available",
)
@click.option(
"--update-meta-yml", is_flag=True, help="Update the meta.yml file with the correct format of input and outputs"
)
def modules_lint(ctx, tool, dir, registry, key, all, fail_warned, local, passed, sort_by, fix_version, update_meta_yml):
@click.option("--fix", is_flag=True, help="Fix all linting tests if possible.")
def modules_lint(ctx, tool, dir, registry, key, all, fail_warned, local, passed, sort_by, fix_version, fix):
"""
Lint one or more modules in a directory.
Expand All @@ -1599,7 +1597,7 @@ def modules_lint(ctx, tool, dir, registry, key, all, fail_warned, local, passed,
module_lint = ModuleLint(
dir,
fail_warned=fail_warned,
update_meta_yml=update_meta_yml,
fix=fix,
registry=ctx.params["registry"],
remote_url=ctx.obj["modules_repo_url"],
branch=ctx.obj["modules_repo_branch"],
Expand Down
4 changes: 2 additions & 2 deletions nf_core/components/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
component_type,
dir,
fail_warned=False,
update_meta_yml=False,
fix=False,
remote_url=None,
branch=None,
no_pull=False,
Expand All @@ -73,7 +73,7 @@ def __init__(
)

self.fail_warned = fail_warned
self.update_meta_yml = update_meta_yml
self.fix = fix
self.passed = []
self.warned = []
self.failed = []
Expand Down
6 changes: 3 additions & 3 deletions nf_core/modules/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
self,
dir,
fail_warned=False,
update_meta_yml=False,
fix=False,
remote_url=None,
branch=None,
no_pull=False,
Expand All @@ -58,7 +58,7 @@ def __init__(
component_type="modules",
dir=dir,
fail_warned=fail_warned,
update_meta_yml=update_meta_yml,
fix=fix,
remote_url=remote_url,
branch=branch,
no_pull=no_pull,
Expand Down Expand Up @@ -224,7 +224,7 @@ def lint_module(self, mod, progress_bar, registry, local=False, fix_version=Fals
mod.get_inputs_from_main_nf()
mod.get_outputs_from_main_nf()
# Update meta.yml file if requested
if self.update_meta_yml:
if self.fix:
self.update_meta_yml_file(mod)

if self.repo_type == "pipeline" and self.modules_json:
Expand Down
4 changes: 2 additions & 2 deletions nf_core/modules/lint/meta_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def meta_yml(module_lint_object: ComponentLint, module: NFCoreComponent) -> None
module.failed.append(
(
"correct_meta_inputs",
f"Incorrect inputs specified in module `meta.yml`. Inputs should contain: {correct_inputs}\nRun `nf-core modules lint --update-meta-yml` to update the `meta.yml` file.",
f"Incorrect inputs specified in module `meta.yml`. Inputs should contain: {correct_inputs}\nRun `nf-core modules lint --fix` to update the `meta.yml` file.",
module.meta_yml,
)
)
Expand Down Expand Up @@ -155,7 +155,7 @@ def meta_yml(module_lint_object: ComponentLint, module: NFCoreComponent) -> None
module.failed.append(
(
"correct_meta_outputs",
f"Incorrect outputs specified in module `meta.yml`. Outputs should contain: {correct_outputs}\nRun `nf-core modules lint --update-meta-yml` to update the `meta.yml` file.",
f"Incorrect outputs specified in module `meta.yml`. Outputs should contain: {correct_outputs}\nRun `nf-core modules lint --fix` to update the `meta.yml` file.",
module.meta_yml,
)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_modules_lint_new_modules(self):

def test_modules_lint_update_meta_yml(self):
"""update the meta.yml of a module"""
module_lint = nf_core.modules.ModuleLint(dir=self.nfcore_modules, update_meta_yml=True)
module_lint = nf_core.modules.ModuleLint(dir=self.nfcore_modules, fix=True)
module_lint.lint(print_results=False, all_modules="fastqc")
assert len(module_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}"
assert len(module_lint.passed) > 0
Expand Down

0 comments on commit 611f8f4

Please sign in to comment.