Skip to content

Commit

Permalink
Add docker prefix for absolute containers as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasZepper committed Dec 18, 2023
1 parent 58251cd commit e700682
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nf_core/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://', '')}"
Expand Down
15 changes: 15 additions & 0 deletions tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}/hello-world.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(
Expand All @@ -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(
Expand Down

0 comments on commit e700682

Please sign in to comment.