1
다음 테스트에서 예기치 않은 동작이 나타납니다. 내가 오해했을 수도 있지만 현재 나는 아이디어가 부족하고 의견을 주셔서 감사합니다. 다음 테스트를 고려하십시오.normalize_token이 예기치 않은 동작
# test passing an object
from dask import delayed, compute, get, set_options
# for testing the caching
from dask.base import normalize_token
from dask.cache import Cache
set_options(delayed_pure=True)
def test_object_hash():
cache_tmp = cache.Cache(1e9)
# test that object hashing is working
class Foo:
a = 1
b = 2
@normalize_token.register(Foo)
def tokenize_foo(self):
return normalize_token((self.a, self.b))
global_list = list()
def add(foo):
print("here")
global_list.append(1)
return foo.a + foo.b
# first, verify the hashes are the same
myobj = Foo()
first = delayed(add)(myobj)
myobj2 = Foo()
second = delayed(add)(myobj2)
assert first.key == second.key
# don't test with streams since it should be the same result
# this better highlights the problem
compute(first, get=get)
compute(second, get=get)
assert global_list == [1]
첫 번째 assert 문은 통과하지만 두 번째 문은 통과하지 않습니다. 나는 dask가 결과를 캐싱하여 같은 dask 키를 가진 계산이 오직 한 번만 계산된다고 생각했습니다. 이 코드에 누락 된 것이 있습니까? 이 문제는 dask.distributed
에서 발생합니다. 따라서 API에서 잘못 이해 된 것 같습니다.
감사합니다.