Skip to content

1960 Remove warning message if no __version__ property #1962

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 5 commits into from
Apr 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions monai/utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ def min_version(the_module, min_version_str: str = "") -> bool:
Returns True if the module's version is greater or equal to the 'min_version'.
When min_version_str is not provided, it always returns True.
"""
if not min_version_str:
if not min_version_str or not hasattr(the_module, "__version__"):
return True # always valid version
if not hasattr(the_module, "__version__"):
warnings.warn(f"{the_module} has no attribute __version__ in min_version check.")
return True # min_version is the default, shouldn't be noisy

mod_version = tuple(int(x) for x in the_module.__version__.split(".")[:2])
required = tuple(int(x) for x in min_version_str.split(".")[:2])
return mod_version >= required
Expand Down