|
| 1 | +# |
| 2 | +# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved. |
| 3 | +# This file is a part of the vllm-ascend project. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +from typing import List, Optional, Union |
| 19 | + |
| 20 | +import vllm |
| 21 | + |
| 22 | + |
| 23 | +def modelscope_list_repo_files_patch( |
| 24 | + repo_id: str, |
| 25 | + revision: Optional[str] = None, |
| 26 | + token: Union[str, bool, None] = None, |
| 27 | +) -> List[str]: |
| 28 | + """List files in a modelscope repo.""" |
| 29 | + from modelscope.hub.api import HubApi # type: ignore |
| 30 | + api = HubApi() |
| 31 | + api.login(token) |
| 32 | + # same as huggingface_hub.list_repo_files |
| 33 | + files = [ |
| 34 | + file['Path'] for file in api.get_model_files( |
| 35 | + model_id=repo_id, revision=revision, recursive=True) |
| 36 | + if file['Type'] == 'blob' |
| 37 | + ] |
| 38 | + return files |
| 39 | + |
| 40 | + |
| 41 | +# NOTE: this patch should only be included in v0.7.3. It has been fixed in |
| 42 | +# https://github.com/vllm-project/vllm/pull/13807 |
| 43 | +vllm.transformers_utils.utils.modelscope_list_repo_files = \ |
| 44 | + modelscope_list_repo_files_patch |
0 commit comments