Skip to content

Commit 58e774d

Browse files
committed
improve: add helpful error message for missing tensorboard package
- Checks if tensorboard is installed before attempting to create SummaryWriter - Provides installation instructions when tensorboard is missing - Improves user experience for debugging missing dependencies - Addresses issue #7980 Signed-off-by: skdas20 <skdas5405@gmail.com>
1 parent 85ed7a9 commit 58e774d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

monai/handlers/tensorboard_handlers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ class TensorBoardHandler:
5050

5151
def __init__(self, summary_writer: SummaryWriter | SummaryWriterX | None = None, log_dir: str = "./runs"):
5252
if summary_writer is None:
53+
if SummaryWriter is None:
54+
raise RuntimeError(
55+
"TensorBoardHandler requires tensorboard to be installed. "
56+
"Please install it with: pip install tensorboard"
57+
)
5358
self._writer = SummaryWriter(log_dir=log_dir)
5459
self.internal_writer = True
5560
else:

0 commit comments

Comments
 (0)