schema.serde.distribution.FunctionRegistry

A dictionary-like container for custom functions used in serialization.

This class extends dict and provides methods for hashing, validation, and key retrieval based on function identity, required for safe serialization and deserialization of models that use custom functions.

*args Positional arguments to pass to the dictionary constructor.
**kwargs Keyword arguments to pass to the dictionary constructor.

hashed_registry Returns hashed function registry with keys mapped to hashed function code.

Methods

get_function_key

View source

Returns the function key for the given function from the registry.

validate

View source

Validates whether functions within the registry have changed.

It checks that all functions listed in stored_hashed_function_registry are present in this registry, and that their source code hash matches the stored hash.

Args
stored_hashed_function_registry The hashed function registry from the serialized object.

Raises
ValueError If a function is missing or a hash mismatch is detected.