Skip to content

Commit 6282e25

Browse files
feat: suffix replacement (#54)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for suffix-substitution configuration in source files. * **Bug Fixes** * Removed unintended debugger breakpoint that was interrupting hash operations during runtime. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 58c5322 commit 6282e25

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

  • snakemake_interface_software_deployment_plugins

snakemake_interface_software_deployment_plugins/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@
3333
from snakemake_interface_common.software import SoftwareReport
3434

3535

36+
@dataclass
37+
class SuffixReplacement:
38+
old_suffixes: List[str]
39+
new_suffix: str
40+
41+
3642
@dataclass
3743
class EnvSpecSourceFile:
3844
path_or_uri: Union[str, Path]
45+
suffix_replacement: Optional[SuffixReplacement] = None
3946
cached: Optional[Path] = field(repr=False, default=None)
4047

4148
def __eq__(self, other) -> bool:
@@ -46,6 +53,18 @@ def __eq__(self, other) -> bool:
4653
def __hash__(self) -> int:
4754
return hash(self.path_or_uri)
4855

56+
def replace_suffix(
57+
self, suffixes: List[str], new_suffix: str
58+
) -> "EnvSpecSourceFile":
59+
if self.suffix_replacement is not None:
60+
raise ValueError("Suffix replacement already defined for this source file.")
61+
return EnvSpecSourceFile(
62+
path_or_uri=self.path_or_uri,
63+
suffix_replacement=SuffixReplacement(
64+
old_suffixes=suffixes, new_suffix=new_suffix
65+
),
66+
)
67+
4968

5069
class EnvSpecBase(ABC):
5170
@classmethod
@@ -306,6 +325,7 @@ def _managed_generic_hash(self, kind: str) -> str:
306325
if store is None:
307326
record_hash = f"record_{kind}"
308327
hash_object = hashlib.md5(usedforsecurity=False)
328+
breakpoint()
309329
if self.within is not None and self.hash_include_within():
310330
# For within, we always take the normal hash,
311331
# since the deployment just runs within that.

0 commit comments

Comments
 (0)