Skip to content

Commit 6c1bcb6

Browse files
committed
change name to _package_map
1 parent 9566140 commit 6c1bcb6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/diffusers/utils/import_utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
else:
3838
import importlib.metadata as importlib_metadata
3939
try:
40-
package_map = importlib_metadata.packages_distributions() # load-once to avoid expensive calls
40+
_package_map = importlib_metadata.packages_distributions() # load-once to avoid expensive calls
4141
except Exception:
42-
package_map = None
42+
_package_map = None
4343

4444
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
4545

@@ -59,13 +59,13 @@
5959

6060

6161
def _is_package_available(pkg_name: str, get_dist_name: bool = False) -> Tuple[bool, str]:
62-
global package_map
62+
global _package_map
6363
pkg_exists = importlib.util.find_spec(pkg_name) is not None
6464
pkg_version = "N/A"
6565

6666
if pkg_exists:
67-
if package_map is None:
68-
package_map = defaultdict(list)
67+
if _package_map is None:
68+
_package_map = defaultdict(list)
6969
try:
7070
# Fallback for Python < 3.10
7171
for dist in importlib_metadata.distributions():
@@ -75,16 +75,16 @@ def _is_package_available(pkg_name: str, get_dist_name: bool = False) -> Tuple[b
7575
} - {None}
7676
_top_level_inferred = filter(lambda name: "." not in name, _infered_opt_names)
7777
for pkg in _top_level_declared or _top_level_inferred:
78-
package_map[pkg].append(dist.metadata["Name"])
78+
_package_map[pkg].append(dist.metadata["Name"])
7979
except Exception as _:
8080
pass
8181
try:
82-
if get_dist_name and pkg_name in package_map and package_map[pkg_name]:
83-
if len(package_map[pkg_name]) > 1:
82+
if get_dist_name and pkg_name in _package_map and _package_map[pkg_name]:
83+
if len(_package_map[pkg_name]) > 1:
8484
logger.warning(
85-
f"Multiple distributions found for package {pkg_name}. Picked distribution: {package_map[pkg_name][0]}"
85+
f"Multiple distributions found for package {pkg_name}. Picked distribution: {_package_map[pkg_name][0]}"
8686
)
87-
pkg_name = package_map[pkg_name][0]
87+
pkg_name = _package_map[pkg_name][0]
8888
pkg_version = importlib_metadata.version(pkg_name)
8989
logger.debug(f"Successfully imported {pkg_name} version {pkg_version}")
9090
except (ImportError, importlib_metadata.PackageNotFoundError):

0 commit comments

Comments
 (0)