From efd397d94ee223f8dd60f1c3a88a04211bc4b27e Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Mon, 27 May 2024 14:39:17 +0200 Subject: [PATCH 1/4] add org to main.nf.test tag --- nf_core/components/create.py | 4 ++++ nf_core/module-template/tests/main.nf.test.j2 | 2 +- nf_core/subworkflow-template/tests/main.nf.test.j2 | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nf_core/components/create.py b/nf_core/components/create.py index 6c9c01b496..e603db3857 100644 --- a/nf_core/components/create.py +++ b/nf_core/components/create.py @@ -157,6 +157,10 @@ def create(self): if self.component_type == "modules": self._get_module_structure_components() + # Add a valid organization name for nf-test tags + not_alphabet = re.compile(r'[^a-zA-Z]') + self.org_alphabet = not_alphabet.sub('', self.org) + # Create component template with jinja2 self._render_template() log.info(f"Created component template: '{self.component_name}'") diff --git a/nf_core/module-template/tests/main.nf.test.j2 b/nf_core/module-template/tests/main.nf.test.j2 index 1f70df64b0..456c989f85 100644 --- a/nf_core/module-template/tests/main.nf.test.j2 +++ b/nf_core/module-template/tests/main.nf.test.j2 @@ -7,7 +7,7 @@ nextflow_process { process "{{ component_name_underscore|upper }}" tag "modules" - tag "modules_nfcore" + tag "modules_{{ org_alphabet }}" {%- if subtool %} tag "{{ component }}" {%- endif %} diff --git a/nf_core/subworkflow-template/tests/main.nf.test.j2 b/nf_core/subworkflow-template/tests/main.nf.test.j2 index c44e19a4e4..8aaf6e0c7c 100644 --- a/nf_core/subworkflow-template/tests/main.nf.test.j2 +++ b/nf_core/subworkflow-template/tests/main.nf.test.j2 @@ -7,7 +7,7 @@ nextflow_workflow { workflow "{{ component_name_underscore|upper }}" tag "subworkflows" - tag "subworkflows_nfcore" + tag "subworkflows_{{ org_alphabet }}" tag "subworkflows/{{ component_name }}" // TODO nf-core: Add tags for all modules used within this subworkflow. Example: tag "samtools" From a446f29d01470e05870552d6bb496236460d46b6 Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Mon, 27 May 2024 15:19:50 +0200 Subject: [PATCH 2/4] make sure linting passes this new feature --- nf_core/modules/lint/module_tests.py | 6 +++++- nf_core/subworkflows/lint/subworkflow_tests.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nf_core/modules/lint/module_tests.py b/nf_core/modules/lint/module_tests.py index b2b6c2221f..080fc2bdc8 100644 --- a/nf_core/modules/lint/module_tests.py +++ b/nf_core/modules/lint/module_tests.py @@ -4,6 +4,7 @@ import json import logging +import re from pathlib import Path import yaml @@ -137,7 +138,10 @@ def module_tests(_, module: NFCoreComponent): ) # Verify that tags are correct. main_nf_tags = module._get_main_nf_tags(module.nftest_main_nf) - required_tags = ["modules", "modules_nfcore", module.component_name] + not_alphabet = re.compile(r'[^a-zA-Z]') + org_alp = not_alphabet.sub('', module.org) + org_alphabet = org_alp if org_alp != "" else "nfcore" + required_tags = ["modules", f"modules_{org_alphabet}", module.component_name] if module.component_name.count("/") == 1: required_tags.append(module.component_name.split("/")[0]) chained_components_tags = module._get_included_components_in_chained_tests(module.nftest_main_nf) diff --git a/nf_core/subworkflows/lint/subworkflow_tests.py b/nf_core/subworkflows/lint/subworkflow_tests.py index cfae2d553c..87e850e8fb 100644 --- a/nf_core/subworkflows/lint/subworkflow_tests.py +++ b/nf_core/subworkflows/lint/subworkflow_tests.py @@ -4,6 +4,7 @@ import json import logging +import re from pathlib import Path import yaml @@ -144,10 +145,13 @@ def subworkflow_tests(_, subworkflow: NFCoreComponent): ) # Verify that tags are correct. main_nf_tags = subworkflow._get_main_nf_tags(subworkflow.nftest_main_nf) + not_alphabet = re.compile(r'[^a-zA-Z]') + org_alp = not_alphabet.sub('', subworkflow.org) + org_alphabet = org_alp if org_alp != "" else "nfcore" required_tags = [ "subworkflows", f"subworkflows/{subworkflow.component_name}", - "subworkflows_nfcore", + f"subworkflows_{org_alphabet}", ] included_components = [] if subworkflow.main_nf.is_file(): From 7bae122e1da8fb54511ebdfe02894a602621dbce Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Mon, 27 May 2024 15:27:20 +0200 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16262bd1c3..259982e39f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ ### Components +- The `modules_nfcore` tag in the `main.nf.test` file of modules/subworkflows now displays the organization name in custom modules repositories ([#3005](https://github.com/nf-core/tools/pull/3005)) + ### General - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.4 ([#2974](https://github.com/nf-core/tools/pull/2974)) From a4ecb70909da3b6986c25d8986ba956391bcd0fc Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Mon, 27 May 2024 15:32:45 +0200 Subject: [PATCH 4/4] ruff! --- nf_core/components/create.py | 4 ++-- nf_core/modules/lint/module_tests.py | 4 ++-- nf_core/subworkflows/lint/subworkflow_tests.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nf_core/components/create.py b/nf_core/components/create.py index e603db3857..78c30b5179 100644 --- a/nf_core/components/create.py +++ b/nf_core/components/create.py @@ -158,8 +158,8 @@ def create(self): self._get_module_structure_components() # Add a valid organization name for nf-test tags - not_alphabet = re.compile(r'[^a-zA-Z]') - self.org_alphabet = not_alphabet.sub('', self.org) + not_alphabet = re.compile(r"[^a-zA-Z]") + self.org_alphabet = not_alphabet.sub("", self.org) # Create component template with jinja2 self._render_template() diff --git a/nf_core/modules/lint/module_tests.py b/nf_core/modules/lint/module_tests.py index 080fc2bdc8..4bf4ea7745 100644 --- a/nf_core/modules/lint/module_tests.py +++ b/nf_core/modules/lint/module_tests.py @@ -138,8 +138,8 @@ def module_tests(_, module: NFCoreComponent): ) # Verify that tags are correct. main_nf_tags = module._get_main_nf_tags(module.nftest_main_nf) - not_alphabet = re.compile(r'[^a-zA-Z]') - org_alp = not_alphabet.sub('', module.org) + not_alphabet = re.compile(r"[^a-zA-Z]") + org_alp = not_alphabet.sub("", module.org) org_alphabet = org_alp if org_alp != "" else "nfcore" required_tags = ["modules", f"modules_{org_alphabet}", module.component_name] if module.component_name.count("/") == 1: diff --git a/nf_core/subworkflows/lint/subworkflow_tests.py b/nf_core/subworkflows/lint/subworkflow_tests.py index 87e850e8fb..fe7b40407a 100644 --- a/nf_core/subworkflows/lint/subworkflow_tests.py +++ b/nf_core/subworkflows/lint/subworkflow_tests.py @@ -145,8 +145,8 @@ def subworkflow_tests(_, subworkflow: NFCoreComponent): ) # Verify that tags are correct. main_nf_tags = subworkflow._get_main_nf_tags(subworkflow.nftest_main_nf) - not_alphabet = re.compile(r'[^a-zA-Z]') - org_alp = not_alphabet.sub('', subworkflow.org) + not_alphabet = re.compile(r"[^a-zA-Z]") + org_alp = not_alphabet.sub("", subworkflow.org) org_alphabet = org_alp if org_alp != "" else "nfcore" required_tags = [ "subworkflows",