@@ -104,20 +104,20 @@ def __init__(
104104 # Set global random seeds
105105 random .seed (self .config .random_seed )
106106 np .random .seed (self .config .random_seed )
107-
107+
108108 # Create hash-based seeds for different components
109- base_seed = str (self .config .random_seed ).encode (' utf-8' )
110- llm_seed = int (hashlib .md5 (base_seed + b' llm' ).hexdigest ()[:8 ], 16 ) % (2 ** 31 )
111-
109+ base_seed = str (self .config .random_seed ).encode (" utf-8" )
110+ llm_seed = int (hashlib .md5 (base_seed + b" llm" ).hexdigest ()[:8 ], 16 ) % (2 ** 31 )
111+
112112 # Propagate seed to LLM configurations
113113 self .config .llm .random_seed = llm_seed
114114 for model_cfg in self .config .llm .models :
115- if not hasattr (model_cfg , ' random_seed' ) or model_cfg .random_seed is None :
115+ if not hasattr (model_cfg , " random_seed" ) or model_cfg .random_seed is None :
116116 model_cfg .random_seed = llm_seed
117117 for model_cfg in self .config .llm .evaluator_models :
118- if not hasattr (model_cfg , ' random_seed' ) or model_cfg .random_seed is None :
118+ if not hasattr (model_cfg , " random_seed" ) or model_cfg .random_seed is None :
119119 model_cfg .random_seed = llm_seed
120-
120+
121121 logger .info (f"Set random seed to { self .config .random_seed } for reproducibility" )
122122 logger .debug (f"Generated LLM seed: { llm_seed } " )
123123
@@ -161,7 +161,7 @@ def __init__(
161161 self .evaluation_file = evaluation_file
162162
163163 logger .info (f"Initialized OpenEvolve with { initial_program_path } " )
164-
164+
165165 # Initialize improved parallel processing components
166166 self .parallel_controller = None
167167
@@ -212,7 +212,7 @@ async def run(
212212 Best program found
213213 """
214214 max_iterations = iterations or self .config .max_iterations
215-
215+
216216 # Determine starting iteration
217217 start_iteration = 0
218218 if checkpoint_path and os .path .exists (checkpoint_path ):
@@ -260,30 +260,31 @@ async def run(
260260 self .parallel_controller = ImprovedParallelController (
261261 self .config , self .evaluation_file , self .database
262262 )
263-
263+
264264 # Set up signal handlers for graceful shutdown
265265 def signal_handler (signum , frame ):
266266 logger .info (f"Received signal { signum } , initiating graceful shutdown..." )
267267 self .parallel_controller .request_shutdown ()
268-
268+
269269 # Set up a secondary handler for immediate exit if user presses Ctrl+C again
270270 def force_exit_handler (signum , frame ):
271271 logger .info ("Force exit requested - terminating immediately" )
272272 import sys
273+
273274 sys .exit (0 )
274-
275+
275276 signal .signal (signal .SIGINT , force_exit_handler )
276-
277+
277278 signal .signal (signal .SIGINT , signal_handler )
278279 signal .signal (signal .SIGTERM , signal_handler )
279-
280+
280281 self .parallel_controller .start ()
281-
282+
282283 # Run evolution with improved parallel processing and checkpoint callback
283284 await self ._run_evolution_with_checkpoints (
284285 start_iteration , max_iterations , target_score
285286 )
286-
287+
287288 finally :
288289 # Clean up parallel processing resources
289290 if self .parallel_controller :
@@ -420,31 +421,28 @@ def _load_checkpoint(self, checkpoint_path: str) -> None:
420421 """Load state from a checkpoint directory"""
421422 if not os .path .exists (checkpoint_path ):
422423 raise FileNotFoundError (f"Checkpoint directory { checkpoint_path } not found" )
423-
424+
424425 logger .info (f"Loading checkpoint from { checkpoint_path } " )
425426 self .database .load (checkpoint_path )
426- logger .info (
427- f"Checkpoint loaded successfully (iteration { self .database .last_iteration } )"
428- )
427+ logger .info (f"Checkpoint loaded successfully (iteration { self .database .last_iteration } )" )
429428
430429 async def _run_evolution_with_checkpoints (
431430 self , start_iteration : int , max_iterations : int , target_score : Optional [float ]
432431 ) -> None :
433432 """Run evolution with checkpoint saving support"""
434433 logger .info (f"Using island-based evolution with { self .config .database .num_islands } islands" )
435434 self .database .log_island_status ()
436-
435+
437436 # Run the evolution process with checkpoint callback
438437 await self .parallel_controller .run_evolution (
439- start_iteration , max_iterations , target_score ,
440- checkpoint_callback = self ._save_checkpoint
438+ start_iteration , max_iterations , target_score , checkpoint_callback = self ._save_checkpoint
441439 )
442-
440+
443441 # Check if shutdown was requested
444442 if self .parallel_controller .shutdown_flag .is_set ():
445443 logger .info ("Evolution stopped due to shutdown request" )
446444 return
447-
445+
448446 # Save final checkpoint if needed
449447 final_iteration = start_iteration + max_iterations - 1
450448 if final_iteration > 0 and final_iteration % self .config .checkpoint_interval == 0 :
@@ -499,4 +497,4 @@ def _save_best_program(self, program: Optional[Program] = None) -> None:
499497 indent = 2 ,
500498 )
501499
502- logger .info (f"Saved best program to { code_path } with program info to { info_path } " )
500+ logger .info (f"Saved best program to { code_path } with program info to { info_path } " )
0 commit comments