@@ -271,7 +271,7 @@ async def process_page(args, worker_id: int, pdf_orig_path: str, pdf_local_path:
271
271
local_image_rotation = page_response .rotation_correction
272
272
raise ValueError (f"invalid_page rotation for { pdf_orig_path } -{ page_num } " )
273
273
274
- metrics .add_metrics (completed_pages = 1 )
274
+ metrics .add_metrics (** { " completed_pages" : 1 , f"finished_on_attempt_ { attempt } " : 1 } )
275
275
await tracker .track_work (worker_id , f"{ pdf_orig_path } -{ page_num } " , "finished" )
276
276
return PageResult (
277
277
pdf_orig_path ,
@@ -1211,6 +1211,19 @@ async def main():
1211
1211
f"Page Failure rate: { total_metrics .get ('failed_pages' , 0 ) / max (total_metrics .get ('completed_pages' , 0 ) + total_metrics .get ('failed_pages' , 0 ), 1 ) * 100 :.2f} %"
1212
1212
)
1213
1213
1214
+ # Output finished_on_attempt statistics
1215
+ logger .info ("\n Pages finished by attempt number:" )
1216
+ total_finished = sum (total_metrics .get (f'finished_on_attempt_{ i } ' , 0 ) for i in range (args .max_page_retries ))
1217
+ cumulative = 0
1218
+
1219
+ for i in range (args .max_page_retries ):
1220
+ if f'finished_on_attempt_{ i } ' in total_metrics :
1221
+ count = total_metrics [f'finished_on_attempt_{ i } ' ]
1222
+ cumulative += count
1223
+ percentage = (count / total_finished * 100 ) if total_finished > 0 else 0
1224
+ cumulative_percentage = (cumulative / total_finished * 100 ) if total_finished > 0 else 0
1225
+ logger .info (f" Attempt { i } : { count :,} pages ({ percentage :.1f} %) - Cumulative: { cumulative :,} ({ cumulative_percentage :.1f} %)" )
1226
+
1214
1227
# Output rates
1215
1228
if "server_input_tokens_per_sec" in rates :
1216
1229
logger .info (f"Server Input tokens/sec rate: { rates ['server_input_tokens_per_sec' ]:.2f} " )
0 commit comments