From 5743140920d7f5de7c6244a04554770b8ff58da6 Mon Sep 17 00:00:00 2001 From: mashehu Date: Fri, 17 Feb 2023 16:00:19 +0100 Subject: [PATCH 01/29] update required rich version --- CHANGELOG.md | 1 + requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67e6ada896..3608e20e48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ ### General - `nf-core modules/subworkflows info` now prints the include statement for the module/subworkflow ([#2182](https://github.com/nf-core/tools/pull/2182)). +- update minimum version of rich to 13.3.1 ## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19] diff --git a/requirements.txt b/requirements.txt index b3d1f251bf..9dda69b407 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,6 +15,6 @@ questionary>=1.8.0 refgenie requests requests_cache -rich-click>=1.0.0 -rich>=10.7.0 +rich-click>=1.6.1 +rich>=13.3.1 tabulate From 62a26ac0dcfcd56b371afb7806fe38c62cc08072 Mon Sep 17 00:00:00 2001 From: mashehu Date: Fri, 17 Feb 2023 16:16:13 +0100 Subject: [PATCH 02/29] add PR to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3608e20e48..ff5014a3dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ ### General - `nf-core modules/subworkflows info` now prints the include statement for the module/subworkflow ([#2182](https://github.com/nf-core/tools/pull/2182)). -- update minimum version of rich to 13.3.1 +- update minimum version of rich to 13.3.1 ([#2185](https://github.com/nf-core/tools/pull/2185)) ## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19] From 671c1e59dec927fba1473a2ce29f280eb0cc3957 Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Mon, 27 Mar 2023 14:58:17 -0400 Subject: [PATCH 03/29] Add failed lint condition when params.enable_conda is in a module --- nf_core/modules/lint/main_nf.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index d44fe90f1e..1bfbb6825e 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -257,9 +257,15 @@ def check_process_section(self, lines, fix_version, progress_bar): self.warned.append(("process_standard_label", "Process label unspecified", self.main_nf)) for i, l in enumerate(lines): url = None + l = l.strip(" '\"") if _container_type(l) == "bioconda": bioconda_packages = [b for b in l.split() if "bioconda::" in b] - l = l.strip(" '\"") + if _container_type(l) == "bioconda" or _container_type(l) == "conda": + match = re.search(r"params\.enable_conda",l) + if match is None: + self.passed.append(("deprecated_enable_conda", f"Found deprecated parameter 'params.enable_conda' in the conda definition", self.main_nf)) + else: + self.failed.append(("deprecated_enable_conda", f"Deprecated parameter 'params.enable_conda' correctly not found in the conda definition", self.main_nf)) if _container_type(l) == "singularity": # e.g. "https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv1/biocontainers_v1.2.0_cv1.img' :" -> v1.2.0_cv1 # e.g. "https://depot.galaxyproject.org/singularity/fastqc:0.11.9--0' :" -> 0.11.9--0 @@ -518,6 +524,8 @@ def _container_type(line): """Returns the container type of a build.""" if re.search("bioconda::", line): return "bioconda" + if line.startswith("conda"): + return "conda" if line.startswith("https://containers") or line.startswith("https://depot"): # Look for a http download URL. # Thanks Stack Overflow for the regex: https://stackoverflow.com/a/3809435/713980 From d78b9263d3521777fe620848562926f229d4f01c Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Mon, 27 Mar 2023 15:38:39 -0400 Subject: [PATCH 04/29] Empty-Commit From 97fda70a315cc5b5c19a61a4cb7784a5f0f6d294 Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Mon, 27 Mar 2023 15:47:35 -0400 Subject: [PATCH 05/29] fix code formatting with black --- nf_core/modules/lint/main_nf.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index 1bfbb6825e..c9bc9f4526 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -261,11 +261,23 @@ def check_process_section(self, lines, fix_version, progress_bar): if _container_type(l) == "bioconda": bioconda_packages = [b for b in l.split() if "bioconda::" in b] if _container_type(l) == "bioconda" or _container_type(l) == "conda": - match = re.search(r"params\.enable_conda",l) + match = re.search(r"params\.enable_conda", l) if match is None: - self.passed.append(("deprecated_enable_conda", f"Found deprecated parameter 'params.enable_conda' in the conda definition", self.main_nf)) + self.passed.append( + ( + "deprecated_enable_conda", + f"Found deprecated parameter 'params.enable_conda' in the conda definition", + self.main_nf, + ) + ) else: - self.failed.append(("deprecated_enable_conda", f"Deprecated parameter 'params.enable_conda' correctly not found in the conda definition", self.main_nf)) + self.failed.append( + ( + "deprecated_enable_conda", + f"Deprecated parameter 'params.enable_conda' correctly not found in the conda definition", + self.main_nf, + ) + ) if _container_type(l) == "singularity": # e.g. "https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv1/biocontainers_v1.2.0_cv1.img' :" -> v1.2.0_cv1 # e.g. "https://depot.galaxyproject.org/singularity/fastqc:0.11.9--0' :" -> 0.11.9--0 From 30a6dc3dafd8a81d28920093a85f2526e78d84a4 Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Mon, 27 Mar 2023 16:14:12 -0400 Subject: [PATCH 06/29] add tests to account for params.enable_conda failures --- tests/modules/lint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/modules/lint.py b/tests/modules/lint.py index 476481a109..70fa6bff2b 100644 --- a/tests/modules/lint.py +++ b/tests/modules/lint.py @@ -66,7 +66,7 @@ def test_modules_lint_gitlab_modules(self): self.mods_install_gitlab.install("multiqc") module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL) module_lint.lint(print_results=False, all_modules=True) - assert len(module_lint.failed) == 0 + assert len(module_lint.failed) == 1 assert len(module_lint.passed) > 0 assert len(module_lint.warned) >= 0 @@ -77,7 +77,7 @@ def test_modules_lint_multiple_remotes(self): self.mods_install_gitlab.install("multiqc") module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL) module_lint.lint(print_results=False, all_modules=True) - assert len(module_lint.failed) == 0 + assert len(module_lint.failed) == 1 assert len(module_lint.passed) > 0 assert len(module_lint.warned) >= 0 @@ -103,6 +103,6 @@ def test_modules_lint_patched_modules(self): all_modules=True, ) - assert len(module_lint.failed) == 0 + assert len(module_lint.failed) == 1 assert len(module_lint.passed) > 0 assert len(module_lint.warned) >= 0 From 95594951a9fbebabcbb9c26a828e1ba3e615e815 Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Mon, 27 Mar 2023 16:31:16 -0400 Subject: [PATCH 07/29] Add enable_conda linting to CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0dd174e3d..112c05d8bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ ### Linting +- Update modules lint test to fail if enable_conda is found ([#2213](https://github.com/nf-core/tools/pull/2213)) + ### Modules - Add an `--empty-template` option to create a module without TODO statements or examples ([#2175](https://github.com/nf-core/tools/pull/2175) & [#2177](https://github.com/nf-core/tools/pull/2177)) From c2ab6fee5975280d2e99815ca1b23abb6456073e Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Mon, 27 Mar 2023 16:43:50 -0400 Subject: [PATCH 08/29] Fix number of fails in assertion test --- tests/modules/lint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/lint.py b/tests/modules/lint.py index 70fa6bff2b..18c0dc4dab 100644 --- a/tests/modules/lint.py +++ b/tests/modules/lint.py @@ -66,7 +66,7 @@ def test_modules_lint_gitlab_modules(self): self.mods_install_gitlab.install("multiqc") module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL) module_lint.lint(print_results=False, all_modules=True) - assert len(module_lint.failed) == 1 + assert len(module_lint.failed) == 2 assert len(module_lint.passed) > 0 assert len(module_lint.warned) >= 0 From 8242026f48d135a668c007295d7d01c6b8196d4b Mon Sep 17 00:00:00 2001 From: ash Date: Tue, 28 Mar 2023 14:22:50 +0100 Subject: [PATCH 09/29] Make `nf-core modules lint` use new config file --- nf_core/components/components_command.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/nf_core/components/components_command.py b/nf_core/components/components_command.py index 31ab1a71fb..775b205cf5 100644 --- a/nf_core/components/components_command.py +++ b/nf_core/components/components_command.py @@ -6,6 +6,7 @@ import yaml +import nf_core.utils from nf_core.modules.modules_json import ModulesJson from nf_core.modules.modules_repo import ModulesRepo @@ -162,24 +163,13 @@ def install_component_files(self, component_name, component_version, modules_rep def load_lint_config(self): """Parse a pipeline lint config file. - Look for a file called either `.nf-core-lint.yml` or - `.nf-core-lint.yaml` in the pipeline root directory and parse it. - (`.yml` takes precedence). + Load the '.nf-core.yml' config file and extract + the lint config from it Add parsed config to the `self.lint_config` class attribute. """ - config_fn = os.path.join(self.dir, ".nf-core-lint.yml") - - # Pick up the file if it's .yaml instead of .yml - if not os.path.isfile(config_fn): - config_fn = os.path.join(self.dir, ".nf-core-lint.yaml") - - # Load the YAML - try: - with open(config_fn, "r") as fh: - self.lint_config = yaml.safe_load(fh) - except FileNotFoundError: - log.debug(f"No lint config file found: {config_fn}") + _, tools_config = nf_core.utils.load_tools_config(self.dir) + self.lint_config = tools_config.get("lint", {}) def check_modules_structure(self): """ From 8d3404dbad4fce136076a4ec292d8745cd3ae960 Mon Sep 17 00:00:00 2001 From: ash Date: Tue, 28 Mar 2023 14:23:36 +0100 Subject: [PATCH 10/29] Correct old reference to .nf-core-lint.yaml --- nf_core/__main__.py | 2 +- nf_core/lint/nextflow_config.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 841cb9f7e7..2cf3805902 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -341,7 +341,7 @@ def lint(ctx, dir, release, fix, key, show_passed, fail_ignored, fail_warned, ma meets the nf-core guidelines. Documentation of all lint tests can be found on the nf-core website: [link=https://nf-co.re/tools-docs/]https://nf-co.re/tools-docs/[/] - You can ignore tests using a file called [blue].nf-core-lint.yaml[/] [i](if you have a good reason!)[/]. + You can ignore tests using a file called [blue].nf-core.yml[/] [i](if you have a good reason!)[/]. See the documentation for details. """ diff --git a/nf_core/lint/nextflow_config.py b/nf_core/lint/nextflow_config.py index 79bce3e7f1..af018331f0 100644 --- a/nf_core/lint/nextflow_config.py +++ b/nf_core/lint/nextflow_config.py @@ -92,20 +92,22 @@ def nextflow_config(self): * Process-level configuration syntax still using the old Nextflow syntax, for example: ``process.$fastqc`` instead of ``process withName:'fastqc'``. .. tip:: You can choose to ignore tests for the presence or absence of specific config variables - by creating a file called ``.nf-core-lint.yml`` in the root of your pipeline and creating + by creating a file called ``.nf-core.yml`` in the root of your pipeline and creating a list the config variables that should be ignored. For example: .. code-block:: yaml - nextflow_config: - - params.input + lint: + nextflow_config: + - params.input The other checks in this test (depreciated syntax etc) can not be individually identified, but you can skip the entire test block if you wish: .. code-block:: yaml - nextflow_config: False + lint: + nextflow_config: False """ passed = [] warned = [] From cf45d4941e8189f1c78062e428777d754c7a59b9 Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Tue, 28 Mar 2023 09:43:53 -0400 Subject: [PATCH 11/29] Remove container determination of bioconda in favor of determining conda --- nf_core/modules/lint/main_nf.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index c9bc9f4526..1caa67ac4f 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -258,9 +258,8 @@ def check_process_section(self, lines, fix_version, progress_bar): for i, l in enumerate(lines): url = None l = l.strip(" '\"") - if _container_type(l) == "bioconda": + if _container_type(l) == "conda": bioconda_packages = [b for b in l.split() if "bioconda::" in b] - if _container_type(l) == "bioconda" or _container_type(l) == "conda": match = re.search(r"params\.enable_conda", l) if match is None: self.passed.append( @@ -534,8 +533,6 @@ def _get_build(response): def _container_type(line): """Returns the container type of a build.""" - if re.search("bioconda::", line): - return "bioconda" if line.startswith("conda"): return "conda" if line.startswith("https://containers") or line.startswith("https://depot"): From 2242cf4f0e6098dab8c11831bec62a3c521b6c0a Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Tue, 28 Mar 2023 09:44:35 -0400 Subject: [PATCH 12/29] Fix bug where lint messages are swapped --- nf_core/modules/lint/main_nf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index 1caa67ac4f..0b82ad2bad 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -265,7 +265,7 @@ def check_process_section(self, lines, fix_version, progress_bar): self.passed.append( ( "deprecated_enable_conda", - f"Found deprecated parameter 'params.enable_conda' in the conda definition", + f"Deprecated parameter 'params.enable_conda' correctly not found in the conda definition", self.main_nf, ) ) @@ -273,7 +273,7 @@ def check_process_section(self, lines, fix_version, progress_bar): self.failed.append( ( "deprecated_enable_conda", - f"Deprecated parameter 'params.enable_conda' correctly not found in the conda definition", + f"Found deprecated parameter 'params.enable_conda' in the conda definition", self.main_nf, ) ) From dfe2057fe514ab73b5586e3e98a114f2161aa972 Mon Sep 17 00:00:00 2001 From: ash Date: Tue, 28 Mar 2023 14:55:09 +0100 Subject: [PATCH 13/29] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0dd174e3d..007901d476 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ ### Linting +- Read module lint configuration from `.nf-core.yml`, not `.nf-core-lint.yml` ([#2221](https://github.com/nf-core/tools/pull/2221)) + ### Modules - Add an `--empty-template` option to create a module without TODO statements or examples ([#2175](https://github.com/nf-core/tools/pull/2175) & [#2177](https://github.com/nf-core/tools/pull/2177)) From e8baf1928c171f6d7ee0aeffa8ae681c9fc0260e Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Tue, 28 Mar 2023 15:17:05 -0400 Subject: [PATCH 14/29] bugfix --- nf_core/modules/lint/main_nf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index 0b82ad2bad..dd565c9a4e 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -488,7 +488,7 @@ def _fix_module_version(self, current_version, latest_version, singularity_tag, for line in lines: l = line.strip(" '\"") build_type = _container_type(l) - if build_type == "bioconda": + if build_type == "conda": new_lines.append(re.sub(rf"{current_version}", f"{latest_version}", line)) elif build_type in ("singularity", "docker"): # Check that the new url is valid From 7e40458a471e62f158d3a9bd8b44a047b5924d37 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Mon, 27 Mar 2023 14:19:42 +0200 Subject: [PATCH 15/29] Test subworkflow yml dumper --- tests/subworkflows/create_test_yml.py | 24 ++++++++++++++++++++++++ tests/test_subworkflows.py | 3 +++ 2 files changed, 27 insertions(+) create mode 100644 tests/subworkflows/create_test_yml.py diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py new file mode 100644 index 0000000000..1654117bb6 --- /dev/null +++ b/tests/subworkflows/create_test_yml.py @@ -0,0 +1,24 @@ +import os +from unittest import mock + +import pytest + +import nf_core.subworkflows + +from ..utils import with_temporary_folder + + +@with_temporary_folder +def test_subworkflows_custom_yml_dumper(self, out_dir): + """Try to create a yml file with the custom yml dumper""" + yml_output_path = os.path.join(out_dir, "test.yml") + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow="test/tool", + directory=self.pipeline_dir, + test_yml_output_path=yml_output_path, + no_prompts=True, + ) + meta_builder.test_yml_output_path = yml_output_path + meta_builder.tests = [{"testname": "myname"}] + meta_builder.print_test_yml() + assert os.path.isfile(yml_output_path) diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index c5d768ab10..b11af31325 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -93,6 +93,9 @@ def tearDown(self): test_subworkflows_create_nfcore_modules, test_subworkflows_create_succeed, ) + from .subworkflows.create_test_yml import ( + test_subworkflows_custom_yml_dumper, + ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, test_subworkflows_info_local, From 488b25e1498f72675dec264dbb15449be0e00de9 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Mon, 27 Mar 2023 14:34:21 +0200 Subject: [PATCH 16/29] Test create_test_file_dict --- tests/subworkflows/create_test_yml.py | 16 ++++++++++++++++ tests/test_subworkflows.py | 1 + 2 files changed, 17 insertions(+) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index 1654117bb6..ff4f03c1fd 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -22,3 +22,19 @@ def test_subworkflows_custom_yml_dumper(self, out_dir): meta_builder.tests = [{"testname": "myname"}] meta_builder.print_test_yml() assert os.path.isfile(yml_output_path) + + +@with_temporary_folder +def test_subworkflows_test_file_dict(self, test_file_dir): + """Create dict of test files and create md5 sums""" + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow="test/tool", + directory=self.pipeline_dir, + test_yml_output_path="./", + no_prompts=True, + ) + with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + fh.write("this line is just for testing") + test_files = meta_builder.create_test_file_dict(test_file_dir) + assert len(test_files) == 1 + assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index b11af31325..50f674f29e 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -95,6 +95,7 @@ def tearDown(self): ) from .subworkflows.create_test_yml import ( test_subworkflows_custom_yml_dumper, + test_subworkflows_test_file_dict, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From c404c8717d98e44a703575a754a298b1e09d35da Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Mon, 27 Mar 2023 15:06:17 +0200 Subject: [PATCH 17/29] Test get_md5_sums --- nf_core/subworkflows/test_yml_builder.py | 4 ++-- tests/subworkflows/create_test_yml.py | 19 +++++++++++++++++++ tests/test_subworkflows.py | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/nf_core/subworkflows/test_yml_builder.py b/nf_core/subworkflows/test_yml_builder.py index 39877ca241..384561bf68 100644 --- a/nf_core/subworkflows/test_yml_builder.py +++ b/nf_core/subworkflows/test_yml_builder.py @@ -195,7 +195,7 @@ def build_single_test(self, entry_point): ).strip() ep_test["tags"] = [t.strip() for t in prompt_tags.split(",")] - ep_test["files"] = self.get_md5_sums(entry_point, ep_test["command"]) + ep_test["files"] = self.get_md5_sums(ep_test["command"]) return ep_test @@ -272,7 +272,7 @@ def create_test_file_dict(self, results_dir, is_repeat=False): return test_files - def get_md5_sums(self, entry_point, command, results_dir=None, results_dir_repeat=None): + def get_md5_sums(self, command, results_dir=None, results_dir_repeat=None): """ Recursively go through directories and subdirectories and generate tuples of (, ) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index ff4f03c1fd..33ad59d655 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -38,3 +38,22 @@ def test_subworkflows_test_file_dict(self, test_file_dir): test_files = meta_builder.create_test_file_dict(test_file_dir) assert len(test_files) == 1 assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" + + +@with_temporary_folder +def test_subworkflows_create_test_yml_get_md5(self, test_file_dir): + """Get md5 sums from a dummy output""" + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow="test/tool", + directory=self.pipeline_dir, + test_yml_output_path="./", + no_prompts=True, + ) + with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + fh.write("this line is just for testing") + test_files = meta_builder.get_md5_sums( + command="dummy", + results_dir=test_file_dir, + results_dir_repeat=test_file_dir, + ) + assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index 50f674f29e..f888c982de 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -96,6 +96,7 @@ def tearDown(self): from .subworkflows.create_test_yml import ( test_subworkflows_custom_yml_dumper, test_subworkflows_test_file_dict, + test_subworkflows_create_test_yml_get_md5, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From 4db16799abdddccf61ca058fb4bd68d88369dccb Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Tue, 28 Mar 2023 13:29:09 +0200 Subject: [PATCH 18/29] Test scrape_workflow_entry_points --- nf_core/subworkflow-template/tests/main.nf | 2 +- nf_core/subworkflows/test_yml_builder.py | 2 +- tests/subworkflows/create_test_yml.py | 16 ++++++++++++++++ tests/test_subworkflows.py | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/nf_core/subworkflow-template/tests/main.nf b/nf_core/subworkflow-template/tests/main.nf index 2bf63da2f3..f8c9b10dcb 100644 --- a/nf_core/subworkflow-template/tests/main.nf +++ b/nf_core/subworkflow-template/tests/main.nf @@ -4,7 +4,7 @@ nextflow.enable.dsl = 2 include { {{ subworkflow_name|upper }} } from '../../../../subworkflows/{{ org }}/{{ subworkflow_dir }}/main.nf' -workflow test_{{ subworkflow_name }} { +workflow test_{{ component_name_underscore }} { {% if has_meta %} input = [ [ id:'test' ], // meta map diff --git a/nf_core/subworkflows/test_yml_builder.py b/nf_core/subworkflows/test_yml_builder.py index 384561bf68..2ad50d4e25 100644 --- a/nf_core/subworkflows/test_yml_builder.py +++ b/nf_core/subworkflows/test_yml_builder.py @@ -139,7 +139,7 @@ def scrape_workflow_entry_points(self): if match: self.entry_points.append(match.group(1)) if len(self.entry_points) == 0: - raise UserWarning("No workflow entry points found in 'self.module_test_main'") + raise UserWarning(f"No workflow entry points found in '{self.subworkflow_test_main}'") def build_all_tests(self): """ diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index 33ad59d655..ac06a45e68 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -57,3 +57,19 @@ def test_subworkflows_create_test_yml_get_md5(self, test_file_dir): results_dir_repeat=test_file_dir, ) assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" + + +def test_subworkflows_create_test_yml_entry_points(self): + """Test extracting test entry points from a main.nf file""" + subworkflow = "test_subworkflow" + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow=f"{subworkflow}/test", + directory=self.pipeline_dir, + test_yml_output_path="./", + no_prompts=True, + ) + meta_builder.subworkflow_test_main = os.path.join( + self.nfcore_modules, "tests", "subworkflows", "nf-core", subworkflow, "main.nf" + ) + meta_builder.scrape_workflow_entry_points() + assert meta_builder.entry_points[0] == f"test_{subworkflow}" diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index f888c982de..663d51a474 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -97,6 +97,7 @@ def tearDown(self): test_subworkflows_custom_yml_dumper, test_subworkflows_test_file_dict, test_subworkflows_create_test_yml_get_md5, + test_subworkflows_create_test_yml_entry_points, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From e7bda6db3da0638e62baa5ab4d845d0bb60dac38 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Tue, 28 Mar 2023 14:16:12 +0200 Subject: [PATCH 19/29] Test check_inputs --- tests/subworkflows/create_test_yml.py | 20 ++++++++++++++++++++ tests/test_subworkflows.py | 1 + 2 files changed, 21 insertions(+) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index ac06a45e68..a2f3bb321d 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -73,3 +73,23 @@ def test_subworkflows_create_test_yml_entry_points(self): ) meta_builder.scrape_workflow_entry_points() assert meta_builder.entry_points[0] == f"test_{subworkflow}" + + +def test_subworkflows_create_test_yml_check_inputs(self): + """Test the check_inputs() function - raise UserWarning because test.yml exists""" + cwd = os.getcwd() + os.chdir(self.nfcore_modules) + subworkflow = "test_subworkflow" + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow=f"{subworkflow}", + directory=self.pipeline_dir, + test_yml_output_path="./", + no_prompts=True, + ) + meta_builder.subworkflow_test_main = os.path.join( + self.nfcore_modules, "tests", "subworkflows", "nf-core", subworkflow, "main.nf" + ) + with pytest.raises(UserWarning) as excinfo: + meta_builder.check_inputs() + os.chdir(cwd) + assert "Test YAML file already exists!" in str(excinfo.value) diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index 663d51a474..aa8be60863 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -98,6 +98,7 @@ def tearDown(self): test_subworkflows_test_file_dict, test_subworkflows_create_test_yml_get_md5, test_subworkflows_create_test_yml_entry_points, + test_subworkflows_create_test_yml_check_inputs, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From 36aab3837db4ec020245923d6239115891b3b742 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Tue, 28 Mar 2023 14:30:39 +0200 Subject: [PATCH 20/29] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4797f020e0..21f41cef7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,10 @@ - Use `nfcore/gitpod:dev` container in the dev branch ([#2196](https://github.com/nf-core/tools/pull/2196)) - Replace requests_mock with responses in test mocks ([#2165](https://github.com/nf-core/tools/pull/2165)). +### Bug fixes, maintenance and tests + +- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) + ## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19] ### Template From a661087f0d1a5e1040071a3b9a9ec4adb1bbf13e Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Tue, 28 Mar 2023 16:16:32 +0200 Subject: [PATCH 21/29] Fix linting --- CHANGELOG.md | 2 +- README.md | 4 ++-- tests/test_subworkflows.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f41cef7e..fc18f9ccee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ ### Bug fixes, maintenance and tests -- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) +- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) ## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19] diff --git a/README.md b/README.md index 63bf235bc7..2fe09e80d2 100644 --- a/README.md +++ b/README.md @@ -612,7 +612,7 @@ The graphical interface is oganzised in groups and within the groups the single Now you can start to change the parameter itself. The `ID` of a new parameter should be defined in small letters without whitespaces. The description is a short free text explanation about the parameter, that appears if you run your pipeline with the `--help` flag. By clicking on the dictionary icon you can add a longer explanation for the parameter page of your pipeline. Usually, they contain a small paragraph about the parameter settings or a used datasource, like databases or references. If you want to specify some conditions for your parameter, like the file extension, you can use the nut icon to open the settings. This menu depends on the `type` you assigned to your parameter. For integers you can define a min and max value, and for strings the file extension can be specified. -The `type` field is one of the most important points in your pipeline schema, since it defines the datatype of your input and how it will be interpreted. This allows extensive testing prior to starting the pipeline. +The `type` field is one of the most important points in your pipeline schema, since it defines the datatype of your input and how it will be interpreted. This allows extensive testing prior to starting the pipeline. The basic datatypes for a pipeline schema are: @@ -621,7 +621,7 @@ The basic datatypes for a pipeline schema are: - `integer` - `boolean` -For the `string` type you have three different options in the settings (nut icon): `enumerated values`, `pattern` and `format`. The first option, `enumerated values`, allows you to specify a list of specific input values. The list has to be separated with a pipe. The `pattern` and `format` settings can depend on each other. The `format` has to be either a directory or a file path. Depending on the `format` setting selected, specifying the `pattern` setting can be the most efficient and time saving option, especially for `file paths`. The `number` and `integer` types share the same settings. Similarly to `string`, there is an `enumerated values` option with the possibility of specifying a `min` and `max` value. For the `boolean` there is no further settings and the default value is usually `false`. The `boolean` value can be switched to `true` by adding the flag to the command. This parameter type is often used to skip specific sections of a pipeline. +For the `string` type you have three different options in the settings (nut icon): `enumerated values`, `pattern` and `format`. The first option, `enumerated values`, allows you to specify a list of specific input values. The list has to be separated with a pipe. The `pattern` and `format` settings can depend on each other. The `format` has to be either a directory or a file path. Depending on the `format` setting selected, specifying the `pattern` setting can be the most efficient and time saving option, especially for `file paths`. The `number` and `integer` types share the same settings. Similarly to `string`, there is an `enumerated values` option with the possibility of specifying a `min` and `max` value. For the `boolean` there is no further settings and the default value is usually `false`. The `boolean` value can be switched to `true` by adding the flag to the command. This parameter type is often used to skip specific sections of a pipeline. After filling the schema, click on the `Finished` button in the top right corner, this will automatically update your `nextflow_schema.json`. If this is not working, the schema can be copied from the graphical interface and pasted in your `nextflow_schema.json` file. diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index aa8be60863..19a090f7f0 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -94,11 +94,11 @@ def tearDown(self): test_subworkflows_create_succeed, ) from .subworkflows.create_test_yml import ( + test_subworkflows_create_test_yml_check_inputs, + test_subworkflows_create_test_yml_entry_points, + test_subworkflows_create_test_yml_get_md5, test_subworkflows_custom_yml_dumper, test_subworkflows_test_file_dict, - test_subworkflows_create_test_yml_get_md5, - test_subworkflows_create_test_yml_entry_points, - test_subworkflows_create_test_yml_check_inputs, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From 41837df4b7ebb45e83bd6dd005405fe7dd36a49a Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Wed, 29 Mar 2023 10:19:59 +0200 Subject: [PATCH 22/29] =?UTF-8?q?Switch=20from=20`os.path`=C2=A0to=20`Path?= =?UTF-8?q?`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matthias Hörtenhuber --- tests/subworkflows/create_test_yml.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index a2f3bb321d..ed5715832f 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -1,6 +1,6 @@ import os from unittest import mock - +from pathlib import Path import pytest import nf_core.subworkflows @@ -11,7 +11,7 @@ @with_temporary_folder def test_subworkflows_custom_yml_dumper(self, out_dir): """Try to create a yml file with the custom yml dumper""" - yml_output_path = os.path.join(out_dir, "test.yml") + yml_output_path = Path(out_dir, "test.yml") meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( subworkflow="test/tool", directory=self.pipeline_dir, @@ -21,7 +21,7 @@ def test_subworkflows_custom_yml_dumper(self, out_dir): meta_builder.test_yml_output_path = yml_output_path meta_builder.tests = [{"testname": "myname"}] meta_builder.print_test_yml() - assert os.path.isfile(yml_output_path) + assert Path(yml_output_path).is_file() @with_temporary_folder @@ -33,7 +33,7 @@ def test_subworkflows_test_file_dict(self, test_file_dir): test_yml_output_path="./", no_prompts=True, ) - with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + with open(Path(test_file_dir, "test_file.txt"), "w") as fh: fh.write("this line is just for testing") test_files = meta_builder.create_test_file_dict(test_file_dir) assert len(test_files) == 1 @@ -68,7 +68,7 @@ def test_subworkflows_create_test_yml_entry_points(self): test_yml_output_path="./", no_prompts=True, ) - meta_builder.subworkflow_test_main = os.path.join( + meta_builder.subworkflow_test_main = Path( self.nfcore_modules, "tests", "subworkflows", "nf-core", subworkflow, "main.nf" ) meta_builder.scrape_workflow_entry_points() @@ -86,7 +86,7 @@ def test_subworkflows_create_test_yml_check_inputs(self): test_yml_output_path="./", no_prompts=True, ) - meta_builder.subworkflow_test_main = os.path.join( + meta_builder.subworkflow_test_main = Path( self.nfcore_modules, "tests", "subworkflows", "nf-core", subworkflow, "main.nf" ) with pytest.raises(UserWarning) as excinfo: From ef4738b26d3d79516cfa6eab823bdd59f076d40a Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Wed, 29 Mar 2023 10:23:06 +0200 Subject: [PATCH 23/29] Switch from `os.path` to `Path` for modules too --- tests/modules/create_test_yml.py | 12 ++++++------ tests/subworkflows/create_test_yml.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/modules/create_test_yml.py b/tests/modules/create_test_yml.py index d444ff841a..950737062b 100644 --- a/tests/modules/create_test_yml.py +++ b/tests/modules/create_test_yml.py @@ -11,19 +11,19 @@ @with_temporary_folder def test_modules_custom_yml_dumper(self, out_dir): """Try to create a yml file with the custom yml dumper""" - yml_output_path = os.path.join(out_dir, "test.yml") + yml_output_path = Path(out_dir, "test.yml") meta_builder = nf_core.modules.ModulesTestYmlBuilder("test/tool", self.pipeline_dir, False, "./", False, True) meta_builder.test_yml_output_path = yml_output_path meta_builder.tests = [{"testname": "myname"}] meta_builder.print_test_yml() - assert os.path.isfile(yml_output_path) + assert Path(yml_output_path).is_file() @with_temporary_folder def test_modules_test_file_dict(self, test_file_dir): """Create dict of test files and create md5 sums""" meta_builder = nf_core.modules.ModulesTestYmlBuilder("test/tool", self.pipeline_dir, False, "./", False, True) - with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + with open(Path(test_file_dir, "test_file.txt"), "w") as fh: fh.write("this line is just for testing") test_files = meta_builder.create_test_file_dict(test_file_dir) assert len(test_files) == 1 @@ -34,7 +34,7 @@ def test_modules_test_file_dict(self, test_file_dir): def test_modules_create_test_yml_get_md5(self, test_file_dir): """Get md5 sums from a dummy output""" meta_builder = nf_core.modules.ModulesTestYmlBuilder("test/tool", self.pipeline_dir, False, "./", False, True) - with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + with open(Path(test_file_dir, "test_file.txt"), "w") as fh: fh.write("this line is just for testing") test_files = meta_builder.get_md5_sums(command="dummy", results_dir=test_file_dir, results_dir_repeat=test_file_dir) assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" @@ -43,7 +43,7 @@ def test_modules_create_test_yml_get_md5(self, test_file_dir): def test_modules_create_test_yml_entry_points(self): """Test extracting test entry points from a main.nf file""" meta_builder = nf_core.modules.ModulesTestYmlBuilder("bpipe/test", self.pipeline_dir, False, "./", False, True) - meta_builder.module_test_main = os.path.join( + meta_builder.module_test_main = Path( self.nfcore_modules, "tests", "modules", "nf-core", "bpipe", "test", "main.nf" ) meta_builder.scrape_workflow_entry_points() @@ -55,7 +55,7 @@ def test_modules_create_test_yml_check_inputs(self): cwd = os.getcwd() os.chdir(self.nfcore_modules) meta_builder = nf_core.modules.ModulesTestYmlBuilder("bpipe/test", ".", False, "./", False, True) - meta_builder.module_test_main = os.path.join(self.nfcore_modules, "tests", "modules", "bpipe", "test", "main.nf") + meta_builder.module_test_main = Path(self.nfcore_modules, "tests", "modules", "bpipe", "test", "main.nf") with pytest.raises(UserWarning) as excinfo: meta_builder.check_inputs() os.chdir(cwd) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index ed5715832f..a195f74d60 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -49,7 +49,7 @@ def test_subworkflows_create_test_yml_get_md5(self, test_file_dir): test_yml_output_path="./", no_prompts=True, ) - with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + with open(Path(test_file_dir, "test_file.txt"), "w") as fh: fh.write("this line is just for testing") test_files = meta_builder.get_md5_sums( command="dummy", From 8d81588af485759eda1549e62fc55b1e43090027 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Wed, 29 Mar 2023 10:37:06 +0200 Subject: [PATCH 24/29] Lint code (isort, black) --- tests/modules/create_test_yml.py | 4 +--- tests/subworkflows/create_test_yml.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/modules/create_test_yml.py b/tests/modules/create_test_yml.py index 950737062b..243378af78 100644 --- a/tests/modules/create_test_yml.py +++ b/tests/modules/create_test_yml.py @@ -43,9 +43,7 @@ def test_modules_create_test_yml_get_md5(self, test_file_dir): def test_modules_create_test_yml_entry_points(self): """Test extracting test entry points from a main.nf file""" meta_builder = nf_core.modules.ModulesTestYmlBuilder("bpipe/test", self.pipeline_dir, False, "./", False, True) - meta_builder.module_test_main = Path( - self.nfcore_modules, "tests", "modules", "nf-core", "bpipe", "test", "main.nf" - ) + meta_builder.module_test_main = Path(self.nfcore_modules, "tests", "modules", "nf-core", "bpipe", "test", "main.nf") meta_builder.scrape_workflow_entry_points() assert meta_builder.entry_points[0] == "test_bpipe_test" diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index a195f74d60..40384b420f 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -1,6 +1,7 @@ import os -from unittest import mock from pathlib import Path +from unittest import mock + import pytest import nf_core.subworkflows From 20f82c08d7f7a529f33cd0af36da3e4dd7621393 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Wed, 29 Mar 2023 12:04:10 +0200 Subject: [PATCH 25/29] Fix changelog [skip ci] --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc18f9ccee..bb12675044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Fixing problem when a module included in a subworkflow had a name change from TOOL to TOOL/SUBTOOL ([#2177](https://github.com/nf-core/tools/pull/2177)) - Fix `nf-core subworkflows test` not running subworkflow tests ([#2181](https://github.com/nf-core/tools/pull/2181)) +- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) ### General @@ -29,10 +30,6 @@ - Use `nfcore/gitpod:dev` container in the dev branch ([#2196](https://github.com/nf-core/tools/pull/2196)) - Replace requests_mock with responses in test mocks ([#2165](https://github.com/nf-core/tools/pull/2165)). -### Bug fixes, maintenance and tests - -- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) - ## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19] ### Template From 790a9b86de92de4703bc65a33ce9ee9f97b53b2f Mon Sep 17 00:00:00 2001 From: ash Date: Wed, 29 Mar 2023 10:47:34 +0100 Subject: [PATCH 26/29] Don't require an argument for `nf-core schema lint` --- README.md | 4 ++-- nf_core/__main__.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2fe09e80d2..8235bf4386 100644 --- a/README.md +++ b/README.md @@ -634,13 +634,13 @@ It's important to change the default value of a parameter in the `nextflow.confi The pipeline schema is linted as part of the main pipeline `nf-core lint` command, however sometimes it can be useful to quickly check the syntax of the JSONSchema without running a full lint run. -Usage is `nf-core schema lint `, eg: +Usage is `nf-core schema lint ` (defaulting to `nextflow_schema.json`), eg: -![`nf-core schema lint nextflow_schema.json`](docs/images/nf-core-schema-lint.svg) +![`nf-core schema lint`](docs/images/nf-core-schema-lint.svg) ## Bumping a pipeline version number diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 2cf3805902..a801df4266 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -1398,7 +1398,7 @@ def build(dir, no_prompts, web_only, url): # nf-core schema lint @schema.command() -@click.argument("schema_path", type=click.Path(exists=True), required=True, metavar="") +@click.argument("schema_path", type=click.Path(exists=True), default="nextflow_schema.json", metavar="") def lint(schema_path): """ Check that a given pipeline schema is valid. @@ -1408,6 +1408,8 @@ def lint(schema_path): This function runs as part of the nf-core lint command, this is a convenience command that does just the schema linting nice and quickly. + + If no schema path is provided, "nextflow_schema.json" will be used (if it exists). """ schema_obj = nf_core.schema.PipelineSchema() try: From d53259ea6257adb731e14821f08682d5dfd9967d Mon Sep 17 00:00:00 2001 From: ash Date: Wed, 29 Mar 2023 12:26:00 +0100 Subject: [PATCH 27/29] Add basic tests for `nf-core schema lint` --- tests/test_cli.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 2bd8af5c59..58c4525a76 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -350,3 +350,20 @@ def test_lint_log_user_warning(self, mock_lint, mock_is_pipeline): assert result.exit_code == 1 assert error_txt in captured_logs.output[-1] assert captured_logs.records[-1].levelname == "ERROR" + + @mock.patch("nf_core.schema.PipelineSchema.get_schema_path") + def test_schema_lint(self, mock_get_schema_path): + """Test nf-core schema lint defaults to nextflow_schema.json""" + cmd = ["schema", "lint"] + result = self.invoke_cli(cmd) + assert mock_get_schema_path.called_with("nextflow_schema.json") + assert "nextflow_schema.json" in result.output + + @mock.patch("nf_core.schema.PipelineSchema.get_schema_path") + def test_schema_lint_filename(self, mock_get_schema_path): + """Test nf-core schema lint accepts a filename""" + cmd = ["schema", "lint", "some_other_filename"] + result = self.invoke_cli(cmd) + assert mock_get_schema_path.called_with("some_other_filename") + assert "some_other_filename" in result.output + assert "nextflow_schema.json" not in result.output From b4e22d363bcd9ddbcc62fd495e6c5a94c2bad0eb Mon Sep 17 00:00:00 2001 From: ash Date: Wed, 29 Mar 2023 14:52:43 +0100 Subject: [PATCH 28/29] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index df9a14d03d..40d62f1345 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Linting - Read module lint configuration from `.nf-core.yml`, not `.nf-core-lint.yml` ([#2221](https://github.com/nf-core/tools/pull/2221)) +- `nf-core schema lint` now defaults to linting `nextflow_schema.json` if no filename is provided ([#2225](https://github.com/nf-core/tools/pull/2225)) ### Modules From ff84a09385287a00ee6881e9685de33a47f3241a Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Wed, 29 Mar 2023 17:48:32 -0400 Subject: [PATCH 29/29] fix linting with black --- nf_core/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nf_core/__main__.py b/nf_core/__main__.py index a801df4266..15bacde92f 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -1398,7 +1398,9 @@ def build(dir, no_prompts, web_only, url): # nf-core schema lint @schema.command() -@click.argument("schema_path", type=click.Path(exists=True), default="nextflow_schema.json", metavar="") +@click.argument( + "schema_path", type=click.Path(exists=True), default="nextflow_schema.json", metavar="" +) def lint(schema_path): """ Check that a given pipeline schema is valid.