(*args, **kwargs)
| 49 | |
| 50 | |
| 51 | def 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 | |
| 82 | def test_check_tokenize(): |
no test coverage detected
searching dependent graphs…