From 1d6817d8a756e1208ff11abb1e5729b15ae31cfc Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Tue, 30 Sep 2025 12:45:56 +0200 Subject: [PATCH] feat: allow removal of pinfile --- .../__init__.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/snakemake_interface_software_deployment_plugins/__init__.py b/snakemake_interface_software_deployment_plugins/__init__.py index f95243f..f38b8f4 100644 --- a/snakemake_interface_software_deployment_plugins/__init__.py +++ b/snakemake_interface_software_deployment_plugins/__init__.py @@ -312,6 +312,16 @@ def pinfile(self) -> Path: self.pinfile_extension() ) + def remove_pinfile(self) -> None: + """Remove the pinfile.""" + if self.pinfile.exists(): + try: + self.pinfile.unlink() + except Exception as e: + raise WorkflowError( + f"Removal of pinfile {self.pinfile} failed: {e}" + ) from e + class CacheableEnvBase(EnvBase, ABC): async def get_cache_assets(self) -> Iterable[str]: ... @@ -340,7 +350,7 @@ async def remove_cache(self) -> None: except Exception as e: raise WorkflowError( f"Removal of cache asset {asset_path} for {self.spec} failed: {e}" - ) + ) from e class DeployableEnvBase(EnvBase, ABC): @@ -385,13 +395,13 @@ def managed_remove(self) -> None: try: self.remove() except Exception as e: - raise WorkflowError(f"Removal of {self.spec} failed: {e}") + raise WorkflowError(f"Removal of {self.spec} failed: {e}") from e async def managed_deploy(self) -> None: try: await self.deploy() except Exception as e: - raise WorkflowError(f"Deployment of {self.spec} failed: {e}") + raise WorkflowError(f"Deployment of {self.spec} failed: {e}") from e def deployment_hash(self) -> str: return self._managed_generic_hash("deployment_hash")