From 611f8f4fc104e876bcc549e0b868222367a96223 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 4 Jul 2024 12:18:12 +0200 Subject: [PATCH] use param --fix to update the meta.yml --- nf_core/__main__.py | 8 +++----- nf_core/components/lint/__init__.py | 4 ++-- nf_core/modules/lint/__init__.py | 6 +++--- nf_core/modules/lint/meta_yml.py | 4 ++-- tests/modules/lint.py | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 5d34163cb5..d258d73c39 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -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. @@ -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"], diff --git a/nf_core/components/lint/__init__.py b/nf_core/components/lint/__init__.py index b4194e768e..0e3aba23f7 100644 --- a/nf_core/components/lint/__init__.py +++ b/nf_core/components/lint/__init__.py @@ -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, @@ -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 = [] diff --git a/nf_core/modules/lint/__init__.py b/nf_core/modules/lint/__init__.py index f6c2069bda..58a4c47159 100644 --- a/nf_core/modules/lint/__init__.py +++ b/nf_core/modules/lint/__init__.py @@ -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, @@ -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, @@ -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: diff --git a/nf_core/modules/lint/meta_yml.py b/nf_core/modules/lint/meta_yml.py index 9c074ba731..c3b5f3f283 100644 --- a/nf_core/modules/lint/meta_yml.py +++ b/nf_core/modules/lint/meta_yml.py @@ -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, ) ) @@ -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, ) ) diff --git a/tests/modules/lint.py b/tests/modules/lint.py index 7798c0a948..9b6c6a78c3 100644 --- a/tests/modules/lint.py +++ b/tests/modules/lint.py @@ -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