Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template: remove try-catch blocks from nextflow.config #3167

Merged
merged 15 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- Add tests to ensure all files are part of a template customisation group and all groups are tested ([#3099](https://github.com/nf-core/tools/pull/3099))
- Replaces the old custom `check_max()` function with the Nextflow native `resourceLimits` directive ([#3037](https://github.com/nf-core/tools/pull/3037))
- Fixed release announcement hashtags for Mastodon ([#3099](https://github.com/nf-core/tools/pull/3176))
- Remove try/catch blocks from `nextflow.config` ([#3167](https://github.com/nf-core/tools/pull/3167))

### Linting

Expand Down
13 changes: 3 additions & 10 deletions nf_core/pipeline-template/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,11 @@ profiles {

{% if nf_core_configs -%}
// Load nf-core custom profiles from different Institutions
try {
includeConfig "${params.custom_config_base}/nfcore_custom.config"
} catch (Exception e) {
System.err.println("WARNING: Could not load nf-core/config profiles: ${params.custom_config_base}/nfcore_custom.config")
}
includeConfig !System.getenv('NXF_OFFLINE') && params.custom_config_base ? "${params.custom_config_base}/nfcore_custom.config" : "/dev/null"

// Load {{ name }} custom profiles from different institutions.
try {
includeConfig "${params.custom_config_base}/pipeline/{{ short_name }}.config"
} catch (Exception e) {
System.err.println("WARNING: Could not load nf-core/config/{{ short_name }} profiles: ${params.custom_config_base}/pipeline/{{ short_name }}.config")
}
// 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"
mirpedrol marked this conversation as resolved.
Show resolved Hide resolved
{% endif -%}

// Set default registry for Apptainer, Docker, Podman, Charliecloud and Singularity independent of -profile
Expand Down
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
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def create_tmp_pipeline(no_git: bool = False) -> Tuple[Path, Path, str, Path]:
tmp_dir = Path(tempfile.TemporaryDirectory().name)
root_repo_dir = Path(__file__).resolve().parent.parent
template_dir = root_repo_dir / "nf_core" / "pipeline-template"
pipeline_name = "mypipeline"
pipeline_name = "testpipeline"
pipeline_dir = tmp_dir / pipeline_name
pipeline_dir.mkdir(parents=True)

Expand All @@ -114,7 +114,7 @@ def create_tmp_pipeline(no_git: bool = False) -> Tuple[Path, Path, str, Path]:
org_path="nf-core",
lint=None,
template=NFCoreTemplateConfig(
name="mypipeline",
name="testpipeline",
author="me",
description="it is mine",
org="nf-core",
Expand Down
Loading