flair.trainers.plugins.Pluggable#

class flair.trainers.plugins.Pluggable(*, plugins=[])View on GitHub#

Bases: object

Dispatches events which attached plugins can react to.

__init__(*, plugins=[])View on GitHub#

Initialize a Pluggable.

Parameters:

plugins (Sequence[Union[BasePlugin, type[BasePlugin]]]) – Plugins which should be attached to this Pluggable.

Methods

__init__(*[, plugins])

Initialize a Pluggable.

append_plugin(plugin)

dispatch(event, *args, **kwargs)

Call all functions hooked to a certain event.

register_hook(func, *events)

Register a hook.

remove_hook(handle)

Remove a hook handle from this instance.

validate_event(*events)

Attributes

plugins

Returns all plugins attached to this instance as a list of BasePlugin.

valid_events

valid_events: Optional[set[str]] = None#
property plugins#

Returns all plugins attached to this instance as a list of BasePlugin.

Returns:

List of BasePlugin instances attached to this Pluggable.

append_plugin(plugin)View on GitHub#
validate_event(*events)View on GitHub#
register_hook(func, *events)View on GitHub#

Register a hook.

Parameters:
  • func (Callable) – Function to be called when the event is emitted.

  • *events (str) – List of events to call this function on.

dispatch(event, *args, **kwargs)View on GitHub#

Call all functions hooked to a certain event.

Return type:

None

remove_hook(handle)View on GitHub#

Remove a hook handle from this instance.