-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Improve/writer error messages #8753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
85ed7a9
58e774d
2cefafe
a5ed44b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,12 +14,13 @@ | |||||||||||||
| import glob | ||||||||||||||
| import tempfile | ||||||||||||||
| import unittest | ||||||||||||||
| from unittest.mock import MagicMock | ||||||||||||||
| from unittest.mock import MagicMock, patch | ||||||||||||||
|
|
||||||||||||||
| from ignite.engine import Engine, Events | ||||||||||||||
| from parameterized import parameterized | ||||||||||||||
|
|
||||||||||||||
| from monai.handlers import TensorBoardStatsHandler | ||||||||||||||
| from monai.handlers.tensorboard_handlers import TensorBoardHandler | ||||||||||||||
| from monai.utils import optional_import | ||||||||||||||
|
|
||||||||||||||
| SummaryWriter, has_tb = optional_import("torch.utils.tensorboard", name="SummaryWriter") | ||||||||||||||
|
|
@@ -162,5 +163,13 @@ def _update_metric(engine): | |||||||||||||
| ) # 2 = len([1, 3]) from event_filter | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| class TestTensorBoardHandlerMissingDependency(unittest.TestCase): | ||||||||||||||
|
|
||||||||||||||
| def test_raises_when_tensorboard_unavailable(self): | ||||||||||||||
| with patch("monai.handlers.tensorboard_handlers._tb_available", False): | ||||||||||||||
| with self.assertRaises(RuntimeError): | ||||||||||||||
| TensorBoardHandler() | ||||||||||||||
|
Comment on lines
+169
to
+171
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Assert the installation guidance, not only the exception type. The PR objective requires an actionable Suggested assertion- with self.assertRaises(RuntimeError):
+ with self.assertRaisesRegex(RuntimeError, r"pip install tensorboard"):
TensorBoardHandler()📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| if __name__ == "__main__": | ||||||||||||||
| unittest.main() | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add docstrings to the new test definitions.
Document the test class and method, for example:
TestTensorBoardHandlerMissingDependencyverifies missing TensorBoard handling, andtest_raises_when_tensorboard_unavailableverifies the raised exception.As per path instructions, “Docstrings should be present for all definition[s] which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings.”
🤖 Prompt for AI Agents
Source: Path instructions