docs/v3/api-ref/python/prefect-utilities-hashing.mdx
prefect.utilities.hashingstable_hash <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/utilities/hashing.py#L14" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>stable_hash(*args: Union[str, bytes]) -> str
Given some arguments, produces a stable 64-bit hash of their contents.
Supports bytes and strings. Strings will be UTF-8 encoded.
Args:
*args: Items to include in the hash.hash_algo: Hash algorithm from hashlib to use.Returns:
file_hash <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/utilities/hashing.py#L34" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>file_hash(path: str, hash_algo: Callable[..., Any] = _md5) -> str
Given a path to a file, produces a stable hash of the file contents.
Args:
path: the path to a filehash_algo: Hash algorithm from hashlib to use.Returns:
hash_objects <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/utilities/hashing.py#L48" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>hash_objects(*args: Any, **kwargs: Any) -> Optional[str]
Attempt to hash objects by dumping to JSON or serializing with cloudpickle.
Args:
*args: Positional arguments to hashhash_algo: Hash algorithm to useraise_on_failure: If True, raise exceptions instead of returning None**kwargs: Keyword arguments to hashReturns:
Raises:
HashError: If objects cannot be hashed and raise_on_failure is True