@@ -24,6 +24,7 @@ def download_metadata_only(
2424 repo_id : str ,
2525 cache_dir : Optional [str ] = None ,
2626 force_download : bool = False ,
27+ local_files_only : bool = False ,
2728) -> Path :
2829 # If a local path is provided, return it directly without contacting HF Hub
2930 local_path = Path (repo_id )
@@ -35,6 +36,7 @@ def download_metadata_only(
3536 cache_dir = cache_dir ,
3637 ignore_patterns = EXCLUDE_WEIGHT_PATTERNS ,
3738 force_download = force_download ,
39+ local_files_only = local_files_only ,
3840 )
3941 return Path (path )
4042
@@ -45,6 +47,7 @@ def selective_model_download(
4547 end_layer : Optional [int ] = None ,
4648 cache_dir : Optional [str ] = None ,
4749 force_download : bool = False ,
50+ local_files_only : bool = False ,
4851) -> Path :
4952 # Handle local model directory
5053 local_path = Path (repo_id )
@@ -58,6 +61,7 @@ def selective_model_download(
5861 repo_id = repo_id ,
5962 cache_dir = cache_dir ,
6063 force_download = force_download ,
64+ local_files_only = local_files_only ,
6165 )
6266 logger .debug (f"Downloaded model metadata to { model_path } " )
6367 is_remote = True
@@ -78,6 +82,7 @@ def selective_model_download(
7882 repo_id = repo_id ,
7983 cache_dir = cache_dir ,
8084 force_download = force_download ,
85+ local_files_only = local_files_only ,
8186 )
8287 else :
8388 # Step 3: Download only the needed weight files
@@ -90,6 +95,7 @@ def selective_model_download(
9095 filename = weight_file ,
9196 cache_dir = cache_dir ,
9297 force_download = force_download ,
98+ local_files_only = local_files_only ,
9399 )
94100
95101 logger .debug (f"Downloaded weight files for layers [{ start_layer } , { end_layer } )" )
@@ -104,6 +110,7 @@ def selective_model_download(
104110 repo_id = repo_id ,
105111 cache_dir = cache_dir ,
106112 force_download = force_download ,
113+ local_files_only = local_files_only ,
107114 )
108115 else :
109116 logger .debug ("No layer range specified and using local path; nothing to download" )
@@ -115,9 +122,11 @@ def get_model_path_with_selective_download(
115122 model_path_or_repo : str ,
116123 start_layer : Optional [int ] = None ,
117124 end_layer : Optional [int ] = None ,
125+ local_files_only : bool = False ,
118126) -> Path :
119127 return selective_model_download (
120128 repo_id = model_path_or_repo ,
121129 start_layer = start_layer ,
122130 end_layer = end_layer ,
131+ local_files_only = local_files_only ,
123132 )
0 commit comments