Skip to content

whos_there.callback

source module whos_there.callback

Classes

source class NotificationCallback()

Bases : Callback

Notification callback.

Initialize the notification callback.

Parameters

  • senders : list[Sender] | None List of instances of senders.

Attributes

  • state_key : str Identifier for the state of the callback.

Methods

  • setup Called when fit, validate, test, predict, or tune begins.

  • teardown Called when fit, validate, test, predict, or tune ends.

  • on_exception Called when any trainer execution is interrupted by an exception.

  • state_dict Called when saving a checkpoint, implement to generate callback's state_dict.

  • on_load_checkpoint Called when loading a model checkpoint, use to reload state.

source method NotificationCallback.setup(trainer: pl.Trainer, pl_module: pl.LightningModule, stage: str)None

Called when fit, validate, test, predict, or tune begins.

Parameters

  • trainer : pl.Trainer The current :class:~lightning.pytorch.trainer.Trainer instance.

  • pl_module : pl.LightningModule The current :class:~lightning.pytorch.core.lightning.LightningModule instance.

  • stage : str The stage the trainer is currently in.

source method NotificationCallback.teardown(trainer: pl.Trainer, pl_module: pl.LightningModule, stage: str)None

Called when fit, validate, test, predict, or tune ends.

Parameters

  • trainer : pl.Trainer The current :class:~lightning.pytorch.trainer.Trainer instance.

  • pl_module : pl.LightningModule The current :class:~lightning.pytorch.core.lightning.LightningModule instance.

  • stage : str The stage the trainer is currently in.

source method NotificationCallback.on_exception(trainer: pl.Trainer, pl_module: pl.LightningModule, exception: BaseException)None

Called when any trainer execution is interrupted by an exception.

Parameters

  • trainer : pl.Trainer The current :class:~lightning.pytorch.trainer.Trainer instance.

  • pl_module : pl.LightningModule The current :class:~lightning.pytorch.core.lightning.LightningModule instance.

  • exception : BaseException The exception raised.

source method NotificationCallback.state_dict()dict[str, Any]

Called when saving a checkpoint, implement to generate callback's state_dict.

Returns

  • dict[str, Any] A dictionary containing callback state.

source method NotificationCallback.on_load_checkpoint(trainer: pl.Trainer, pl_module: pl.LightningModule, checkpoint: dict[str, Any])None

Called when loading a model checkpoint, use to reload state.

Parameters

  • trainer : pl.Trainer the current :class:~lightning.pytorch.trainer.Trainer instance.

  • pl_module : pl.LightningModule the current :class:~lightning.pytorch.core.module.LightningModule instance.

  • checkpoint : dict[str, Any] the full checkpoint dictionary that got loaded by the Trainer.