[Fix] Fix missing package directory error (#72)

* [Fix] Fix missing package directory error

* fix grammar

* fix comment

* fix comment

* remove a comment for debug
pull/78/head
Zaida Zhou 2021-07-28 20:09:44 +08:00 committed by GitHub
parent d70f9cf14b
commit 9fe8a75cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -52,7 +52,20 @@ def list_package(all: bool = False) -> List[Tuple[str, ...]]:
if not home_page:
home_page = pkg.location
installed_path = get_installed_path(pkg_name)
if pkg_name.startswith('mmcv'):
pkgs_info.append((pkg_name, pkg.version, home_page))
continue
try:
# `installed_path` of some packages can not be obtained like
# threadpoolctl. We can ignore those packages because
# `mim list` only need to list those packages that have
# model-index.yml or model_zoo.yml file.
# more datails at https://github.com/open-mmlab/mim/issues/71
installed_path = get_installed_path(pkg_name)
except Exception:
continue
# rename the model_zoo.yml to model-index.yml but support both
# of them for backward compatibility. In addition, model-index.yml
# will be put in package/.mim in PR #68
@ -62,7 +75,10 @@ def list_package(all: bool = False) -> List[Tuple[str, ...]]:
osp.join(installed_path, '.mim', 'model_zoo.yml'),
osp.join(installed_path, 'model_zoo.yml')
]
if pkg_name.startswith('mmcv') or any(
map(osp.exists, possible_metadata_paths)):
pkgs_info.append((pkg_name, pkg.version, home_page))
for path in possible_metadata_paths:
if osp.exists(path):
pkgs_info.append((pkg_name, pkg.version, home_page))
break
pkgs_info.sort(key=lambda pkg_info: pkg_info[0])
return pkgs_info

View File

@ -84,7 +84,7 @@ def parse_home_page(package: str) -> Optional[str]:
"""Parse home page from package metadata.
Args:
pakcage (str): Package to parse home page.
package (str): Package to parse home page.
"""
home_page = None
pkg = get_distribution(package)