codelion commited on
Commit
b2339e2
·
verified ·
1 Parent(s): 3876e1a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -57
app.py CHANGED
@@ -561,9 +561,9 @@ def create_config_file(model: str, work_dir: str):
561
  "exploit_ratio": 0.6,
562
  },
563
  "evaluator": {
564
- "timeout": None, # Disable timeout to avoid signal handling issues
565
  "cascade_evaluation": False, # Disable cascade to prevent signal errors
566
- "parallel_evaluations": 1, # Single worker
567
  "distributed": False, # No distributed processing
568
  }
569
  }
@@ -673,62 +673,16 @@ def optimize_prompt(initial_prompt: str, dataset_name: str, dataset_split: str,
673
 
674
  signal.signal = safe_signal
675
 
676
- # Step 3: Monkey-patch ProcessParallelController
677
- import openevolve.process_parallel as pp_module
678
- from concurrent.futures import Future
679
-
680
- OriginalProcessController = pp_module.ProcessParallelController
681
-
682
- class NoOpProcessController:
683
- def __init__(self, *args, **kwargs):
684
- self.num_workers = 1
685
-
686
- def __enter__(self):
687
- return self
688
-
689
- def __exit__(self, *args):
690
- pass
691
-
692
- def submit(self, func, *args, **kwargs):
693
- # Execute directly and wrap in a completed Future
694
- future = Future()
695
- try:
696
- result = func(*args, **kwargs)
697
- future.set_result(result)
698
- except Exception as e:
699
- future.set_exception(e)
700
- return future
701
-
702
- def map(self, func, *args):
703
- # Execute directly and wrap each result in a Future
704
- futures = []
705
- for a in zip(*args):
706
- future = Future()
707
- try:
708
- result = func(*a)
709
- future.set_result(result)
710
- except Exception as e:
711
- future.set_exception(e)
712
- futures.append(future)
713
- return futures
714
-
715
- def shutdown(self, wait=True):
716
- pass
717
-
718
- pp_module.ProcessParallelController = NoOpProcessController
719
 
720
- try:
721
- # Run evolution
722
- result = run_evolution(
723
- initial_program=initial_prompt_path,
724
- evaluator=evaluator_path,
725
- config=config_path,
726
- output_dir=output_dir
727
- )
728
- finally:
729
- # Restore everything
730
- pp_module.ProcessParallelController = OriginalProcessController
731
- signal.signal = original_signal
732
 
733
  progress(0.80, desc="Parsing evolution history...")
734
 
 
561
  "exploit_ratio": 0.6,
562
  },
563
  "evaluator": {
564
+ "timeout": 3600, # 1 hour timeout (effectively disabled, but prevents NoneType arithmetic errors)
565
  "cascade_evaluation": False, # Disable cascade to prevent signal errors
566
+ "parallel_evaluations": 1, # Single worker to avoid multiprocessing complexity
567
  "distributed": False, # No distributed processing
568
  }
569
  }
 
673
 
674
  signal.signal = safe_signal
675
 
676
+ # Run evolution with signal patch in place
677
+ result = run_evolution(
678
+ initial_program=initial_prompt_path,
679
+ evaluator=evaluator_path,
680
+ config=config_path,
681
+ output_dir=output_dir
682
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
683
 
684
+ # Restore signal handler
685
+ signal.signal = original_signal
 
 
 
 
 
 
 
 
 
 
686
 
687
  progress(0.80, desc="Parsing evolution history...")
688