2.0.11

HashFunction

Package: flyte.io

A hash method that wraps a user-provided function to compute hashes.

This class allows you to define custom hashing logic by providing a callable that takes data and returns a hash string. It implements the HashMethod protocol, making it compatible with Flyte’s hashing infrastructure.

Parameters

class HashFunction(
    fn: Callable[[Any], str],
)

Initialize a HashFunction with a custom hash callable.

Parameter Type Description
fn Callable[[Any], str]

Methods

Method Description
from_fn() Create a HashFunction from a callable.
reset()
result() Return the most recently computed hash value.
update() Update the hash value by applying the hash function to the given data.

from_fn()

def from_fn(
    fn: Callable[[Any], str],
) -> HashFunction

Create a HashFunction from a callable.

This is a convenience factory method for creating HashFunction instances.

Parameter Type Description
fn Callable[[Any], str] A callable that takes data of any type and returns a hash string.

Returns

A new HashFunction instance wrapping the provided callable.

reset()

def reset()

result()

def result()

Return the most recently computed hash value.

Returns: The hash string from the last call to update().

update()

def update(
    data: Any,
)

Update the hash value by applying the hash function to the given data.

Parameter Type Description
data Any The data to hash. The type depends on the hash function provided.