Skip to main content

prefect.utilities.dispatch

Provides methods for performing dynamic dispatch for actions on base type to one of its subtypes. Example:

Functions

get_registry_for_type

Get the first matching registry for a class or any of its base classes. If not found, None is returned.

get_dispatch_key

Retrieve the unique dispatch key for a class type or instance. This key is defined at the __dispatch_key__ attribute. If it is a callable, it will be resolved. If allow_missing is False, an exception will be raised if the attribute is not defined or the key is null. If True, None will be returned in these cases.

register_base_type

Register a base type allowing child types to be registered for dispatch with register_type. The base class may or may not define a __dispatch_key__ to allow lookups of the base type.

register_type

Register a type for lookup with dispatch. The type or one of its parents must define a unique __dispatch_key__. One of the classes base types must be registered using register_base_type.

lookup_type

Look up a dispatch key in the type registry for the given class.