Skip to content

Commit

Permalink
Merge pull request nf-core#2576 from MatthiasZepper/Download_Docker_p…
Browse files Browse the repository at this point in the history
…refix

Download: Add docker prefix for absolute container URIs as well.
  • Loading branch information
MatthiasZepper authored Dec 18, 2023
2 parents 58251cd + 0241790 commit 056036a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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

0 comments on commit 056036a

Please sign in to comment.