-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix #7980: Enhanced image writer error messages with actionable installation guidance #8594
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
Open
iloveme81189-del
wants to merge
2
commits into
Project-MONAI:dev
Choose a base branch
from
iloveme81189-del:fix-issue-7980-writer-error-message
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+37
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
Manual environment check for versions of PyTorch and MONAI. | ||
|
||
This script helps verify the runtime versions of key libraries during manual testing | ||
of writer error messages or environment troubleshooting. | ||
|
||
Note: | ||
- This is intended for manual execution only. | ||
- Consider moving to a diagnostics folder or integrating into automated tests. | ||
""" | ||
|
||
import torch | ||
import monai | ||
|
||
print("Torch version:", torch.__version__) | ||
print("MONAI version:", monai.__version__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from monai.data.image_writer import resolve_writer, OptionalImportError, SUPPORTED_WRITERS, EXT_WILDCARD, ITKWriter | ||
|
||
# Fake extension to simulate unsupported file type | ||
ext = "fakeext" | ||
|
||
print(f"Before clearing fallback writers: {SUPPORTED_WRITERS.get(EXT_WILDCARD)}") | ||
|
||
# Temporarily clear fallback writers to simulate no support scenario | ||
SUPPORTED_WRITERS[EXT_WILDCARD] = () | ||
|
||
try: | ||
# Try resolving writer for fake unsupported extension with error flag | ||
writers = resolve_writer(ext, error_if_not_found=True) | ||
except OptionalImportError as e: | ||
# Catch and print the enhanced OptionalImportError with package hints | ||
print("Caught OptionalImportError:", e) | ||
finally: | ||
# Restore the fallback writers to avoid side effects on other tests | ||
SUPPORTED_WRITERS[EXT_WILDCARD] = (ITKWriter,) | ||
|
||
print(f"After restoring fallback writers: {SUPPORTED_WRITERS.get(EXT_WILDCARD)}") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.