@@ -75,6 +75,35 @@ def extract_model_identifiers(self):
7575
7676 return model_name , model_tag , model_organization
7777
78+ def _assemble_split_file_list (self , snapshot_hash : str ) -> list [SnapshotFile ]:
79+ files : list [SnapshotFile ] = []
80+
81+ # model is split, lets fetch all files based on the name pattern
82+ match = re .match (SPLIT_MODEL_PATH_RE , self .model )
83+ if match is None :
84+ return files
85+
86+ path_part = match [1 ]
87+ filename_base = match [2 ]
88+ total_parts = int (match [3 ])
89+
90+ for i in range (1 , total_parts + 1 ):
91+ file_name = f"{ filename_base } -{ i :05d} -of-{ total_parts :05d} .gguf"
92+ url = f"{ self .type } ://{ path_part } /{ file_name } "
93+ files .append (
94+ SnapshotFile (
95+ url = url ,
96+ header = {},
97+ hash = snapshot_hash ,
98+ type = SnapshotFileType .Model ,
99+ name = file_name ,
100+ should_show_progress = True ,
101+ required = True ,
102+ )
103+ )
104+
105+ return files
106+
78107 def pull (self , _ ):
79108 name , tag , _ = self .extract_model_identifiers ()
80109 _ , _ , all_files = self .model_store .get_cached_files (tag )
@@ -96,40 +125,21 @@ def pull(self, _):
96125 self .model_store .new_snapshot (tag , snapshot_hash , files )
97126 return
98127
99- if not is_split_file_model (self .model ):
100- files .append (
101- SnapshotFile (
102- url = f"{ self .type } ://{ self .model } " ,
103- header = {},
104- hash = snapshot_hash ,
105- type = SnapshotFileType .Model ,
106- name = name ,
107- should_show_progress = True ,
108- required = True ,
109- )
110- )
128+ if is_split_file_model (self .model ):
129+ files = self ._assemble_split_file_list (snapshot_hash )
111130 self .model_store .new_snapshot (tag , snapshot_hash , files )
112131 return
113132
114- # model is split, lets fetch all files based on the name pattern
115- match = re .match (SPLIT_MODEL_PATH_RE , self .model )
116- path_part = match [1 ]
117- filename_base = match [2 ]
118- total_parts = int (match [3 ])
119-
120- for i in range (total_parts - 1 ):
121- i_off = i + 2
122- url = f"{ self .type } ://{ path_part } /{ filename_base } -{ i_off :05d} -of-{ total_parts :05d} .gguf"
123- files .append (
124- SnapshotFile (
125- url = url ,
126- header = {},
127- hash = snapshot_hash ,
128- type = SnapshotFileType .Model ,
129- name = name ,
130- should_show_progress = True ,
131- required = True ,
132- )
133+ files .append (
134+ SnapshotFile (
135+ url = f"{ self .type } ://{ self .model } " ,
136+ header = {},
137+ hash = snapshot_hash ,
138+ type = SnapshotFileType .Model ,
139+ name = name ,
140+ should_show_progress = True ,
141+ required = True ,
133142 )
134-
143+ )
135144 self .model_store .new_snapshot (tag , snapshot_hash , files )
145+ return
0 commit comments