From 2f6bcc7d16883641de6d36adda5999ad174f2c9e Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 18 Sep 2026 13:33:53 +0200 Subject: [PATCH 1/3] feat: provide method for retrieving the cache_asset path of a given asset --- snakemake_interface_software_deployment_plugins/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/snakemake_interface_software_deployment_plugins/__init__.py b/snakemake_interface_software_deployment_plugins/__init__.py index 8178d8a..dc81fe7 100644 --- a/snakemake_interface_software_deployment_plugins/__init__.py +++ b/snakemake_interface_software_deployment_plugins/__init__.py @@ -399,7 +399,7 @@ async def managed_cache_asset(self, asset: str) -> None: ) os.close(fd) tmp_cache_path = Path(tmp_cache_path) - cache_path = self.cache_path / asset + cache_path = self.get_cache_asset_path(asset) try: await self.cache_asset(asset, tmp_cache_path) os.replace(tmp_cache_path, cache_path) @@ -415,6 +415,10 @@ async def managed_cache_asset(self, asset: str) -> None: def cache_path(self) -> Path: return self._cache_prefix + @property + def get_cache_asset_path(self, asset: str) -> Path: + return self.cache_path / asset + async def remove_cache(self) -> None: """Remove the cached environment assets.""" for asset in await self.get_cache_assets(): From 6cc6f9c64622d6cbe0e00086d1fb8a6cab2bc406 Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 18 Sep 2026 13:34:33 +0200 Subject: [PATCH 2/3] fmt --- snakemake_interface_software_deployment_plugins/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snakemake_interface_software_deployment_plugins/__init__.py b/snakemake_interface_software_deployment_plugins/__init__.py index dc81fe7..1e38bb6 100644 --- a/snakemake_interface_software_deployment_plugins/__init__.py +++ b/snakemake_interface_software_deployment_plugins/__init__.py @@ -417,6 +417,9 @@ def cache_path(self) -> Path: @property def get_cache_asset_path(self, asset: str) -> Path: + """Return the path to the cached asset. + This does not check whether the asset exists. + """ return self.cache_path / asset async def remove_cache(self) -> None: From a921adb11ee2e9c3ea5f12e6aff665079ba1d146 Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 18 Sep 2026 13:41:28 +0200 Subject: [PATCH 3/3] fix: always pin and cache if the env provides that --- .../tests.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/snakemake_interface_software_deployment_plugins/tests.py b/snakemake_interface_software_deployment_plugins/tests.py index 2b9da15..46b4452 100644 --- a/snakemake_interface_software_deployment_plugins/tests.py +++ b/snakemake_interface_software_deployment_plugins/tests.py @@ -101,6 +101,10 @@ def test_shellcmd(self, tmp_path): assert cmd != decorated_cmd assert env.run_cmd(decorated_cmd).returncode == 0 + async def _cache_assets(env): + for asset in await env.get_cache_assets(): + await env.managed_cache_asset(asset) + def test_deploy(self, tmp_path): env = self._get_env(tmp_path) self._deploy(env, tmp_path) @@ -114,13 +118,7 @@ def test_cache(self, tmp_path): assert isinstance(env, CacheableEnvBase) - async def cache_assets(env): - for asset in await env.get_cache_assets(): - await env.managed_cache_asset(asset) - - asyncio.run(cache_assets(env)) - - self._deploy(env, tmp_path) + asyncio.run(self.cache_assets(env)) assert any(env.cache_path.iterdir()) @@ -134,7 +132,6 @@ def test_pin(self, tmp_path): asyncio.run(env.pin()) assert env.pinfile.exists() print("Pinfile content:", env.pinfile.read_text(), sep="\n") - self._deploy(env, tmp_path) def test_report_software(self, tmp_path): env = self._get_env(tmp_path) @@ -257,6 +254,11 @@ def _deploy(self, env: EnvBase, tmp_path): if not env.is_deployable(): pytest.skip("Environment is not deployable.") + if env.is_pinnable(): + asyncio.run(env.pin()) + if env.is_cacheable(): + asyncio.run(self._cache_assets(env)) + assert isinstance(env, DeployableEnvBase) asyncio.run(env.deploy()) assert any((tmp_path / env.spec.module().__name__ / "deployments").iterdir())