Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions snakemake_interface_software_deployment_plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,28 @@ def modify_identity_attributes(self, modify_func: Callable) -> Self:
return self._modify_attributes("identity_attributes", modify_func)

def _modify_attributes(self, attribute_method: str, modify_func: Callable) -> Self:
if self.has_source_paths():
self_or_copied = copy(self)
else:
attributes = list(getattr(self, attribute_method)())
if not attributes and self.within is None and self.fallback is None:
return self
for attr_name in getattr(self_or_copied, attribute_method)():
current_value = getattr(self_or_copied, attr_name)
copied = copy(self)

for attr_name in attributes:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
current_value = getattr(copied, attr_name)
if current_value is not None:
setattr(self_or_copied, attr_name, modify_func(current_value))
setattr(copied, attr_name, modify_func(current_value))

if self_or_copied.within is not None:
self_or_copied.within = self_or_copied.within._modify_attributes(
if copied.within is not None:
copied.within = copied.within._modify_attributes(
attribute_method,
modify_func,
)

if self_or_copied.fallback is not None:
self_or_copied.fallback = self_or_copied.fallback._modify_attributes(
if copied.fallback is not None:
copied.fallback = copied.fallback._modify_attributes(
attribute_method,
modify_func,
)
return self_or_copied
return copied

def __or__(self, other: "EnvSpecBase") -> "EnvSpecBase":
copied = copy(self)
Expand Down Expand Up @@ -341,10 +342,7 @@ def __hash__(self) -> int:
return self._obj_hash

def __eq__(self, other) -> bool:
return (
self.__class__ == other.__class__
and self.hash() == other.hash()
)
return self.__class__ == other.__class__ and self.hash() == other.hash()


class PinnableEnvBase(EnvBase, ABC):
Expand Down
Loading