[Bugfix] Fix VLLM_USE_MODELSCOPE issue (#13384)

This commit is contained in:
r.4ntix
2025-02-17 14:22:01 +00:00
committed by GitHub
parent 30513d1cb6
commit ce77eb9410
2 changed files with 32 additions and 7 deletions
+20 -1
View File
@@ -2,7 +2,7 @@
from os import PathLike
from pathlib import Path
from typing import Union
from typing import List, Optional, Union
def is_s3(model_or_path: str) -> bool:
@@ -20,3 +20,22 @@ def check_gguf_file(model: Union[str, PathLike]) -> bool:
with open(model, "rb") as f:
header = f.read(4)
return header == b"GGUF"
def modelscope_list_repo_files(
repo_id: str,
revision: Optional[str] = None,
token: Union[str, bool, None] = None,
) -> List[str]:
"""List files in a modelscope repo."""
from modelscope.hub.api import HubApi
from modelscope.utils.hf_util import _try_login
_try_login(token)
api = HubApi()
# same as huggingface_hub.list_repo_files
files = [
file['Path'] for file in api.get_model_files(
model_id=repo_id, revision=revision, recursive=True)
if file['Type'] == 'blob'
]
return files