Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Add Bluesky badge to readme ([#3475](https://github.com/nf-core/tools/pull/3475))
- Run awsfulltest after release, and with dev revision on PRs to master ([#3485](https://github.com/nf-core/tools/pull/3485))
- Add .nftignore to trigger list ([#3508](https://github.com/nf-core/tools/pull/3508))
- Include the centralized nf-core configs also in offline mode, if a local copy is available. ([#3491](https://github.com/nf-core/tools/pull/3491))

### Linting

Expand All @@ -18,6 +19,7 @@
- Fix: linting with comments after the input directive ([#3458](https://github.com/nf-core/tools/pull/3458))
- EDAM ontology fixes ([#3460](https://github.com/nf-core/tools/pull/3460))
- Fix default linting of nf-core components when `nf-core pipelines lint` is ran ([#3480](https://github.com/nf-core/tools/pull/3480))
- Adapt the linter to the new notation used to include the centralized nf-core configs ([#3491](https://github.com/nf-core/tools/pull/3491))

### Modules

Expand Down
10 changes: 7 additions & 3 deletions nf_core/pipeline-template/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,16 @@ profiles {
}

{% if nf_core_configs -%}
// Load nf-core custom profiles from different Institutions
includeConfig !System.getenv('NXF_OFFLINE') && params.custom_config_base ? "${params.custom_config_base}/nfcore_custom.config" : "/dev/null"
// Load nf-core custom profiles from different institutions

// If params.custom_config_base is set AND either the NXF_OFFLINE environment variable is not set or params.custom_config_base is a local path, the nfcore_custom.config file from the specified base path is included.
// Load {{ name }} custom profiles from different institutions.
includeConfig params.custom_config_base && (!System.getenv('NXF_OFFLINE') || !params.custom_config_base.startsWith('http')) ? "${params.custom_config_base}/nfcore_custom.config" : "/dev/null"


// Load {{ name }} custom profiles from different institutions.
// TODO nf-core: Optionally, you can add a pipeline-specific nf-core config at https://github.com/nf-core/configs
// includeConfig !System.getenv('NXF_OFFLINE') && params.custom_config_base ? "${params.custom_config_base}/pipeline/{{ short_name }}.config" : "/dev/null"
// includeConfig params.custom_config_base && (!System.getenv('NXF_OFFLINE') || !params.custom_config_base.startsWith('http')) ? "${params.custom_config_base}/pipeline/{{ short_name }}.config" : "/dev/null"
{%- endif %}

// Set default registry for Apptainer, Docker, Podman, Charliecloud and Singularity independent of -profile
Expand Down
4 changes: 2 additions & 2 deletions nf_core/pipelines/lint/included_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def included_configs(self):
with open(config_file) as fh:
config = fh.read()
if (
f"// includeConfig !System.getenv('NXF_OFFLINE') && params.custom_config_base ? \"${{params.custom_config_base}}/pipeline/{self.pipeline_name}.config\""
f"// includeConfig params.custom_config_base && (!System.getenv('NXF_OFFLINE') || !params.custom_config_base.startsWith('http')) ? \"${{params.custom_config_base}}/pipeline/{self.pipeline_name}.config\""
in config
):
failed.append("Pipeline config does not include custom configs. Please uncomment the includeConfig line.")
elif (
f"includeConfig !System.getenv('NXF_OFFLINE') && params.custom_config_base ? \"${{params.custom_config_base}}/pipeline/{self.pipeline_name}.config\""
f"includeConfig params.custom_config_base && (!System.getenv('NXF_OFFLINE') || !params.custom_config_base.startsWith('http')) ? \"${{params.custom_config_base}}/pipeline/{self.pipeline_name}.config\""
in config
):
passed.append("Pipeline config includes custom configs.")
Expand Down
69 changes: 31 additions & 38 deletions nf_core/pipelines/lint/nextflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,48 +346,41 @@ 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
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"''',
]
old_institutional_config_pattern_1 = r"""try\s*{
\s*includeConfig \"\${params\.custom_config_base}/nfcore_custom\.config\"
\s*}\s*catch\s*\(Exception\s+e\)\s*{
\s*System\.err\.println\(\"WARNING: Could not load nf-core/config profiles: \${params\.custom_config_base}/nfcore_custom\.config\"\)
\s*}"""

old_institutional_config_pattern_2 = r"""includeConfig !System\.getenv\('NXF_OFFLINE'\) && params\.custom_config_base \? \"\${params\.custom_config_base}/nfcore_custom\.config\" : \"/dev/null\""""

current_institutional_config_pattern = r"""includeConfig params\.custom_config_base && \(!System\.getenv\('NXF_OFFLINE'\) \|\| !params\.custom_config_base\.startsWith\('http'\)\) \? \"\${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 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)
content = f.read()

current_institutional_config_lines = [
"// Load nf-core custom profiles from different institutions",
"""includeConfig params.custom_config_base && (!System.getenv('NXF_OFFLINE') || !params.custom_config_base.startsWith('http')) ? \"${params.custom_config_base}/nfcore_custom.config" : "/dev/null\"""",
]

if re.search(current_institutional_config_pattern, content, re.MULTILINE):
passed.append("Lines for loading custom profiles found")
elif re.search(old_institutional_config_pattern_1, content, re.MULTILINE) or re.search(
old_institutional_config_pattern_2, content, re.MULTILINE
):
failed.append(
"Outdated lines for loading custom profiles found. File should contain:\n```groovy\n{}\n```".format(
"\n".join(current_institutional_config_lines)
)
)
)
else:
lines[2] = f"\t{lines[2]}"
lines[4] = f"\t{lines[4]}"
failed.append(
"Lines for loading custom profiles not found. File should contain: ```groovy\n{}".format(
"\n".join(lines)
else:
failed.append(
"Lines for loading custom profiles not found. File should contain:\n```groovy\n{}\n```".format(
"\n".join(current_institutional_config_lines)
)
)
)

# Check for the availability of the "test" configuration profile by parsing nextflow.config
with open(Path(self.wf_path, "nextflow.config")) as f:
Expand Down
Loading