Skip to content

Make InMemImageReader work even when monai is not used/available #169

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

Merged
merged 1 commit into from
Jan 15, 2022

Conversation

gigony
Copy link
Collaborator

@gigony gigony commented Oct 9, 2021

If the user's application doesn't depend on monai and monai is not installed, it causes an error when the following statement is executed by the interpreter.

This patch sets ImageReader to object if monai library is not available so the user's app doesn't require monai app if not using.

Signed-off-by: Gigon Bae <gbae@nvidia.com>
@gigony gigony added the bug Something isn't working label Oct 9, 2021
@gigony gigony requested a review from MMelQin October 9, 2021 18:14
@gigony gigony self-assigned this Oct 9, 2021
Copy link
Collaborator

@MMelQin MMelQin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The InMemImageReader is a derived class of MONAI ImageReader, hence dependency on MONAI be present.

This PR is wrong trying to break this dependency at runtime, and should be rejected.

@gigony
Copy link
Collaborator Author

gigony commented Oct 9, 2021

The InMemImageReader is a derived class of MONAI ImageReader, hence dependency on MONAI be present.

This PR is wrong trying to break this dependency at runtime, and should be rejected.

@MMelQin , existing code caused an error even when user's application doesn't use monai.

I faced the issue somehow and
I think you can reproduce it with simple_imaging_app in a fresh python virtual environment.

Let me also double check it in case the PR cause the side effect you described.

Thank you!

@MMelQin
Copy link
Collaborator

MMelQin commented Oct 9, 2021

The example you mentioned should not be loading the monai_seg_inference_operator classes at all, where the InMemImageReader is. So puzzled by the error you saw, while setting the reader to object in the seg operator is not the way to address the issue, even if it can help to avoid the symptom (optional_import was already used in the code).

@MMelQin MMelQin merged commit 7dd08bd into main Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants