From 13bbac6570af595697aaec638a82d7e7fd4fa3ac Mon Sep 17 00:00:00 2001 From: mashehu Date: Tue, 28 Nov 2023 16:32:57 +0100 Subject: [PATCH 1/2] fix subworkflow command --- nf_core/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 232f1bf116..81e7de0f16 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -1064,7 +1064,6 @@ def create_subworkflow(ctx, subworkflow, dir, author, force): @click.pass_context @click.argument("subworkflow", type=str, required=False, metavar="subworkflow name") @click.option("-d", "--dir", type=click.Path(exists=True), default=".", metavar="") -@click.option("-t", "--run-tests", is_flag=True, default=False, help="Run the test workflows") @click.option("-p", "--no-prompts", is_flag=True, default=False, help="Use defaults without prompting") @click.option("-u", "--update", is_flag=True, default=False, help="Update existing snapshots") @click.option("-o", "--once", is_flag=True, default=False, help="Run tests only once. Don't check snapshot stability") From ad03acdd8007e482f7f6d1df2dd9b3b9394ab103 Mon Sep 17 00:00:00 2001 From: mashehu Date: Tue, 28 Nov 2023 22:00:46 +0100 Subject: [PATCH 2/2] fix parsing for include statement of nested subworkflows, print long messages --- nf_core/components/lint/__init__.py | 17 ++++++++++++----- nf_core/components/nfcore_component.py | 13 ++++++++++--- nf_core/subworkflows/lint/subworkflow_tests.py | 1 + 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/nf_core/components/lint/__init__.py b/nf_core/components/lint/__init__.py index c46d68ff22..efffc28e85 100644 --- a/nf_core/components/lint/__init__.py +++ b/nf_core/components/lint/__init__.py @@ -10,7 +10,9 @@ import os from pathlib import Path -import rich +import rich.box +import rich.console +import rich.panel from rich.markdown import Markdown from rich.table import Table @@ -209,7 +211,7 @@ def _print_results(self, show_passed=False, sort_by="test"): self.failed.sort(key=operator.attrgetter(*sort_order)) # Find maximum module name length - max_name_len = 40 + max_name_len = len(self.component_type[:-1] + " name") for tests in [self.passed, self.warned, self.failed]: try: for lint_result in tests: @@ -264,7 +266,7 @@ def format_result(test_results, table): table = Table(style="yellow", box=rich.box.MINIMAL, pad_edge=False, border_style="dim") table.add_column(f"{self.component_type[:-1].title()} name", width=max_name_len) table.add_column("File path") - table.add_column("Test message") + table.add_column("Test message", overflow="fold") table = format_result(self.warned, table) console.print( rich.panel.Panel( @@ -278,10 +280,15 @@ def format_result(test_results, table): # Table of failing tests if len(self.failed) > 0: - table = Table(style="red", box=rich.box.MINIMAL, pad_edge=False, border_style="dim") + table = Table( + style="red", + box=rich.box.MINIMAL, + pad_edge=False, + border_style="dim", + ) table.add_column(f"{self.component_type[:-1].title()} name", width=max_name_len) table.add_column("File path") - table.add_column("Test message") + table.add_column("Test message", overflow="fold") table = format_result(self.failed, table) console.print( rich.panel.Panel( diff --git a/nf_core/components/nfcore_component.py b/nf_core/components/nfcore_component.py index 190310faae..8d9b6840b0 100644 --- a/nf_core/components/nfcore_component.py +++ b/nf_core/components/nfcore_component.py @@ -4,6 +4,7 @@ import logging import re from pathlib import Path +from typing import Union log = logging.getLogger(__name__) @@ -77,7 +78,7 @@ def __init__( self.test_yml = None self.test_main_nf = None - def _get_main_nf_tags(self, test_main_nf: str): + def _get_main_nf_tags(self, test_main_nf: Union[Path, str]): """Collect all tags from the main.nf.test file.""" tags = [] with open(test_main_nf, "r") as fh: @@ -86,13 +87,19 @@ def _get_main_nf_tags(self, test_main_nf: str): tags.append(line.strip().split()[1].strip('"')) return tags - def _get_included_components(self, main_nf: str): + def _get_included_components(self, main_nf: Union[Path, str]): """Collect all included components from the main.nf file.""" included_components = [] with open(main_nf, "r") as fh: for line in fh: if line.strip().startswith("include"): - included_components.append(line.strip().split()[-1].split(self.org)[-1].split("main")[0].strip("/")) + # get tool/subtool or subworkflow name from include statement, can be in the form + #'../../../modules/nf-core/hisat2/align/main' + #'../bam_sort_stats_samtools/main' + #'../subworkflows/nf-core/bam_sort_stats_samtools/main' + component = line.strip().split()[-1].split(self.org)[-1].split("main")[0].strip("/") + component = component.replace("'../", "subworkflows/") + included_components.append(component) return included_components def get_inputs_from_main_nf(self): diff --git a/nf_core/subworkflows/lint/subworkflow_tests.py b/nf_core/subworkflows/lint/subworkflow_tests.py index e82d00f636..30439a8d0b 100644 --- a/nf_core/subworkflows/lint/subworkflow_tests.py +++ b/nf_core/subworkflows/lint/subworkflow_tests.py @@ -107,6 +107,7 @@ def subworkflow_tests(_, subworkflow: NFCoreComponent): included_components = [] if subworkflow.main_nf.is_file(): included_components = subworkflow._get_included_components(subworkflow.main_nf) + log.debug(f"Required tags: {required_tags}") missing_tags = [] for tag in required_tags + included_components: if tag not in main_nf_tags: