Skip to content
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: 3 additions & 0 deletions src/cloudai/_core/installables.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def installed_path(self) -> Union[str, Path]:
"""Return the cached path or URL of the docker image."""
if self._installed_path:
return self._installed_path.absolute() if isinstance(self._installed_path, Path) else self._installed_path
local_image_path = Path(self.url)
if local_image_path.is_absolute() or self.url.startswith("."):
return local_image_path.absolute()
return self.url

@installed_path.setter
Expand Down
14 changes: 14 additions & 0 deletions tests/systems/slurm/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,17 @@ def test_mark_as_installed_local_container(slurm_system: SlurmSystem):
installer.mark_as_installed_one(docker_image)

assert docker_image.installed_path == local_image.absolute()


def test_mark_as_installed_duplicate_local_containers_preserve_local_path(slurm_system: SlurmSystem):
installer = SlurmInstaller(slurm_system)

local_image = Path("/tmp/local_image.sqsh")
first = DockerImage(url=str(local_image))
second = DockerImage(url=str(local_image))

result = installer.mark_as_installed([first, second])

assert result.success
assert first.installed_path == local_image
assert second.installed_path == local_image
Loading