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 @@ -116,7 +116,14 @@ def list_repo_files(
116116 token : Union [str , bool , None ] = None ,
117117) -> list [str ]:
118118
119- def lookup_files ():
119+ def lookup_files () -> list [str ]:
120+ # directly list files if model is local
121+ if (local_path := Path (repo_id )).exists ():
122+ return [
123+ str (file .relative_to (local_path ))
124+ for file in local_path .rglob ('*' ) if file .is_file ()
125+ ]
126+ # if model is remote, use hf_hub api to list files
120127 try :
121128 if VLLM_USE_MODELSCOPE :
122129 from vllm .transformers_utils .utils import (
@@ -156,8 +163,8 @@ def file_exists(
156163# In offline mode the result can be a false negative
157164def file_or_path_exists (model : Union [str , Path ], config_name : str ,
158165 revision : Optional [str ]) -> bool :
159- if Path (model ).exists ():
160- return (Path ( model ) / config_name ).is_file ()
166+ if ( local_path := Path (model ) ).exists ():
167+ return (local_path / config_name ).is_file ()
161168
162169 # Offline mode support: Check if config file is cached already
163170 cached_filepath = try_to_load_from_cache (repo_id = model ,
You can’t perform that action at this time.
0 commit comments