clean directory structure

This commit is contained in:
Yingda Chen
2025-01-21 21:44:37 +08:00
parent 2c9ec4ff2d
commit 9646f6b912
2 changed files with 6 additions and 9 deletions

View File

@@ -22,6 +22,7 @@ from modelscope.utils.constant import (DEFAULT_DATASET_REVISION,
DEFAULT_REPOSITORY_REVISION,
REPO_TYPE_DATASET, REPO_TYPE_MODEL,
REPO_TYPE_SUPPORT)
from modelscope.utils.file_utils import get_default_modelscope_cache_dir
from modelscope.utils.logger import get_logger
from modelscope.utils.thread_utils import thread_executor
@@ -223,9 +224,8 @@ def _snapshot_download(
temporary_cache_dir, cache = create_temporary_directory_and_cache(
repo_id, local_dir=local_dir, cache_dir=cache_dir, repo_type=repo_type)
system_cache = cache_dir if cache_dir is not None else os.getenv(
'MODELSCOPE_CACHE',
Path.home().joinpath('.cache', 'modelscope', 'hub'))
system_cache = cache_dir if cache_dir is not None else get_default_modelscope_cache_dir(
)
if local_files_only:
if len(cache.cached_files) == 0:
raise ValueError(

View File

@@ -37,7 +37,7 @@ def get_default_modelscope_cache_dir():
"""
default base dir: '~/.cache/modelscope'
"""
default_cache_dir = Path.home().joinpath('.cache', 'modelscope')
default_cache_dir = Path.home().joinpath('.cache', 'modelscope', 'hub')
return default_cache_dir
@@ -57,7 +57,7 @@ def get_model_cache_root() -> str:
Returns:
str: the modelscope model cache root.
"""
return os.path.join(get_modelscope_cache_dir(), 'hub')
return os.path.join(get_modelscope_cache_dir(), 'models')
def get_dataset_cache_root() -> str:
@@ -68,10 +68,7 @@ def get_dataset_cache_root() -> str:
Returns:
str: the modelscope dataset raw file cache root.
"""
if os.getenv('MODELSCOPE_CACHE'):
return os.path.join(get_modelscope_cache_dir(), 'datasets')
else:
return os.path.join(get_modelscope_cache_dir(), 'hub', 'datasets')
return os.path.join(get_modelscope_cache_dir(), 'datasets')
def get_dataset_cache_dir(dataset_id: str) -> str: