From 196cc438714dd6db91a592cea27f1516eab65cc1 Mon Sep 17 00:00:00 2001 From: Ashar Ali Date: Sun, 30 Aug 2026 18:45:35 -0400 Subject: [PATCH 1/3] fix(modules): match nf-core container formatting when bumping versions `nf-core modules bump-versions` rewrote the container directive with the ternary operators at column 0 and padding inside `${...}`: container "${ workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container ? 'https://...' : 'quay.io/...' }" Every module in nf-core/modules writes the operators at the start of the indented continuation lines instead, with no padding: container "${workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container ? 'https://...' : 'quay.io/...'}" The cause is the order of the interpolations in `_replace`: `f"? {inner_indent}"` emits the operator before the indent rather than after it. This is the formatting undone by hand across 106 files in nf-core/modules#12756, which is the PR the issue links to. Adds a regression test asserting the canonical block is what lands in main.nf. Closes #4452 Signed-off-by: Ashar Ali --- nf_core/modules/containers.py | 6 +++--- tests/modules/test_containers.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/nf_core/modules/containers.py b/nf_core/modules/containers.py index 74496f6304..eefa8dac81 100644 --- a/nf_core/modules/containers.py +++ b/nf_core/modules/containers.py @@ -322,10 +322,10 @@ def _replace(match: "re.Match[str]") -> str: indent = match.group(1) inner_indent = indent + " " return ( - f"{indent}container \"${{ workflow.containerEngine in ['singularity', 'apptainer'] " + f"{indent}container \"${{workflow.containerEngine in ['singularity', 'apptainer'] " "&& !task.ext.singularity_pull_docker_container\n" - f"? {inner_indent}'{singularity_image}'\n" - f": {inner_indent}'{docker_image}' }}\"" + f"{inner_indent}? '{singularity_image}'\n" + f"{inner_indent}: '{docker_image}'}}\"" ) new_content = re.sub( diff --git a/tests/modules/test_containers.py b/tests/modules/test_containers.py index b48b75b018..dcfcd49bd1 100644 --- a/tests/modules/test_containers.py +++ b/tests/modules/test_containers.py @@ -350,6 +350,30 @@ def test_get_containers_from_meta_success(self): assert result is not None assert result == MetaYmlContainers.model_validate(containers) + def test_update_main_nf_container_matches_nf_core_formatting(self): + """The rewritten directive must match the formatting used across nf-core/modules. + + The ternary operators belong at the start of the indented continuation lines, + and there is no padding inside `${...}`. + """ + singularity = "https://community-cr-prod.seqera.io/blobs/sha256/e6/e613097/data" + docker = "community.wave.seqera.io/library/bpipe_test:0.1.0--abc123" + self.module_containers.containers = MetaYmlContainers( + docker={p: ContainerEntry(name=docker) for p in CONTAINER_PLATFORMS}, + singularity={p: ContainerEntry(name=singularity) for p in CONTAINER_PLATFORMS}, + ) + + main_nf = self.bpipe_test_module_path / "main.nf" + self.module_containers.update_main_nf_container(force=True) + + expected = ( + " container \"${workflow.containerEngine in ['singularity', 'apptainer'] " + "&& !task.ext.singularity_pull_docker_container\n" + f" ? '{singularity}'\n" + f" : '{docker}'}}\"" + ) + assert expected in main_nf.read_text() + def test_update_containers_in_meta_merges(self): self._write_meta({"name": "bpipe/test", "containers": {"docker": {"linux/amd64": {"name": "old"}}}}) containers = self._containers_by_system("new") From a4816ce6966bffd10793b674d82504cc4d919925 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Fri, 9 Oct 2026 14:46:29 +0000 Subject: [PATCH 2/3] [automated] Update CHANGELOG.md [skip ci] --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee2f6f466c..365793c7fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ ### Modules +- modules bump-versions: match nf-core container formatting in main.nf ([#4459](https://github.com/nf-core/tools/pull/4459)) + ### Subworkflows ### Template From 40fb1084d7d4cf77cc6b6202812b128b4a7ed20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20H=C3=B6rtenhuber?= Date: Thu, 15 Oct 2026 17:31:58 +0200 Subject: [PATCH 3/3] Apply suggestion from @mashehu --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 365793c7fd..04b4034b6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ ### Modules -- modules bump-versions: match nf-core container formatting in main.nf ([#4459](https://github.com/nf-core/tools/pull/4459)) +- modules main.nf template: match nf-core container formatting in main.nf ([#4459](https://github.com/nf-core/tools/pull/4459)) ### Subworkflows