Skip to content

Commit

Permalink
fixed ParameterInvariant.freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
TyberiusPrime committed Sep 20, 2024
1 parent 553a85f commit bca115f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions python/pypipegraph2/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ def freeze(obj):
# if isinstance(obj, str) and len(obj) == 32 and is_hex_re.match(obj):
# If it's already a hash, we keep it that way
# return obj
return _hash_object(obj)
return _hash_object(obj)[1]

def extract_strict_hash(self, a_hash) -> bytes:
return str(ParameterInvariant.freeze(a_hash)).encode("utf-8")
Expand All @@ -1894,14 +1894,14 @@ def _hash_object(obj):
my_hash = hashers.hash_bytes(obj.encode("utf-8"))
elif isinstance(obj, bytes):
my_hash = hashers.hash_bytes(obj)
elif isinstance(
obj, (int, float, complex)
): # for these types, the build in hash should be good enough. This also covers numpy floats
# todo: does it vary across python versions?
# todo: these do not get salted. at least up to 3.8..
# todo: probably would be better to choose something deterministic...
# but also lot of work.
my_hash = str(hash(obj)) # since the others are also strings.
# elif isinstance(
# obj, (int, float, complex)
# ): # for these types, the build in hash should be good enough. This also covers numpy floats
# # todo: does it vary across python versions?
# # todo: these do not get salted. at least up to 3.8..
# # todo: probably would be better to choose something deterministic...
# # but also lot of work.
# my_hash = str(hash(obj)) # since the others are also strings.
elif isinstance(obj, ValuePlusHash):
my_hash = obj.hexdigest
obj = obj.value
Expand Down

0 comments on commit bca115f

Please sign in to comment.