Skip to content

Commit

Permalink
fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasraabe committed Nov 8, 2023
1 parent 6f2a7ea commit 3a91f23
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/_pytask/_hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,6 @@ def hash_value(value: Any) -> int | str:
"""
if value is None:
return 0xFCA86420
if hasattr(value, "_asdict"):
value = value._asdict()
if isinstance(value, dict):
value = "".join(
"".join((str(hash_value(k)), str(hash_value(value[k]))))
for k in sorted(value)
)
if isinstance(value, (tuple, list)):
value = "".join(str(hash_value(i)) for i in value)
if isinstance(value, Path):
Expand Down
14 changes: 8 additions & 6 deletions src/_pytask/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,14 @@ class PythonNode(PNode):
@property
def signature(self) -> str:
"""The unique signature of the node."""
if self.node_info:
dict_ = self.node_info._asdict()
dict_.pop("value", None)
raw_key = str(hash_value(dict_))
else:
raw_key = str(hash_value(self.node_info))
raw_key = (
"".join(
str(hash_value(getattr(self.node_info, name)))
for name in ("arg_name", "path", "task_name", "task_path")
)
if self.node_info
else str(hash_value(self.node_info))
)
return hashlib.sha256(raw_key.encode()).hexdigest()

def load(self, is_product: bool = False) -> Any:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_hash_of_python_node(value, hash_, expected):
task_name="task_example",
),
),
"17b24b0e3141135172b02c8d898d0337ea79bea0f56b6272d18b6bb8e75f985f",
"7284475a87b8f1aa49c40126c5064269f0ba926265b8fe9158a39a882c6a1512",
),
(
Task(base_name="task", path=Path("task.py"), function=None),
Expand Down

0 comments on commit 3a91f23

Please sign in to comment.