Skip to content

Commit 8c6ec66

Browse files
authored
Merge branch 'main' into feature/improved-whitespace-handling
2 parents 8b82a31 + 4866d2a commit 8c6ec66

File tree

23 files changed

+868
-666
lines changed

23 files changed

+868
-666
lines changed

.github/workflows/python-lint.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-python@v5
11+
with:
12+
python-version: "3.13"
13+
- uses: psf/black@stable
14+
with:
15+
options: "--check --verbose"
16+
src: "./openevolve ./tests ./examples"
17+
use_pyproject: true

.github/workflows/python-test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Python Unit Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.9'
17+
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install -e ".[dev]"
22+
23+
- name: Run unit tests
24+
run: |
25+
python -m unittest discover -s tests -p "*.py"

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use an official Python image as the base
2+
FROM python:3.12-slim
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Install system dependencies
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
build-essential \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Copy the project files into the container
13+
COPY . /app
14+
15+
# Install Python dependencies
16+
RUN pip install --root-user-action=ignore -e .
17+
18+
# Expose the project directory as a volume
19+
VOLUME ["/app"]
20+
21+
# Set the entry point to the openevolve-run.py script
22+
ENTRYPOINT ["python", "/app/openevolve-run.py"]

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Variables
2+
PROJECT_DIR := $(shell pwd)
3+
DOCKER_IMAGE := openevolve
4+
VENV_DIR := $(PROJECT_DIR)/env
5+
PYTHON := $(VENV_DIR)/bin/python
6+
PIP := $(VENV_DIR)/bin/pip
7+
8+
# Default target
9+
.PHONY: all
10+
all: install test
11+
12+
# Create and activate the virtual environment
13+
.PHONY: venv
14+
venv:
15+
python3 -m venv $(VENV_DIR)
16+
17+
# Install Python dependencies in the virtual environment
18+
.PHONY: install
19+
install: venv
20+
$(PIP) install -e .
21+
22+
# Run Black code formatting
23+
.PHONY: lint
24+
lint: venv
25+
$(PYTHON) -m black openevolve examples tests
26+
27+
# Run tests using the virtual environment
28+
.PHONY: test
29+
test: venv
30+
$(PYTHON) -m unittest discover -s tests -p "test_*.py"
31+
32+
# Build the Docker image
33+
.PHONY: docker-build
34+
docker-build:
35+
docker build -t $(DOCKER_IMAGE) .
36+
37+
# Run the Docker container with the example
38+
.PHONY: docker-run
39+
docker-run:
40+
docker run --rm -v $(PROJECT_DIR):/app $(DOCKER_IMAGE) examples/function_minimization/initial_program.py examples/function_minimization/evaluator.py --config examples/function_minimization/config.yaml --iterations 1000

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ OpenEvolve follows an evolutionary approach with the following components:
2727

2828
### Installation
2929

30+
To install natively, use:
3031
```bash
3132
git clone https://github.com/codelion/openevolve.git
3233
cd openevolve
@@ -60,6 +61,44 @@ OpenEvolve can also be run from the command line:
6061
python openevolve-run.py path/to/initial_program.py path/to/evaluator.py --config path/to/config.yaml --iterations 1000
6162
```
6263

64+
### Resuming from Checkpoints
65+
66+
OpenEvolve automatically saves checkpoints at intervals specified by the `checkpoint_interval` config parameter (default is 10 iterations). You can resume an evolution run from a saved checkpoint:
67+
68+
```bash
69+
python openevolve-run.py path/to/initial_program.py path/to/evaluator.py \
70+
--config path/to/config.yaml \
71+
--checkpoint path/to/checkpoint_directory \
72+
--iterations 50
73+
```
74+
75+
When resuming from a checkpoint:
76+
- The system loads all previously evolved programs and their metrics
77+
- Checkpoint numbering continues from where it left off (e.g., if loaded from checkpoint_50, the next checkpoint will be checkpoint_60)
78+
- All evolution state is preserved (best programs, feature maps, archives, etc.)
79+
80+
Example workflow with checkpoints:
81+
82+
```bash
83+
# Run for 50 iterations (creates checkpoints at iterations 10, 20, 30, 40, 50)
84+
python openevolve-run.py examples/function_minimization/initial_program.py \
85+
examples/function_minimization/evaluator.py \
86+
--iterations 50
87+
88+
# Resume from checkpoint 50 for another 50 iterations (creates checkpoints at 60, 70, 80, 90, 100)
89+
python openevolve-run.py examples/function_minimization/initial_program.py \
90+
examples/function_minimization/evaluator.py \
91+
--checkpoint examples/function_minimization/openevolve_output/checkpoints/checkpoint_50 \
92+
--iterations 50
93+
```
94+
### Docker
95+
96+
You can also install and execute via Docker:
97+
```bash
98+
docker build -t openevolve .
99+
docker run --rm -v .:/app openevolve examples/function_minimization/initial_program.py examples/function_minimization/evaluator.py --config examples/function_minimization/config.yaml --iterations 1000
100+
```
101+
63102
## Configuration
64103

65104
OpenEvolve is highly configurable. You can specify configuration options in a YAML file:

0 commit comments

Comments
 (0)