You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logger.debug(f"Successfully processed record from line {line_num} (including linked papers if any).")
455
+
else:
456
+
logger.warning(f"Marked record from line {line_num} as processed with errors/skips.")
457
+
# Even if marked as error, we might count it towards the total lines *attempted* in the batch
458
+
processed_in_batch+=1
427
459
428
-
processed_in_batch+=1
429
460
exceptExceptionase:
430
-
logger.error(
431
-
f"Error processing record for model {hf_model_id} on line {line_num}: {e}"
432
-
)
433
-
logger.error(traceback.format_exc())
434
-
# Decide whether to continue batch or raise error to rollback transaction
435
-
# For robustness, log error and continue processing other records in batch
436
-
437
-
returnprocessed_in_batch
461
+
# Log detailed error including traceback and the problematic record line number
462
+
tb_str=traceback.format_exc()
463
+
logger.error(f"Error processing record from line {line_num}: {e}\\nRecord: {record}\\nTraceback:\\n{tb_str}")
464
+
# Re-raise the exception to trigger the automatic rollback of conn.transaction()
465
+
raise# This will rollback the *entire* batch
466
+
467
+
# If the 'with conn.transaction()' block completes without exceptions, commit is automatic.
468
+
# If an exception occurs, rollback is automatic.
469
+
logger.debug(f"Transaction for batch completed (Commit or Rollback occurred). Successfully processed {successful_lines_in_batch} lines in this attempt.")
470
+
# Return the count of lines successfully processed within the transaction
471
+
# If an exception caused rollback, this will be 0 from the perspective of the DB, but we return the count *attempted* before failure.
472
+
# Let's return successful_lines_in_batch to be more accurate about what potentially committed.
0 commit comments