Skip to content

Commit

Permalink
fix: linting error in meta_yml where module.process_name is always ""
Browse files Browse the repository at this point in the history
  • Loading branch information
lmReef authored and lmReef committed Dec 3, 2024
1 parent a7351a2 commit dc9c3b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion nf_core/components/nfcore_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("/")
Expand Down Expand Up @@ -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"<NFCoreComponent {self.component_name} {self.component_dir} {self.repo_url}>"

Expand Down Expand Up @@ -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]'
Expand Down Expand Up @@ -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

1 change: 0 additions & 1 deletion nf_core/modules/lint/main_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dc9c3b1

Please sign in to comment.