MCPcopy
hub / github.com/dask/dask / tokenize

Function tokenize

dask/tokenize.py:47–80  ·  view source on GitHub ↗

Deterministic token >>> tokenize([1, 2, '3']) # doctest: +SKIP '06961e8de572e73c2e74b51348177918' >>> tokenize('Hello') == tokenize('Hello') True Parameters ---------- args, kwargs: objects to tokenize ensure_deterministic: bool, optional If True,

(
    *args: object, ensure_deterministic: bool | None = None, **kwargs: object
)

Source from the content-addressed store, hash-verified

45
46
47def tokenize(
48 *args: object, ensure_deterministic: bool | None = None, **kwargs: object
49) -> str:
50 """Deterministic token
51
52 >>> tokenize([1, 2, '3']) # doctest: +SKIP
53 '06961e8de572e73c2e74b51348177918'
54
55 >>> tokenize('Hello') == tokenize('Hello')
56 True
57
58 Parameters
59 ----------
60 args, kwargs:
61 objects to tokenize
62 ensure_deterministic: bool, optional
63 If True, raise TokenizationError if the objects cannot be deterministically
64 tokenized, e.g. two identical objects will return different tokens.
65 Defaults to the `tokenize.ensure-deterministic` configuration parameter.
66 """
67 global _SEEN
68 with tokenize_lock:
69 seen_before, _SEEN = _SEEN, {}
70 token = None
71 try:
72 _ENSURE_DETERMINISTIC.get()
73 except LookupError:
74 token = _ENSURE_DETERMINISTIC.set(ensure_deterministic)
75 try:
76 return _tokenize(*args, **kwargs)
77 finally:
78 if token:
79 _ENSURE_DETERMINISTIC.reset(token)
80 _SEEN = seen_before
81
82
83def _maybe_raise_nondeterministic(msg: str) -> None:

Callers 15

cullMethod · 0.90
_unpackFunction · 0.90
clone_keyFunction · 0.90
__eq__Method · 0.90
__dask_tokenize__Method · 0.90
_get_tokenMethod · 0.90
__dask_tokenize__Method · 0.90
_layerMethod · 0.90
_layerMethod · 0.90
to_bagFunction · 0.90
approx_statisticsMethod · 0.90
raw_statisticsMethod · 0.90

Calls 3

_tokenizeFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…