View source on GitHub
|
A dictionary-like container for custom functions used in serialization.
schema.serde.distribution.FunctionRegistry(
*args, **kwargs
)
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 | |
|---|---|
*args
|
Positional arguments to pass to the dictionary constructor. |
**kwargs
|
Keyword arguments to pass to the dictionary constructor. |
Attributes | |
|---|---|
hashed_registry
|
Returns hashed function registry with keys mapped to hashed function code. |
Methods
get_function_key
get_function_key(
func: Callable[..., Any]
) -> (str | None)
Returns the function key for the given function from the registry.
validate
validate(
stored_hashed_function_registry: dict[str, str]
)
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. |
View source on GitHub