Merge pull request #14431 from mvdbeek/cached_image_path_identifier_fix

[22.05] Fix cache image singularity resolver if path contains uppercase chars
This commit is contained in:
Marius van den Beek
2022-08-12 11:21:49 +02:00
committed by GitHub
2 changed files with 33 additions and 2 deletions
+9 -2
View File
@@ -1,4 +1,5 @@
import copy
import os
from typing import (
Any,
Callable,
@@ -186,8 +187,14 @@ class ContainerDescription:
resolve_dependencies: bool = DEFAULT_CONTAINER_RESOLVE_DEPENDENCIES,
shell: str = DEFAULT_CONTAINER_SHELL,
) -> None:
# Force to lowercase because container image names must be lowercase
self.identifier = identifier.lower() if identifier else None
# Force to lowercase because container image names must be lowercase.
# Cached singularity images include the path on disk, so only lowercase
# the image identifier portion.
self.identifier = None
if identifier:
parts = identifier.rsplit(os.sep, 1)
parts[-1] = parts[-1].lower()
self.identifier = os.sep.join(parts)
self.type = type
self.resolve_dependencies = resolve_dependencies
self.shell = shell
@@ -0,0 +1,24 @@
import pytest
from galaxy.tool_util.deps.requirements import ContainerDescription
@pytest.mark.parametrize(
"identifier,expected_identifier",
[
("mulled-abc", "mulled-abc"),
("docker://mulled-abc", "docker://mulled-abc"),
("/Cache/mulled-abc", "/Cache/mulled-abc"),
("/Cache/mUlled-abc", "/Cache/mulled-abc"),
("", None),
(None, None),
],
)
def test_container_description(identifier, expected_identifier):
assert ContainerDescription(identifier=identifier).identifier == expected_identifier
def test_to_from_dict():
container_description_dict = ContainerDescription("mulled-abc").to_dict()
container_description = ContainerDescription.from_dict(container_description_dict)
assert container_description_dict == container_description.to_dict()