diff --git a/snakemake_interface_software_deployment_plugins/__init__.py b/snakemake_interface_software_deployment_plugins/__init__.py index 0c27039..e13565b 100644 --- a/snakemake_interface_software_deployment_plugins/__init__.py +++ b/snakemake_interface_software_deployment_plugins/__init__.py @@ -33,9 +33,16 @@ from snakemake_interface_common.software import SoftwareReport +@dataclass +class SuffixReplacement: + old_suffixes: List[str] + new_suffix: str + + @dataclass class EnvSpecSourceFile: path_or_uri: Union[str, Path] + suffix_replacement: Optional[SuffixReplacement] = None cached: Optional[Path] = field(repr=False, default=None) def __eq__(self, other) -> bool: @@ -46,6 +53,18 @@ def __eq__(self, other) -> bool: def __hash__(self) -> int: return hash(self.path_or_uri) + def replace_suffix( + self, suffixes: List[str], new_suffix: str + ) -> "EnvSpecSourceFile": + if self.suffix_replacement is not None: + raise ValueError("Suffix replacement already defined for this source file.") + return EnvSpecSourceFile( + path_or_uri=self.path_or_uri, + suffix_replacement=SuffixReplacement( + old_suffixes=suffixes, new_suffix=new_suffix + ), + ) + class EnvSpecBase(ABC): @classmethod @@ -306,6 +325,7 @@ def _managed_generic_hash(self, kind: str) -> str: if store is None: record_hash = f"record_{kind}" hash_object = hashlib.md5(usedforsecurity=False) + breakpoint() if self.within is not None and self.hash_include_within(): # For within, we always take the normal hash, # since the deployment just runs within that.