File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,17 +122,20 @@ def UploadModel(self,
122122 ) -> drucker_pb2 .ModelResponse :
123123 """ Upload your latest ML model.
124124 """
125- save_path = None
125+ first_req = next (request_iterator )
126+ save_path = first_req .path
127+ if not self .is_valid_upload_filename (save_path ):
128+ raise Exception (f'Error: Invalid model path specified -> { save_path } ' )
129+
126130 tmp_path = self .app .get_model_path (uuid .uuid4 ().hex )
127131 Path (tmp_path ).parent .mkdir (parents = True , exist_ok = True )
128132 with open (tmp_path , 'wb' ) as f :
133+ f .write (first_req .data )
129134 for request in request_iterator :
130- save_path = request .path
131- model_data = request .data
132- f .write (model_data )
135+ f .write (request .data )
136+ del first_req
133137 f .close ()
134- if not self .is_valid_upload_filename (save_path ):
135- raise Exception (f'Error: Invalid model path specified -> { save_path } ' )
138+
136139 model_path = self .app .get_model_path (save_path )
137140 Path (model_path ).parent .mkdir (parents = True , exist_ok = True )
138141 shutil .move (tmp_path , model_path )
You can’t perform that action at this time.
0 commit comments