MCPcopy Create free account
hub / github.com/dask/dask / check_tokenize

Function check_tokenize

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

Source from the content-addressed store, hash-verified

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

Calls 2

tokenizeFunction · 0.90
setMethod · 0.80

Tested by

no test coverage detected