From 32bc483990b4eb689e5db0a461bcb7120b01d885 Mon Sep 17 00:00:00 2001 From: Andrei Maslennikov Date: Wed, 18 Mar 2026 11:47:13 +0100 Subject: [PATCH] Fix path expansion/storage --- src/cloudai/_core/installables.py | 3 +++ tests/systems/slurm/test_installer.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/cloudai/_core/installables.py b/src/cloudai/_core/installables.py index f8527876c..a901502d6 100644 --- a/src/cloudai/_core/installables.py +++ b/src/cloudai/_core/installables.py @@ -77,6 +77,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 diff --git a/tests/systems/slurm/test_installer.py b/tests/systems/slurm/test_installer.py index 2c09ddc25..8cf6ecaa0 100644 --- a/tests/systems/slurm/test_installer.py +++ b/tests/systems/slurm/test_installer.py @@ -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