fix windows path

This commit is contained in:
Yingda Chen
2025-03-25 21:06:49 +08:00
parent b2244f38b4
commit a99ade99de
3 changed files with 23 additions and 1 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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