FailOnInterrupt
Forces lightning Trainer to fail on KeyboardInterrupt by raising RuntimeError.
Usage
from lightning import Trainer
from thunder.callbacks import FailOnInterrupt
trainer = Trainer(..., callbacks=[FailOnInterrupt()])
Reference
thunder.callbacks.fail_on_interrupt.FailOnInterrupt
Bases: Callback
Forces RuntimeError in order for trainer to stop if KeyboardInterrupt was raised
Source code in thunder/callbacks/fail_on_interrupt.py
| class FailOnInterrupt(Callback):
"""Forces RuntimeError in order for trainer to stop if KeyboardInterrupt was raised"""
def on_exception(self, trainer: Trainer, pl_module: LightningModule, exception: BaseException) -> None:
if isinstance(exception, KeyboardInterrupt):
raise RuntimeError("Finished run on KeyboardInterrupt") from exception
|
on_exception(trainer, pl_module, exception)
Source code in thunder/callbacks/fail_on_interrupt.py
| def on_exception(self, trainer: Trainer, pl_module: LightningModule, exception: BaseException) -> None:
if isinstance(exception, KeyboardInterrupt):
raise RuntimeError("Finished run on KeyboardInterrupt") from exception
|