@@ -265,6 +265,62 @@ def inference(self,
265265 # Silently ignore if metadata file doesn't exist or can't be read
266266 pass
267267
268+ # Update global batch counter and show progress every 5 batches
269+ if calibration_done :
270+ try :
271+ # Get eta_metadata file path
272+ if 'predictions' in output_json_filepath :
273+ work_dir_path = output_json_filepath .split ('predictions' )[0 ].rstrip ('/' )
274+ else :
275+ work_dir_path = os .path .dirname (os .path .dirname (output_json_filepath ))
276+ eta_metadata_file = os .path .join (work_dir_path , 'tmp' , 'eta_metadata.json' )
277+
278+ if os .path .exists (eta_metadata_file ):
279+ # Read and update global progress
280+ with open (eta_metadata_file , 'r' ) as f :
281+ metadata = json .load (f )
282+
283+ # Increment global batch counter
284+ global_batches_completed = metadata .get ('global_batches_completed' , 0 ) + 1
285+ total_batches = metadata ['total_batches' ]
286+
287+ # Calculate average speed from all batches completed so far in current task
288+ elapsed_time = time .time () - start_time_stamp
289+ avg_batch_time = elapsed_time / batch_num
290+
291+ # Calculate GLOBAL remaining time
292+ remaining_batches = total_batches - global_batches_completed
293+ remaining_seconds = remaining_batches * avg_batch_time
294+
295+ # Update metadata with new global counter
296+ metadata ['global_batches_completed' ] = global_batches_completed
297+ with open (eta_metadata_file , 'w' ) as f :
298+ json .dump (metadata , f )
299+
300+ # Show progress every 5 GLOBAL batches
301+ if global_batches_completed % 5 == 0 :
302+ # Format human-readable time
303+ if remaining_seconds < 60 :
304+ remaining_str = f"{ int (remaining_seconds )} s"
305+ else :
306+ remaining_minutes = int (remaining_seconds / 60 )
307+ remaining_secs = int (remaining_seconds % 60 )
308+ remaining_str = f"{ remaining_minutes } m { remaining_secs } s"
309+
310+ # Log human-readable format with global progress
311+ logger .info (f'⏱️ Remaining: { remaining_str } (Global: { global_batches_completed } /{ total_batches } batches)' )
312+
313+ # Log JSON format for parsing
314+ progress_data = {
315+ "remaining_seconds" : int (remaining_seconds ),
316+ "batches_completed" : global_batches_completed ,
317+ "batches_total" : total_batches
318+ }
319+ logger .info (f'PROGRESS_DATA: { json .dumps (progress_data )} ' )
320+ except Exception :
321+ # Silently ignore if metadata file doesn't exist or can't be read
322+ pass
323+
268324 end_time_stamp = time .time ()
269325
270326 # Log completion summary
0 commit comments