Skip to content

Commit e0ee82c

Browse files
committed
fix: change id_generation to cloudpickle due to dill recursion bug
1 parent 0884c18 commit e0ee82c

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies = [
1919
"rich >= 12.6.0",
2020
"python-logging-loki >= 0.3.1",
2121
"neuroglancer >= 2.32",
22+
"cloudpickle >= 3.1.1",
2223
"dill >= 0.3.6",
2324
"pyyaml ~= 6.0.1",
2425
"requests==2.31.0", # version conflicts otherwise
@@ -34,7 +35,7 @@ keywords = ["neuroscience connectomics EM"]
3435
license = {text = "MIT"}
3536
name = "zetta_utils"
3637
readme = "README.md"
37-
requires-python = ">3.9,<3.13"
38+
requires-python = ">3.10,<3.13"
3839
urls = {Homepage = "https://github.com/zettaai/zetta_utils"}
3940
version = "0.0.2"
4041

zetta_utils/mazepa/id_generation.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import uuid
55
from typing import Callable, Optional
66

7-
import dill
7+
import cloudpickle
88
import xxhash
99
from coolname import generate_slug
1010

@@ -42,7 +42,7 @@ def generate_invocation_id(
4242
prefix: Optional[str] = None,
4343
) -> str:
4444
"""Generate a unique and deterministic ID for a function invocation.
45-
The ID is generated using xxhash and dill to hash the function and its arguments.
45+
The ID is generated using xxhash and cloudpickle to hash the function and its arguments.
4646
4747
:param fn: the function, or really any Callable, defaults to None
4848
:param args: the function arguments, or any list, defaults to None
@@ -53,16 +53,8 @@ def generate_invocation_id(
5353
"""
5454
x = xxhash.xxh128()
5555
try:
56-
x.update(
57-
dill.dumps(
58-
(fn, args, kwargs),
59-
protocol=dill.DEFAULT_PROTOCOL,
60-
byref=False,
61-
recurse=True,
62-
fmode=dill.FILE_FMODE,
63-
)
64-
)
65-
except dill.PicklingError as e:
56+
x.update(cloudpickle.dumps((fn, args, kwargs)))
57+
except Exception as e: # pylint: disable=broad-exception-caught
6658
logger.warning(f"Failed to pickle {fn} with args {args} and kwargs {kwargs}: {e}")
6759
x.update(str(uuid.uuid4()))
6860

0 commit comments

Comments
 (0)