mirror of
https://github.com/open-mmlab/mim.git
synced 2025-06-03 14:59:11 +08:00
[Enhancement] Remove commitid (#21)
* [Enhancement] Remove redundant commit_id.py * remove get_commitid function
This commit is contained in:
parent
210e55fb48
commit
55096d02f3
@ -1,6 +1,5 @@
|
||||
import os
|
||||
import os.path as osp
|
||||
import subprocess
|
||||
import tempfile
|
||||
from distutils.dir_util import copy_tree
|
||||
from distutils.file_util import copy_file
|
||||
@ -395,17 +394,6 @@ def install_from_repo(repo_root: str,
|
||||
|
||||
call_command(dep_cmd)
|
||||
|
||||
# write commit id to package
|
||||
current_root = os.getcwd()
|
||||
os.chdir(repo_root) # change work dir to repo_root
|
||||
commit_id = subprocess.check_output(
|
||||
['git', 'rev-parse', '--short', 'HEAD'])
|
||||
os.chdir(current_root)
|
||||
commit_id = str(commit_id, 'UTF-8').strip() # type: ignore
|
||||
commit_id_path = os.path.join(pkg_root, 'commit_id.py')
|
||||
with open(commit_id_path, 'w') as fw:
|
||||
fw.write(f'commit_id = "{commit_id}"') # type: ignore
|
||||
|
||||
install_cmd = ['python', '-m', 'pip', 'install', repo_root]
|
||||
if is_user_dir:
|
||||
install_cmd.append('--user')
|
||||
|
@ -15,11 +15,9 @@ from pandas import DataFrame
|
||||
from mim.click import OptionEatAll, get_downstream_package, param2lowercase
|
||||
from mim.utils import (
|
||||
DEFAULT_CACHE_DIR,
|
||||
PKG2MODULE,
|
||||
PKG2PROJECT,
|
||||
cast2lowercase,
|
||||
echo_success,
|
||||
get_commit_id,
|
||||
get_github_url,
|
||||
get_installed_version,
|
||||
highlighted_error,
|
||||
@ -218,20 +216,10 @@ def load_metadata_from_local(package: str):
|
||||
"""
|
||||
if is_installed(package):
|
||||
version = get_installed_version(package)
|
||||
commit_id = get_commit_id(package)
|
||||
click.echo(f'local verison: {version}')
|
||||
|
||||
pkl_path = osp.join(DEFAULT_CACHE_DIR, f'{package}-{commit_id}.pkl')
|
||||
if osp.exists(pkl_path):
|
||||
with open(pkl_path, 'rb') as fr:
|
||||
metadata = pickle.load(fr)
|
||||
else:
|
||||
module_name = PKG2MODULE.get(package, package)
|
||||
metadata_path = resource_filename(module_name, 'model_zoo.yml')
|
||||
metadata = load(metadata_path)
|
||||
|
||||
with open(pkl_path, 'wb') as fw:
|
||||
pickle.dump(metadata, fw)
|
||||
metadata_path = resource_filename(package, 'model_zoo.yml')
|
||||
metadata = load(metadata_path)
|
||||
|
||||
return metadata
|
||||
else:
|
||||
|
@ -20,7 +20,6 @@ from .utils import (
|
||||
echo_warning,
|
||||
exit_with_error,
|
||||
extract_tar,
|
||||
get_commit_id,
|
||||
get_config,
|
||||
get_content_from_url,
|
||||
get_github_url,
|
||||
@ -71,7 +70,6 @@ __all__ = [
|
||||
'WHEEL_URL',
|
||||
'split_package_version',
|
||||
'call_command',
|
||||
'get_commit_id',
|
||||
'is_version_equal',
|
||||
'MMPACKAGE_PATH',
|
||||
'get_package_version',
|
||||
|
@ -222,17 +222,6 @@ def is_version_equal(version1: str, version2: str) -> bool:
|
||||
return LooseVersion(version1) == LooseVersion(version2)
|
||||
|
||||
|
||||
def get_commit_id(package: str) -> str:
|
||||
"""Get commit id from package.
|
||||
|
||||
Args:
|
||||
package (str): Name of package.
|
||||
"""
|
||||
module_name = PKG2MODULE.get(package, package)
|
||||
module = importlib.import_module('..commit_id', f'{module_name}.subpkg')
|
||||
return module.commit_id # type: ignore
|
||||
|
||||
|
||||
def get_installed_path(package: str) -> str:
|
||||
"""Get installed path of package.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user