DocUA commited on
Commit
798f2fe
·
1 Parent(s): fd0d61e

Add progress tracking to batch classification process

Browse files
src/interface/file_upload_interface.py CHANGED
@@ -362,7 +362,7 @@ class FileUploadInterfaceController(ProgressTrackingMixin):
362
 
363
  return classification
364
 
365
- def run_batch_classification(self) -> Tuple[bool, str, Dict[str, Any]]:
366
  """Run classification for the whole uploaded dataset and persist results.
367
 
368
  File Upload Mode is already labeled (ground truth provided in the file), so we
@@ -389,6 +389,11 @@ class FileUploadInterfaceController(ProgressTrackingMixin):
389
  self.setup_progress_tracking(total)
390
 
391
  for idx, test_message in enumerate(self.current_file_result.parsed_test_cases):
 
 
 
 
 
392
  self.batch_processing_start_time = datetime.now()
393
 
394
  user_prompt = (
@@ -438,6 +443,9 @@ class FileUploadInterfaceController(ProgressTrackingMixin):
438
  self.current_session.is_complete = True
439
  self.current_session.completed_at = datetime.now()
440
 
 
 
 
441
  self.store.save_session(self.current_session)
442
 
443
  accuracy = (
@@ -805,6 +813,9 @@ def create_file_upload_interface() -> gr.Blocks:
805
  "Ready to start batch processing",
806
  label="Progress"
807
  )
 
 
 
808
 
809
  # Message processing section (initially hidden)
810
  message_processing_section = gr.Row(visible=False)
@@ -961,7 +972,7 @@ def create_file_upload_interface() -> gr.Blocks:
961
  if success:
962
  # Simplified behavior: dataset is already labeled, so run full batch
963
  # classification immediately and generate results for export.
964
- run_ok, run_msg, stats = controller.run_batch_classification()
965
  if run_ok:
966
  progress_text = f"✅ Completed: {stats.get('processed', 0)}/{stats.get('total', 0)} messages"
967
  return (
 
362
 
363
  return classification
364
 
365
+ def run_batch_classification(self, progress: Optional[gr.Progress] = None) -> Tuple[bool, str, Dict[str, Any]]:
366
  """Run classification for the whole uploaded dataset and persist results.
367
 
368
  File Upload Mode is already labeled (ground truth provided in the file), so we
 
389
  self.setup_progress_tracking(total)
390
 
391
  for idx, test_message in enumerate(self.current_file_result.parsed_test_cases):
392
+ if progress is not None:
393
+ progress(
394
+ (idx) / total,
395
+ desc=f"Processing {idx + 1}/{total}"
396
+ )
397
  self.batch_processing_start_time = datetime.now()
398
 
399
  user_prompt = (
 
443
  self.current_session.is_complete = True
444
  self.current_session.completed_at = datetime.now()
445
 
446
+ if progress is not None:
447
+ progress(1.0, desc=f"Completed {total}/{total}")
448
+
449
  self.store.save_session(self.current_session)
450
 
451
  accuracy = (
 
813
  "Ready to start batch processing",
814
  label="Progress"
815
  )
816
+
817
+ # Visual progress bar (updates during batch classification)
818
+ batch_progress_bar = gr.Progress()
819
 
820
  # Message processing section (initially hidden)
821
  message_processing_section = gr.Row(visible=False)
 
972
  if success:
973
  # Simplified behavior: dataset is already labeled, so run full batch
974
  # classification immediately and generate results for export.
975
+ run_ok, run_msg, stats = controller.run_batch_classification(progress=batch_progress_bar)
976
  if run_ok:
977
  progress_text = f"✅ Completed: {stats.get('processed', 0)}/{stats.get('total', 0)} messages"
978
  return (