Skip to content

registry ¤

RegisteredFunction dataclass ¤

RegisteredFunction(
    fn: FunctionType,
    key: str,
    filename: str,
    lineno: int,
    hash: str,
)

A function that can be referenced in durable state.

register_function ¤

register_function(fn: FunctionType) -> RegisteredFunction

Register a function in the in-memory function registry.

When serializing a registered function, a reference to the function is stored along with details about its location and contents. When deserializing the function, the registry is consulted in order to find the function associated with the reference (and in order to check whether the function is the same).

Parameters:

Name Type Description Default
fn FunctionType

The function to register.

required

Returns:

Name Type Description
str RegisteredFunction

Unique identifier for the function.

Raises:

Type Description
ValueError

The function conflicts with another registered function.

lookup_function ¤

lookup_function(key: str) -> RegisteredFunction

Lookup a registered function by key.

Parameters:

Name Type Description Default
key str

Unique identifier for the function.

required

Returns:

Name Type Description
RegisteredFunction RegisteredFunction

the function that was registered with the specified key.

Raises:

Type Description
KeyError

A function has not been registered with this key.

unregister_function ¤

unregister_function(key: str)

Unregister a function by key.

Parameters:

Name Type Description Default
key str

Unique identifier for the function.

required

Raises:

Type Description
KeyError

A function has not been registered with this key.

clear_functions ¤

clear_functions()

Clear functions clears the registry.