File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
tests/integrations/huggingface_hub Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -1757,7 +1757,8 @@ def _generate_installed_modules():
17571757
17581758def _normalize_module_name (name ):
17591759 # type: (str) -> str
1760- return name .lower ()
1760+ # https://peps.python.org/pep-0503/#normalized-names
1761+ return re .sub (r"[-_.]+" , "-" , name ).lower ()
17611762
17621763
17631764def _get_installed_modules ():
@@ -1770,8 +1771,10 @@ def _get_installed_modules():
17701771
17711772def package_version (package ):
17721773 # type: (str) -> Optional[Tuple[int, ...]]
1774+ normalized_package = _normalize_module_name (package )
1775+
17731776 installed_packages = _get_installed_modules ()
1774- version = installed_packages .get (package )
1777+ version = installed_packages .get (normalized_package )
17751778 if version is None :
17761779 return None
17771780
Original file line number Diff line number Diff line change 2222 from typing import Any
2323
2424
25- HF_VERSION = package_version ("huggingface-hub" ) or package_version ( "huggingface_hub" )
25+ HF_VERSION = package_version ("huggingface-hub" )
2626
2727if HF_VERSION and HF_VERSION < (0 , 30 , 0 ):
2828 MODEL_ENDPOINT = "https://api-inference.huggingface.co/models/{model_name}"
You can’t perform that action at this time.
0 commit comments