From e0c4d21e6388c59eafea188d3188c995a417c97b Mon Sep 17 00:00:00 2001 From: Kelvin R Date: Sat, 27 Jul 2024 10:37:51 -0700 Subject: [PATCH] Fixing imports Signed-off-by Kelvin R --- monai/utils/module.py | 16 ++++++++-------- setup.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/monai/utils/module.py b/monai/utils/module.py index 747d3a17b9..a2b1a11921 100644 --- a/monai/utils/module.py +++ b/monai/utils/module.py @@ -29,8 +29,8 @@ from typing import Any, Iterable, cast import torch -import importlib.metadata - +## import importlib.metadata +## from packaging import version # bundle config system flags # set MONAI_EVAL_EXPR=1 to use 'eval', default value: run_eval=True @@ -74,10 +74,10 @@ def look_up_option( Raise a value error possibly with a guess of the closest match. Args: - opt_str: The option string or Enum to look up. + opt_str: The option string or Enum to look up. supported: The collection of supported options, it can be list, tuple, set, dict, or Enum. default: If it is given, this method will return `default` when `opt_str` is not found, - instead of raising a `ValueError`. Otherwise, it defaults to `"no_default"`, + instead of raising a `ValueError`. Otherwise, it defaults to `"no_default"`, so that the method may raise a `ValueError`. print_all_options: whether to print all available options when `opt_str` is not found. Defaults to True @@ -566,10 +566,10 @@ def version_leq(lhs: str, rhs: str) -> bool: """ lhs, rhs = str(lhs), str(rhs) - pkging, has_ver = optional_import("packaging") + has_ver = optional_import("packaging") if has_ver: try: - return cast(bool, pkging.version.Version(lhs) <= pkging.version.Version(rhs)) + return cast(bool, version(lhs) <= version(rhs)) except version.InvalidVersion: return True @@ -593,10 +593,10 @@ def version_geq(lhs: str, rhs: str) -> bool: """ lhs, rhs = str(lhs), str(rhs) - pkging, has_ver = optional_import("packaging") + has_ver = optional_import("packaging") if has_ver: try: - return cast(bool, pkging.version.Version(lhs) >= pkging.version.Version(rhs)) + return cast(bool, version(lhs) >= version(rhs)) except version.InvalidVersion: return True diff --git a/setup.py b/setup.py index 576743c1f7..67a5b00933 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ import versioneer -# TODO: debug mode -g -O0, compile test cases +# TODO: debug mode -g -O0, compile test cases RUN_BUILD = os.getenv("BUILD_MONAI", "0") == "1" FORCE_CUDA = os.getenv("FORCE_CUDA", "0") == "1" # flag ignored if BUILD_MONAI is False