MCPcopy Create free account
hub / github.com/FareedKhan-dev/ai-long-task / ProcessParallelController

Class ProcessParallelController

core/process_parallel.py:374–854  ·  view source on GitHub ↗

Controller for process-based parallel evolution

Source from the content-addressed store, hash-verified

372
373
374class ProcessParallelController:
375 """Controller for process-based parallel evolution"""
376
377 def __init__(
378 self,
379 config: Config,
380 evaluation_file: str,
381 database: ProgramDatabase,
382 evolution_tracer=None,
383 file_suffix: str = ".py",
384 ):
385 # Store main configuration
386 self.config = config
387 self.evaluation_file = evaluation_file
388 self.database = database
389 self.evolution_tracer = evolution_tracer
390 self.file_suffix = file_suffix
391
392 # Executor will be initialized in start()
393 self.executor: Optional[ProcessPoolExecutor] = None
394 # Event to signal shutdown to main loop
395 self.shutdown_event = mp.Event()
396 self.early_stopping_triggered = False
397
398 # Number of worker processes from config
399 self.num_workers = config.evaluator.parallel_evaluations
400 self.num_islands = config.database.num_islands
401
402 logger.info(f"Initialized process parallel controller with {self.num_workers} workers")
403
404 def _serialize_config(self, config: Config) -> dict:
405 """Serialize config object to a dictionary that can be pickled"""
406 # Manual serialization to handle nested objects properly and avoid unpickleable types
407
408 # The asdict() call itself triggers the deepcopy which tries to serialize novelty_llm. Remove it first.
409 config.database.novelty_llm = None
410
411 return {
412 "llm": {
413 "models": [asdict(m) for m in config.llm.models],
414 "evaluator_models": [asdict(m) for m in config.llm.evaluator_models],
415 "api_base": config.llm.api_base,
416 "api_key": config.llm.api_key,
417 "temperature": config.llm.temperature,
418 "top_p": config.llm.top_p,
419 "max_tokens": config.llm.max_tokens,
420 "timeout": config.llm.timeout,
421 "retries": config.llm.retries,
422 "retry_delay": config.llm.retry_delay,
423 },
424 "prompt": asdict(config.prompt),
425 "database": asdict(config.database),
426 "evaluator": asdict(config.evaluator),
427 # (+) Serialize new config sections
428 "browser_use": asdict(config.browser_use),
429 "computer_use": asdict(config.computer_use),
430 # Scalar fields
431 "max_iterations": config.max_iterations,

Callers 1

runMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected