MCPcopy Create free account
hub / github.com/UCSB-AI/EvoPresent / process_task

Function process_task

train/eval.py:818–855  ·  view source on GitHub ↗

Process a single task with given test data.

(tester: MultiTaskTester, test_data_file: str, task_type: str, num_workers: int, image_root: str = "")

Source from the content-addressed store, hash-verified

816
817
818def process_task(tester: MultiTaskTester, test_data_file: str, task_type: str, num_workers: int, image_root: str = "") -> List[Dict]:
819 """Process a single task with given test data."""
820 print(f"\n{'='*60}")
821 print(f"PROCESSING {task_type.upper()} TASK")
822 print(f"{'='*60}")
823
824 # Load test data
825 with open(test_data_file, 'r') as f:
826 test_data = json.load(f)
827
828 print(f"Loaded {len(test_data)} {task_type} test samples")
829 print(f"Using {num_workers} concurrent workers")
830 if image_root:
831 print(f"Image root: {image_root}")
832
833 all_results = []
834
835 if num_workers == 1:
836 # Single thread mode
837 for item in tqdm(test_data, desc=f"Processing {task_type} samples"):
838 result = tester.process_single(item, task_type=task_type)
839 if result:
840 all_results.append(result)
841 else:
842 # Multi-threaded mode for concurrent API calls
843 with ThreadPoolExecutor(max_workers=num_workers) as executor:
844 # Submit all tasks
845 futures = {executor.submit(tester.process_single, item, task_type): item for item in test_data}
846
847 # Collect results with progress bar
848 with tqdm(total=len(test_data), desc=f"Processing {task_type} samples") as pbar:
849 for future in as_completed(futures):
850 result = future.result()
851 if result:
852 all_results.append(result)
853 pbar.update(1)
854
855 return all_results
856
857
858def load_config(config_file: str) -> Dict:

Callers 1

mainFunction · 0.85

Calls 2

process_singleMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected