clinicadl.callbacks.CallbacksHandler

class clinicadl.callbacks.CallbacksHandler(callbacks: Sequence[Callback])[source]

To handle all the Callbacks passed to a Trainer.

Note that some callbacks are instantiated by default: LoggerCallback, MonitorCallback, ModelCheckpointCallback and TrainingCheckpointCallback. To override them, just pass a new instance.

Parameters:

callbacks (Sequence[Callback]) –

A sequence of Callbacks.

Important

Order matters! The order of the callbacks may determine the order in which callbacks will be called. Note, however, that some callbacks have an immutable rank in this order. For example, no matter where you place LoggerCallback, it will be called first to initialize logging and last to shutdown logging.

property callbacks: list[Callback]

The public callbacks currently in the CallbacksHandler.

property all_callbacks: list[Callback]

The callbacks currently in the CallbacksHandler, including private callbacks (mandatory callbacks that are always used by ClinicaDL).

add_callbacks(callbacks: Sequence[Callback]) None[source]

Adds new callbacks.

call_event(event: str | Event, **kwargs) None[source]

Call a specific event method on all callbacks (see Callback to get the list of the events).

Parameters:
  • event (str | Event) – Name of the event to call (e.g. "on_train_start").

  • kwargs (Any) – Keyword arguments that will be passed to the methods associated to this event.