Skip to content
Open
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
2 changes: 1 addition & 1 deletion cwltool/singularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def get_image(
d_image_id = dockerRequirement["dockerImageId"]
if d_image_id in _IMAGES:
if (resolved_image_id := _IMAGES[d_image_id]) != d_image_id:
dockerRequirement["dockerImage_id"] = resolved_image_id
dockerRequirement["dockerImageId"] = resolved_image_id
return True
if d_image_id.startswith("/"):
_logger.info(
Expand Down
19 changes: 19 additions & 0 deletions tests/test_singularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from cwltool.singularity import (
_IMAGES,
_IMAGES_LOCK,
SingularityCommandLineJob,
_inspect_singularity_sandbox_image,
)

Expand Down Expand Up @@ -414,3 +415,21 @@ def mock_failed_subprocess(*args: Any, **kwargs: Any) -> None:
monkeypatch.setattr("cwltool.singularity.run", mock_failed_subprocess)
res_inspect = _inspect_singularity_sandbox_image("/tmp/container_repo/alpine")
assert res_inspect is False


def test_get_image_cached_resolution_updates_docker_image_id() -> None:
"""A cached image resolution must be written back to 'dockerImageId'."""
with _IMAGES_LOCK:
_IMAGES["test-cached-image.sif"] = "/cache/test-cached-image.sif"
try:
docker_requirement: dict[str, str] = {
"class": "DockerRequirement",
"dockerImageId": "test-cached-image.sif",
}
assert SingularityCommandLineJob.get_image(
docker_requirement, pull_image=False, tmp_outdir_prefix="/tmp/"
)
assert docker_requirement["dockerImageId"] == "/cache/test-cached-image.sif"
finally:
with _IMAGES_LOCK:
_IMAGES.pop("test-cached-image.sif", None)