Skip to content

Commit

Permalink
update nextflow_config linting to include the new includeconfig line
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Sep 25, 2024
1 parent 930933b commit e6fdba8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions nf_core/pipelines/lint/nextflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,26 +346,40 @@ def nextflow_config(self) -> Dict[str, List[str]]:
failed.append(f"Config `params.custom_config_base` is not set to `{custom_config_base}`")

# Check that lines for loading custom profiles exist
lines = [
old_lines = [
r"// Load nf-core custom profiles from different Institutions",
r"try {",
r'includeConfig "${params.custom_config_base}/nfcore_custom.config"',
r"} catch (Exception e) {",
r'System.err.println("WARNING: Could not load nf-core/config profiles: ${params.custom_config_base}/nfcore_custom.config")',
r"}",
]
lines = [
r"// Load nf-core custom profiles from different Institutions",
r'''includeConfig !System.getenv('NXF_OFFLINE') && params.custom_config_base ? "${params.custom_config_base}/nfcore_custom.config" : "/dev/null"''',
]
path = Path(self.wf_path, "nextflow.config")
i = 0
with open(path) as f:
for line in f:
if lines[i] in line:
if old_lines[i] in line:
i += 1
if i == len(old_lines):
break
elif lines[i] in line:
i += 1
if i == len(lines):
break
else:
i = 0
if i == len(lines):
passed.append("Lines for loading custom profiles found")
elif i == len(old_lines):
failed.append(
"Old lines for loading custom profiles found. File should contain: ```groovy\n{}".format(
"\n".join(lines)
)
)
else:
lines[2] = f"\t{lines[2]}"
lines[4] = f"\t{lines[4]}"
Expand Down

0 comments on commit e6fdba8

Please sign in to comment.