diff --git a/CHANGELOG.md b/CHANGELOG.md index e81fb7093b..b7365fa3f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,8 @@ ### Download -- Bugfix for AttributeError: 'ContainerError' object has no attribute 'absoluteURI' ([#2543](https://github.com/nf-core/tools/pull/2543)). +- Add `docker://` prefix for absolute container URIs as well ([#2576](https://github.com/nf-core/tools/pull/2576)). +- Bugfix for AttributeError: `ContainerError` object has no attribute `absoluteURI` ([#2543](https://github.com/nf-core/tools/pull/2543)). ### Linting diff --git a/nf_core/download.py b/nf_core/download.py index 2cb38061de..08bef935ba 100644 --- a/nf_core/download.py +++ b/nf_core/download.py @@ -1247,7 +1247,7 @@ def singularity_pull_image(self, container, out_path, cache_path, library, progr # Thus, if an explicit registry is specified, the provided -l value is ignored. container_parts = container.split("/") if len(container_parts) > 2: - address = container + address = f"docker://{container}" absolute_URI = True else: address = f"docker://{library}/{container.replace('docker://', '')}" diff --git a/tests/test_download.py b/tests/test_download.py index feb2090b27..7c9532e977 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -264,6 +264,11 @@ def test_singularity_pull_image_singularity_installed(self, tmp_dir, mock_rich_p "hello-world", f"{tmp_dir}/hello-world.sif", None, "docker.io", mock_rich_progress ) + # Test successful pull with absolute URI (use tiny 3.5MB test container from the "Kogia" project: https://github.com/bschiffthaler/kogia) + download_obj.singularity_pull_image( + "docker.io/bschiffthaler/sed", f"{tmp_dir}/sed.sif", None, "docker.io", mock_rich_progress + ) + # try to pull from non-existing registry (Name change hello-world_new.sif is needed, otherwise ImageExists is raised before attempting to pull.) with pytest.raises(ContainerError.RegistryNotFound): download_obj.singularity_pull_image( @@ -290,6 +295,16 @@ def test_singularity_pull_image_singularity_installed(self, tmp_dir, mock_rich_p "a-container", f"{tmp_dir}/acontainer.sif", None, "ghcr.io", mock_rich_progress ) + # test Image not found for absolute URI. + with pytest.raises(ContainerError.ImageNotFound): + download_obj.singularity_pull_image( + "docker.io/bschiffthaler/nothingtopullhere", + f"{tmp_dir}/nothingtopullhere.sif", + None, + "docker.io", + mock_rich_progress, + ) + # Traffic from Github Actions to GitHub's Container Registry is unlimited, so no harm should be done here. with pytest.raises(ContainerError.InvalidTag): download_obj.singularity_pull_image(