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

Download: Add docker prefix for absolute container URIs as well. #2576

Merged
merged 2 commits into from
Dec 18, 2023
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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}/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(
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
Loading