You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An alternative approach could be to use functools.singledispatch:
@functools.singledispatchdefhash_obj(obj: object) ->bytes:
# Works for generic objects with __dict__dict_rep=":".join(":".join(key, hash_obj(val)) forkey, valinobj.__dict__.items())
returnsha256(f"{obj.__class__}:{dict_rep}".encode()).hexdigest()
This defines a cryptographic hash for a generic object that applies recursively. We would need some bottom types that don't have __dict__:
And each type would be able to declare how much is needed to uniquely identify it across instances. We could add set() and frozenset() to ensure that these known-problematic builtin types are consistent. And then provide a means for a downstream tool to register a type with our hasher, such as:
Right now we have hashing split up in a few places:
pydra/pydra/engine/helpers.py
Lines 677 to 708 in b5fe4c0
pydra/pydra/engine/helpers.py
Lines 672 to 674 in b5fe4c0
pydra/pydra/engine/helpers_file.py
Lines 70 to 168 in b5fe4c0
An alternative approach could be to use
functools.singledispatch
:This defines a cryptographic hash for a generic object that applies recursively. We would need some bottom types that don't have
__dict__
:And each type would be able to declare how much is needed to uniquely identify it across instances. We could add
set()
andfrozenset()
to ensure that these known-problematic builtin types are consistent. And then provide a means for a downstream tool to register a type with our hasher, such as:or
The text was updated successfully, but these errors were encountered: