Skip to content
18 changes: 12 additions & 6 deletions nf_core/components/nfcore_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,10 @@ def _extract_value(self, text: str, start_pos: int = 0, split_on_comma: bool = F
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]'
with open(self.main_nf) as f:
data = f.read()
data = ""
if self.main_nf.is_file():
with open(self.main_nf) as f:
data = f.read()
if self.component_type == "modules":
# get input values from main.nf after "input:", which can be formatted as tuple val(foo) path(bar) or val foo or val bar or path bar or path foo
# regex matches:
Expand Down Expand Up @@ -323,8 +325,10 @@ def get_inputs_from_main_nf(self) -> None:
self.inputs = inputs

def get_outputs_from_main_nf(self):
with open(self.main_nf) as f:
data = f.read()
data = ""
if self.main_nf.is_file():
with open(self.main_nf) as f:
data = f.read()
if self.component_type == "modules":
outputs = {}
# get output values from main.nf after "output:". the names are always after "emit:"
Expand Down Expand Up @@ -366,8 +370,10 @@ def get_outputs_from_main_nf(self):
self.outputs = outputs

def get_topics_from_main_nf(self) -> None:
with open(self.main_nf) as f:
data = f.read()
data = ""
if self.main_nf.is_file():
with open(self.main_nf) as f:
data = f.read()
if self.component_type == "modules":
topics: dict[str, list[dict[str, dict] | list[dict[str, dict[str, str]]]]] = {}
# get topic name from main.nf after "output:". the names are always after "topic:"
Expand Down
6 changes: 5 additions & 1 deletion nf_core/modules/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ def update_meta_yml_file(self, mod):
"""
Update the meta.yml file with the correct inputs, outputs, topics and containers
"""
meta_yml = self.read_meta_yml_patched(mod)
try:
meta_yml = self.read_meta_yml_patched(mod)
except LookupError:
log.warning(f"Could not reverse-apply patch to read meta.yml for {mod.component_name}, skipping update")
return
if meta_yml is None:
log.warning(f"Could not read meta.yml for {mod.component_name}, skipping update")
return
Expand Down
10 changes: 9 additions & 1 deletion nf_core/modules/lint/environment_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,15 @@ def lint_environment_yml(
# Parse the YAML content
env_yml = yaml.load(content)
if env_yml is None:
raise ruamel.yaml.scanner.ScannerError("Empty YAML file")
module.failed.append(
(
"environment_yml",
"environment_yml_exists",
"Module's `environment.yml` is empty",
module.environment_yml,
)
)
return

module.passed.append(
(
Expand Down
Loading
Loading