MCPcopy Create free account
hub / github.com/algorithmicsuperintelligence/openevolve / _worker_init

Function _worker_init

openevolve/process_parallel.py:39–95  ·  view source on GitHub ↗

Initialize worker process with necessary components

(config_dict: dict, evaluation_file: str, parent_env: dict = None)

Source from the content-addressed store, hash-verified

37
38
39def _worker_init(config_dict: dict, evaluation_file: str, parent_env: dict = None) -> None:
40 """Initialize worker process with necessary components"""
41 import os
42
43 # Set environment from parent process
44 if parent_env:
45 os.environ.update(parent_env)
46
47 global _worker_config
48 global _worker_evaluation_file
49 global _worker_evaluator
50 global _worker_llm_ensemble
51 global _worker_prompt_sampler
52
53 # Store config for later use
54 # Reconstruct Config object from nested dictionaries
55 from openevolve.config import (
56 Config,
57 DatabaseConfig,
58 EvaluatorConfig,
59 LLMConfig,
60 LLMModelConfig,
61 PromptConfig,
62 )
63
64 # Reconstruct model objects
65 models = [LLMModelConfig(**m) for m in config_dict["llm"]["models"]]
66 evaluator_models = [LLMModelConfig(**m) for m in config_dict["llm"]["evaluator_models"]]
67
68 # Create LLM config with models
69 llm_dict = config_dict["llm"].copy()
70 llm_dict["models"] = models
71 llm_dict["evaluator_models"] = evaluator_models
72 llm_config = LLMConfig(**llm_dict)
73
74 # Create other configs
75 prompt_config = PromptConfig(**config_dict["prompt"])
76 database_config = DatabaseConfig(**config_dict["database"])
77 evaluator_config = EvaluatorConfig(**config_dict["evaluator"])
78
79 _worker_config = Config(
80 llm=llm_config,
81 prompt=prompt_config,
82 database=database_config,
83 evaluator=evaluator_config,
84 **{
85 k: v
86 for k, v in config_dict.items()
87 if k not in ["llm", "prompt", "database", "evaluator"]
88 },
89 )
90 _worker_evaluation_file = evaluation_file
91
92 # These will be lazily initialized on first use
93 _worker_evaluator = None
94 _worker_llm_ensemble = None
95 _worker_prompt_sampler = None
96

Callers

nothing calls this directly

Calls 6

LLMModelConfigClass · 0.90
LLMConfigClass · 0.90
PromptConfigClass · 0.90
DatabaseConfigClass · 0.90
EvaluatorConfigClass · 0.90
ConfigClass · 0.90

Tested by

no test coverage detected