mirror of
https://github.com/modelscope/modelscope.git
synced 2026-02-24 20:19:51 +01:00
[to #42322933]compatible with windows path on only core parts
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9855254
This commit is contained in:
committed by
Yingda Chen
parent
e875129286
commit
ec7cc9a73f
@@ -1,3 +1,5 @@
|
||||
from pathlib import Path
|
||||
|
||||
MODELSCOPE_URL_SCHEME = 'http://'
|
||||
DEFAULT_MODELSCOPE_DOMAIN = 'www.modelscope.cn'
|
||||
DEFAULT_MODELSCOPE_DATA_ENDPOINT = MODELSCOPE_URL_SCHEME + DEFAULT_MODELSCOPE_DOMAIN
|
||||
@@ -6,7 +8,7 @@ DEFAULT_MODELSCOPE_GROUP = 'damo'
|
||||
MODEL_ID_SEPARATOR = '/'
|
||||
FILE_HASH = 'Sha256'
|
||||
LOGGER_NAME = 'ModelScopeHub'
|
||||
DEFAULT_CREDENTIALS_PATH = '~/.modelscope/credentials'
|
||||
DEFAULT_CREDENTIALS_PATH = Path.home().joinpath('.modelscope', 'credentials')
|
||||
API_RESPONSE_FIELD_DATA = 'Data'
|
||||
API_RESPONSE_FIELD_GIT_ACCESS_TOKEN = 'AccessToken'
|
||||
API_RESPONSE_FIELD_USERNAME = 'Username'
|
||||
|
||||
@@ -4,9 +4,9 @@ from pathlib import Path
|
||||
# Cache location
|
||||
from modelscope.hub.constants import DEFAULT_MODELSCOPE_DATA_ENDPOINT
|
||||
|
||||
DEFAULT_CACHE_HOME = '~/.cache'
|
||||
DEFAULT_CACHE_HOME = Path.home().joinpath('.cache')
|
||||
CACHE_HOME = os.getenv('CACHE_HOME', DEFAULT_CACHE_HOME)
|
||||
DEFAULT_MS_CACHE_HOME = os.path.join(CACHE_HOME, 'modelscope/hub')
|
||||
DEFAULT_MS_CACHE_HOME = os.path.join(CACHE_HOME, 'modelscope', 'hub')
|
||||
MS_CACHE_HOME = os.path.expanduser(
|
||||
os.getenv('MS_CACHE_HOME', DEFAULT_MS_CACHE_HOME))
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import os.path as osp
|
||||
import time
|
||||
import traceback
|
||||
from functools import reduce
|
||||
from pathlib import Path
|
||||
from typing import Generator, Union
|
||||
|
||||
import gast
|
||||
@@ -24,9 +25,10 @@ from modelscope.utils.registry import default_group
|
||||
|
||||
logger = get_logger()
|
||||
storage = LocalStorage()
|
||||
p = Path(__file__)
|
||||
|
||||
# get the path of package 'modelscope'
|
||||
MODELSCOPE_PATH = '/'.join(os.path.dirname(__file__).split('/')[:-1])
|
||||
MODELSCOPE_PATH = p.resolve().parents[1]
|
||||
REGISTER_MODULE = 'register_module'
|
||||
IGNORED_PACKAGES = ['modelscope', '.']
|
||||
SCAN_SUB_FOLDERS = [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright (c) Alibaba, Inc. and its affiliates.
|
||||
|
||||
import inspect
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# TODO: remove this api, unify to flattened args
|
||||
@@ -33,6 +33,5 @@ def get_default_cache_dir():
|
||||
"""
|
||||
default base dir: '~/.cache/modelscope'
|
||||
"""
|
||||
default_cache_dir = os.path.expanduser(
|
||||
os.path.join('~/.cache', 'modelscope'))
|
||||
default_cache_dir = Path.home().joinpath('.cache', 'modelscope')
|
||||
return default_cache_dir
|
||||
|
||||
@@ -10,6 +10,7 @@ from collections import OrderedDict
|
||||
from functools import wraps
|
||||
from importlib import import_module
|
||||
from itertools import chain
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Any
|
||||
|
||||
@@ -43,7 +44,7 @@ def import_modules_from_file(py_file: str):
|
||||
"""
|
||||
dirname, basefile = os.path.split(py_file)
|
||||
if dirname == '':
|
||||
dirname == './'
|
||||
dirname = Path.cwd()
|
||||
module_name = osp.splitext(basefile)[0]
|
||||
sys.path.insert(0, dirname)
|
||||
validate_py_syntax(py_file)
|
||||
|
||||
@@ -5,13 +5,13 @@ import shutil
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import gast
|
||||
from pathlib import Path
|
||||
|
||||
from modelscope.utils.ast_utils import AstScaning, FilesAstScaning, load_index
|
||||
|
||||
MODELSCOPE_PATH = '/'.join(
|
||||
os.path.dirname(__file__).split('/')[:-2]) + '/modelscope'
|
||||
p = Path(__file__)
|
||||
|
||||
MODELSCOPE_PATH = p.resolve().parents[2].joinpath('modelscope')
|
||||
|
||||
|
||||
class AstScaningTest(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user