Args: item: data item to be hashed Returns: the corresponding hash key
(item)
| 1358 | |
| 1359 | |
| 1360 | def json_hashing(item) -> bytes: |
| 1361 | """ |
| 1362 | |
| 1363 | Args: |
| 1364 | item: data item to be hashed |
| 1365 | |
| 1366 | Returns: the corresponding hash key |
| 1367 | |
| 1368 | """ |
| 1369 | # TODO: Find way to hash transforms content as part of the cache |
| 1370 | cache_key = "" |
| 1371 | if sys.version_info.minor < 9: |
| 1372 | cache_key = hashlib.md5(json.dumps(item, sort_keys=True).encode("utf-8")).hexdigest() |
| 1373 | else: |
| 1374 | cache_key = hashlib.md5( |
| 1375 | json.dumps(item, sort_keys=True).encode("utf-8"), usedforsecurity=False # type: ignore |
| 1376 | ).hexdigest() |
| 1377 | return f"{cache_key}".encode() |
| 1378 | |
| 1379 | |
| 1380 | def pickle_hashing(item, protocol=pickle.HIGHEST_PROTOCOL) -> bytes: |
searching dependent graphs…