Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ wheels/
.installed.cfg
*.egg
MANIFEST
*.lock

# Virtual environments
venv/
Expand Down
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Copy link
Contributor Author

@yuxuan-z19 yuxuan-z19 Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All hooks have been updated to their latest stable releases using pre-commit update.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pycqa/isort
rev: "7.0.0"
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/psf/black
rev: "25.12.0"
hooks:
- id: black
45 changes: 10 additions & 35 deletions openevolve/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union

import dacite
import yaml

if TYPE_CHECKING:
Expand Down Expand Up @@ -418,46 +419,20 @@ def from_yaml(cls, path: Union[str, Path]) -> "Config":

@classmethod
def from_dict(cls, config_dict: Dict[str, Any]) -> "Config":
"""Create configuration from a dictionary"""
# Handle nested configurations
config = Config()

# Update top-level fields
for key, value in config_dict.items():
if key not in ["llm", "prompt", "database", "evaluator", "evolution_trace"] and hasattr(
config, key
):
setattr(config, key, value)

# Update nested configs
if "llm" in config_dict:
llm_dict = config_dict["llm"]
if "models" in llm_dict:
llm_dict["models"] = [LLMModelConfig(**m) for m in llm_dict["models"]]
if "evaluator_models" in llm_dict:
llm_dict["evaluator_models"] = [
LLMModelConfig(**m) for m in llm_dict["evaluator_models"]
]
config.llm = LLMConfig(**llm_dict)
if "prompt" in config_dict:
config.prompt = PromptConfig(**config_dict["prompt"])
if "database" in config_dict:
config.database = DatabaseConfig(**config_dict["database"])

# Ensure database inherits the random seed if not explicitly set
if config.database.random_seed is None and config.random_seed is not None:
config.database.random_seed = config.random_seed
if "evaluator" in config_dict:
config.evaluator = EvaluatorConfig(**config_dict["evaluator"])
if "evolution_trace" in config_dict:
config.evolution_trace = EvolutionTraceConfig(**config_dict["evolution_trace"])
if "diff_pattern" in config_dict:
# Validate it's a valid regex
try:
re.compile(config_dict["diff_pattern"])
except re.error as e:
raise ValueError(f"Invalid regex pattern in diff_pattern: {e}")
config.diff_pattern = config_dict["diff_pattern"]

config: Config = dacite.from_dict(
data_class=cls,
data=config_dict,
config=dacite.Config(cast=[List, Union], forward_references={"LLMInterface": Any}),
)

if config.database.random_seed is None and config.random_seed is not None:
config.database.random_seed = config.random_seed

return config

Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ dynamic = ["version"]
description = "Open-source implementation of AlphaEvolve"
readme = "README.md"
requires-python = ">=3.10"
license = {text = "Apache-2.0"}
authors = [
{name = "codelion"}
]
license = { text = "Apache-2.0" }
authors = [{ name = "codelion" }]
dependencies = [
"openai>=1.0.0",
"pyyaml>=6.0",
"numpy>=1.22.0",
"tqdm>=4.64.0",
"flask",
"dacite>=1.9.2",
]

[project.optional-dependencies]
Expand All @@ -28,6 +27,7 @@ dev = [
"isort>=5.10.0",
"mypy>=0.950",
"requests>=2.28.0",
"pre-commit>=4.5.1",
]

[tool.black]
Expand All @@ -52,7 +52,7 @@ openevolve-run = "openevolve.cli:main"
[tool.pytest.ini_options]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"integration: marks tests as integration tests requiring external services"
"integration: marks tests as integration tests requiring external services",
]
addopts = "--strict-markers"

Expand All @@ -63,4 +63,4 @@ include = ["openevolve*"]
openevolve = ["prompts/defaults/*.txt", "prompts/defaults/*.json"]

[tool.setuptools.dynamic]
version = {attr = "openevolve._version.__version__"}
version = { attr = "openevolve._version.__version__" }