Skip to content

Commit 0a3228b

Browse files
feat: more convenient cache API
1 parent cfe2e69 commit 0a3228b

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • snakemake_interface_software_deployment_plugins

snakemake_interface_software_deployment_plugins/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,18 @@ class CacheableEnvBase(EnvBase, ABC):
349349
async def get_cache_assets(self) -> Iterable[str]: ...
350350

351351
@abstractmethod
352-
async def cache_assets(self) -> None:
353-
"""Determine environment assets and store any associated information or data to
354-
self.cache_path.
352+
async def cache_asset(self, asset: str) -> None:
353+
"""Retrieve/create and store given asset to self.cache_path.
355354
"""
356355
...
357356

357+
async def managed_cache_assets(self) -> None:
358+
try:
359+
for asset in await self.get_cache_assets():
360+
await self.cache_asset(asset)
361+
except Exception as e:
362+
raise WorkflowError(f"Caching of {self.spec} failed: {e}") from e
363+
358364
@property
359365
def cache_path(self) -> Path:
360366
return self._cache_prefix

0 commit comments

Comments
 (0)