MCPcopy
hub / github.com/dask/dask / check_tokenize

Function check_tokenize

dask/tests/test_tokenize.py:51–79  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

49
50
51def check_tokenize(*args, **kwargs):
52 with dask.config.set({"tokenize.ensure-deterministic": True}):
53 before = tokenize(*args, **kwargs)
54
55 # Test idempotency (the same object tokenizes to the same value)
56 after = tokenize(*args, **kwargs)
57
58 assert before == after, (args, kwargs)
59
60 # Test same-interpreter determinism (two identical objects tokenize to the
61 # same value as long as you do it on the same interpreter) We are not
62 # particularly interested in a class that's never been pickled vs. one
63 # that's already been pickled already (cloudpickle can introduce artifacts
64 # on the first round-trip). We do care however about classes that have both
65 # been through a serialization roundtrip at least once (not necessarily the
66 # same amount of times).
67 args2, kwargs2 = cloudpickle.loads(cloudpickle.dumps((args, kwargs)))
68 args3, kwargs3 = cloudpickle.loads(cloudpickle.dumps((args, kwargs)))
69 args3, kwargs3 = cloudpickle.loads(cloudpickle.dumps((args3, kwargs3)))
70
71 tok2 = tokenize(*args2, **kwargs2)
72 assert tok2 == before, (args, kwargs)
73
74 tok3 = tokenize(*args3, **kwargs3)
75 assert tok2 == tok3, (args, kwargs)
76
77 # Skip: different interpreter determinism
78
79 return before
80
81
82def test_check_tokenize():

Calls 2

tokenizeFunction · 0.90
setMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…