From dc9c3b1763d3f41ae42a4c97a405ba9bfad61878 Mon Sep 17 00:00:00 2001 From: lmReef Date: Wed, 4 Dec 2024 09:43:11 +1300 Subject: [PATCH 1/5] fix: linting error in meta_yml where module.process_name is always "" --- nf_core/components/nfcore_component.py | 12 +++++++++++- nf_core/modules/lint/main_nf.py | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/nf_core/components/nfcore_component.py b/nf_core/components/nfcore_component.py index 37e43a536..090f55a4b 100644 --- a/nf_core/components/nfcore_component.py +++ b/nf_core/components/nfcore_component.py @@ -62,7 +62,6 @@ def __init__( # Initialize the important files self.main_nf: Path = Path(self.component_dir, "main.nf") self.meta_yml: Optional[Path] = Path(self.component_dir, "meta.yml") - self.process_name = "" self.environment_yml: Optional[Path] = Path(self.component_dir, "environment.yml") component_list = self.component_name.split("/") @@ -96,6 +95,9 @@ def __init__( self.test_yml = None self.test_main_nf = None + # Set process_name after self.main_nf is defined + self.process_name = self._get_process_name() + def __repr__(self) -> str: return f"" @@ -169,6 +171,13 @@ def _get_included_components_in_chained_tests(self, main_nf_test: Union[Path, st included_components.append(component) return included_components + def _get_process_name(self): + with open(self.main_nf) as fh: + for line in fh: + if re.search(r"^\s*process\s*\w*\s*{", line): + return re.search(r"^\s*process\s*(\w*)\s*{.*", line).group(1) or "" + return "" + def get_inputs_from_main_nf(self) -> None: """Collect all inputs from the main.nf file.""" inputs: Any = [] # Can be 'list[list[dict[str, dict[str, str]]]]' or 'list[str]' @@ -263,3 +272,4 @@ def get_outputs_from_main_nf(self): pass log.debug(f"Found {len(outputs)} outputs in {self.main_nf}") self.outputs = outputs + diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index 848e17130..9a1790aeb 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -256,7 +256,6 @@ def check_process_section(self, lines, registry, fix_version, progress_bar): bioconda_packages = [] # Process name should be all capital letters - self.process_name = lines[0].split()[1] if all(x.upper() for x in self.process_name): self.passed.append(("process_capitals", "Process name is in capital letters", self.main_nf)) else: From b04351db539fc3962b816595ee7ab9eae3a83bd3 Mon Sep 17 00:00:00 2001 From: lmReef Date: Wed, 4 Dec 2024 09:54:53 +1300 Subject: [PATCH 2/5] fix: python linting warn --- nf_core/components/nfcore_component.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nf_core/components/nfcore_component.py b/nf_core/components/nfcore_component.py index 090f55a4b..eda95be99 100644 --- a/nf_core/components/nfcore_component.py +++ b/nf_core/components/nfcore_component.py @@ -272,4 +272,3 @@ def get_outputs_from_main_nf(self): pass log.debug(f"Found {len(outputs)} outputs in {self.main_nf}") self.outputs = outputs - From d3d9c72d7a20b617e417a8e0ba22ad9b29944d07 Mon Sep 17 00:00:00 2001 From: lmReef Date: Wed, 4 Dec 2024 10:29:10 +1300 Subject: [PATCH 3/5] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da5f72c35..29e405903 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ ### Linting - allow mixed `str` and `dict` entries in lint config ([#3228](https://github.com/nf-core/tools/pull/3228)) +- fix meta_yml linting test failing due to module.process_name always being "" (#3317) ### Modules From 4a8e97631b6164b92f039de74e462cd9b9dd94ee Mon Sep 17 00:00:00 2001 From: lmReef Date: Wed, 4 Dec 2024 10:41:19 +1300 Subject: [PATCH 4/5] update changelog entry with link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e405903..7799ef1d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ ### Linting - allow mixed `str` and `dict` entries in lint config ([#3228](https://github.com/nf-core/tools/pull/3228)) -- fix meta_yml linting test failing due to module.process_name always being "" (#3317) +- fix meta_yml linting test failing due to module.process_name always being "" ([#3317](https://github.com/nf-core/tools/pull/3317)) ### Modules From c3fd9bb084c86e1204e9d4cbeebef413444b1834 Mon Sep 17 00:00:00 2001 From: lmReef Date: Thu, 5 Dec 2024 08:59:07 +1300 Subject: [PATCH 5/5] fix: add explicit str type to self.process_name --- nf_core/components/nfcore_component.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nf_core/components/nfcore_component.py b/nf_core/components/nfcore_component.py index eda95be99..81c0ba98e 100644 --- a/nf_core/components/nfcore_component.py +++ b/nf_core/components/nfcore_component.py @@ -95,8 +95,7 @@ def __init__( self.test_yml = None self.test_main_nf = None - # Set process_name after self.main_nf is defined - self.process_name = self._get_process_name() + self.process_name: str = self._get_process_name() def __repr__(self) -> str: return f""