File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,14 @@ def list_repo_files(
115
115
token : Union [str , bool , None ] = None ,
116
116
) -> list [str ]:
117
117
118
- def lookup_files ():
118
+ def lookup_files () -> list [str ]:
119
+ # directly list files if model is local
120
+ if (local_path := Path (repo_id )).exists ():
121
+ return [
122
+ str (file .relative_to (local_path ))
123
+ for file in local_path .rglob ('*' ) if file .is_file ()
124
+ ]
125
+ # if model is remote, use hf_hub api to list files
119
126
try :
120
127
if VLLM_USE_MODELSCOPE :
121
128
from vllm .transformers_utils .utils import (
@@ -154,8 +161,8 @@ def file_exists(
154
161
# In offline mode the result can be a false negative
155
162
def file_or_path_exists (model : Union [str , Path ], config_name : str ,
156
163
revision : Optional [str ]) -> bool :
157
- if Path (model ).exists ():
158
- return (Path ( model ) / config_name ).is_file ()
164
+ if ( local_path := Path (model ) ).exists ():
165
+ return (local_path / config_name ).is_file ()
159
166
160
167
# Offline mode support: Check if config file is cached already
161
168
cached_filepath = try_to_load_from_cache (repo_id = model ,
You can’t perform that action at this time.
0 commit comments