From 46f414a8a07412619bf3b4d0a7db94b559d65b17 Mon Sep 17 00:00:00 2001 From: Asankhaya Sharma Date: Sat, 21 Jun 2025 07:34:32 +0800 Subject: [PATCH 1/6] Fix archive cleanup and bump version to 0.0.4 Improves archive management in ProgramDatabase by removing stale program references before evaluating archive capacity and replacement logic. Also updates the project version to 0.0.4 in both pyproject.toml and setup.py. --- openevolve/database.py | 37 +++++++++++++++++++++++++++++++------ pyproject.toml | 2 +- setup.py | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/openevolve/database.py b/openevolve/database.py index b23b660dd..6e2cd8492 100644 --- a/openevolve/database.py +++ b/openevolve/database.py @@ -662,13 +662,38 @@ def _update_archive(self, program: Program) -> None: self.archive.add(program.id) return - # Otherwise, find worst program in archive - archive_programs = [self.programs[pid] for pid in self.archive] - worst_program = min(archive_programs, key=lambda p: safe_numeric_average(p.metrics)) + # Clean up stale references and get valid archive programs + valid_archive_programs = [] + stale_ids = [] - # Replace if new program is better - if self._is_better(program, worst_program): - self.archive.remove(worst_program.id) + for pid in self.archive: + if pid in self.programs: + valid_archive_programs.append(self.programs[pid]) + else: + stale_ids.append(pid) + + # Remove stale references from archive + for stale_id in stale_ids: + self.archive.discard(stale_id) + logger.debug(f"Removing stale program {stale_id} from archive") + + # If archive is now not full after cleanup, just add the new program + if len(self.archive) < self.config.archive_size: + self.archive.add(program.id) + return + + # Find worst program among valid programs + if valid_archive_programs: + worst_program = min( + valid_archive_programs, key=lambda p: safe_numeric_average(p.metrics) + ) + + # Replace if new program is better + if self._is_better(program, worst_program): + self.archive.remove(worst_program.id) + self.archive.add(program.id) + else: + # No valid programs in archive, just add the new one self.archive.add(program.id) def _update_best_program(self, program: Program) -> None: diff --git a/pyproject.toml b/pyproject.toml index fa4424fe8..267597a8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "openevolve" -version = "0.0.3" +version = "0.0.4" description = "Open-source implementation of AlphaEvolve" readme = "README.md" requires-python = ">=3.9" diff --git a/setup.py b/setup.py index 200863df2..bc5acd412 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="openevolve", - version="0.0.3", + version="0.0.4", packages=find_packages(), include_package_data=True, ) From 1bb77585a4b1902c5ab2af61363ec41a7451276f Mon Sep 17 00:00:00 2001 From: Asankhaya Sharma Date: Sat, 21 Jun 2025 07:38:05 +0800 Subject: [PATCH 2/6] Update python-lint.yml --- .github/workflows/python-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 29e0fcb29..8441a98e7 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -9,9 +9,9 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v5 with: - python-version: "3.13" + python-version: "3.10" - uses: psf/black@stable with: options: "--check --verbose" src: "./openevolve ./tests ./examples ./scripts" - use_pyproject: true \ No newline at end of file + use_pyproject: true From f4f6420b8ea8685304f4d9143042b1bf866249dc Mon Sep 17 00:00:00 2001 From: Asankhaya Sharma Date: Sat, 21 Jun 2025 07:39:06 +0800 Subject: [PATCH 3/6] Update python-lint.yml --- .github/workflows/python-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 8441a98e7..8ac0d4357 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.11" - uses: psf/black@stable with: options: "--check --verbose" From 940f825ac0c2d5d6c450c77cba48d6bb4bb3c9e7 Mon Sep 17 00:00:00 2001 From: Asankhaya Sharma Date: Sat, 21 Jun 2025 07:39:48 +0800 Subject: [PATCH 4/6] Update python-lint.yml --- .github/workflows/python-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 8ac0d4357..fe89c74c8 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.13" - uses: psf/black@stable with: options: "--check --verbose" From ff0a7941a7dc48c49b45ee5b6555310f365960b1 Mon Sep 17 00:00:00 2001 From: Asankhaya Sharma Date: Sat, 21 Jun 2025 07:42:07 +0800 Subject: [PATCH 5/6] Remove Python lint GitHub Actions workflow Deleted the python-lint.yml workflow file from GitHub Actions. This disables automated linting checks on push and pull request events. --- .github/workflows/python-lint.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .github/workflows/python-lint.yml diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml deleted file mode 100644 index 29e0fcb29..000000000 --- a/.github/workflows/python-lint.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Lint - -on: [push, pull_request] - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v5 - with: - python-version: "3.13" - - uses: psf/black@stable - with: - options: "--check --verbose" - src: "./openevolve ./tests ./examples ./scripts" - use_pyproject: true \ No newline at end of file From 3f8b677be02337272244595137d083363704b3dd Mon Sep 17 00:00:00 2001 From: Asankhaya Sharma Date: Sat, 21 Jun 2025 07:42:39 +0800 Subject: [PATCH 6/6] Remove code style section from CONTRIBUTING.md The section describing the use of Black for code formatting has been removed from the contributing guidelines. Contributors are no longer instructed to format code with Black before submitting pull requests. --- CONTRIBUTING.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 184b790a9..d2620160b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,14 +19,6 @@ source env/bin/activate # On Windows: env\Scripts\activate pip install -e ".[dev]" ``` -## Code Style - -We follow the [Black](https://black.readthedocs.io/) code style. Please format your code before submitting a pull request: - -```bash -black openevolve tests examples -``` - ## Pull Request Process 1. Create a new branch for your feature or bugfix: `git checkout -b feat-your-feature-name`