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
55 changes: 32 additions & 23 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,42 @@ on:
workflow_dispatch:
pull_request:
branches: ["dev", "main"]
paths: ["kaievolve/**", "tests/**", "configs/**", "pyproject.toml", ".github/workflows/python-test.yml"]
paths: ["kaievolve/**", "tests/**", "scripts/**", "configs/**", "pyproject.toml", ".github/workflows/python-test.yml"]
push:
branches: ["dev", "main"]
paths: ["kaievolve/**", "tests/**", "configs/**", "pyproject.toml", ".github/workflows/python-test.yml"]
paths: ["kaievolve/**", "tests/**", "scripts/**", "configs/**", "pyproject.toml", ".github/workflows/python-test.yml"]

jobs:
test:
lint:
name: Lint (black)
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
# Install test dependencies
pip install pytest numpy
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install "black==25.1.0"
- name: Black formatting check
run: black --check --line-length 100 kaievolve tests scripts

- name: Run unit tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
python -m unittest discover -s tests -p "test_*.py" -v
test:
name: Tests (py${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest numpy
- name: Run unit tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: python -m unittest discover -s tests -p "test_*.py"
1 change: 1 addition & 0 deletions kaievolve/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def _resolve_best_program(run_dir):
candidates = [os.path.join(run_dir, "best", "best_program.py")]
ckpts = glob.glob(os.path.join(run_dir, "checkpoints", "checkpoint_*"))
if ckpts:

def _ckpt_num(p):
m = re.search(r"checkpoint_(\d+)$", p.rstrip("/"))
return int(m.group(1)) if m else -1
Expand Down
4 changes: 1 addition & 3 deletions tests/test_cli_init_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def test_prefers_best_dir(self):
with TemporaryDirectory() as d:
_write(os.path.join(d, "best", "best_program.py"))
_write(os.path.join(d, "checkpoints", "checkpoint_10", "best_program.py"))
self.assertEqual(
_resolve_best_program(d), os.path.join(d, "best", "best_program.py")
)
self.assertEqual(_resolve_best_program(d), os.path.join(d, "best", "best_program.py"))

def test_falls_back_to_latest_checkpoint(self):
with TemporaryDirectory() as d:
Expand Down
Loading