Skip to content
Merged
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
15 changes: 13 additions & 2 deletions openevolve/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import random
import time
from dataclasses import asdict, dataclass, field
from dataclasses import asdict, dataclass, field, fields
from pathlib import Path
from typing import Any, Dict, List, Optional, Set, Tuple, Union

Expand Down Expand Up @@ -73,7 +73,18 @@ def to_dict(self) -> Dict[str, Any]:
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "Program":
"""Create from dictionary representation"""
return cls(**data)
# Get the valid field names for the Program dataclass
valid_fields = {f.name for f in fields(cls)}

# Filter the data to only include valid fields
filtered_data = {k: v for k, v in data.items() if k in valid_fields}

# Log if we're filtering out any fields
if len(filtered_data) != len(data):
filtered_out = set(data.keys()) - set(filtered_data.keys())
logger.debug(f"Filtered out unsupported fields when loading Program: {filtered_out}")

return cls(**filtered_data)


class ProgramDatabase:
Expand Down
Loading