MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / get_package_version

Function get_package_version

monai/utils/module.py:493–500  ·  view source on GitHub ↗

Try to load package and get version. If not found, return `default`.

(dep_name, default="NOT INSTALLED or UNKNOWN VERSION.")

Source from the content-addressed store, hash-verified

491
492
493def get_package_version(dep_name, default="NOT INSTALLED or UNKNOWN VERSION."):
494 """
495 Try to load package and get version. If not found, return `default`.
496 """
497 dep, has_dep = optional_import(dep_name)
498 if has_dep and hasattr(dep, "__version__"):
499 return dep.__version__
500 return default
501
502
503@functools.lru_cache(None)

Callers 7

__init__Method · 0.90
test_defaultMethod · 0.90
test_msgMethod · 0.90
_get_directory_storeMethod · 0.90

Calls 1

optional_importFunction · 0.85

Tested by 4

test_defaultMethod · 0.72
test_msgMethod · 0.72
_get_directory_storeMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…