diff --git a/modelscope/hub/api.py b/modelscope/hub/api.py index 16440235..e3ec5ad0 100644 --- a/modelscope/hub/api.py +++ b/modelscope/hub/api.py @@ -11,6 +11,7 @@ import re import shutil import tempfile import uuid +import warnings from collections import defaultdict from http import HTTPStatus from http.cookiejar import CookieJar @@ -422,6 +423,12 @@ class HubApi: original_model_id: Optional[str] = None, ignore_file_pattern: Optional[Union[List[str], str]] = None, lfs_suffix: Optional[Union[str, List[str]]] = None): + warnings.warn( + 'This function is deprecated and will be removed in future versions. ' + 'Please use git command directly or use HubApi().upload_folder instead', + DeprecationWarning, + stacklevel=2 + ) """Upload model from a given directory to given repository. A valid model directory must contain a configuration.json file. diff --git a/modelscope/hub/repository.py b/modelscope/hub/repository.py index 7cf32116..6519d8ea 100644 --- a/modelscope/hub/repository.py +++ b/modelscope/hub/repository.py @@ -1,6 +1,7 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import os +import warnings from typing import Optional from modelscope.hub.errors import GitError, InvalidParameter, NotLoginException @@ -113,6 +114,11 @@ class Repository: local_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION, remote_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION, force: Optional[bool] = False): + warnings.warn( + 'This function is deprecated and will be removed in future versions. ' + 'Please use git command directly or use HubApi().upload_folder instead', + DeprecationWarning, + stacklevel=2) """Push local files to remote, this method will do. Execute git pull, git add, git commit, git push in order. @@ -261,6 +267,11 @@ class DatasetRepository: commit_message: str, branch: Optional[str] = DEFAULT_DATASET_REVISION, force: Optional[bool] = False): + warnings.warn( + 'This function is deprecated and will be removed in future versions. ' + 'Please use git command directly or use HubApi().upload_folder instead', + DeprecationWarning, + stacklevel=2) """Push local files to remote, this method will do. git pull git add diff --git a/modelscope/hub/utils/utils.py b/modelscope/hub/utils/utils.py index 2cb1bb33..2527873a 100644 --- a/modelscope/hub/utils/utils.py +++ b/modelscope/hub/utils/utils.py @@ -2,6 +2,7 @@ import hashlib import os +import sys from datetime import datetime from pathlib import Path from typing import List, Optional, Union @@ -64,7 +65,10 @@ def convert_patterns(raw_input: Union[str, List[str]]): # during model download, the '.' would be converted to '___' to produce # actual physical (masked) directory for storage def get_model_masked_directory(directory, model_id): - parts = directory.rsplit('/', 2) + if sys.platform.startswith('win'): + parts = directory.rsplit('\\', 2) + else: + parts = directory.rsplit('/', 2) # this is the actual directory the model files are located. masked_directory = os.path.join(parts[0], model_id.replace('.', '___')) return masked_directory