Skip to content
Closed
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
126 changes: 126 additions & 0 deletions .github/workflows/test-refactoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Test Benchmark Refactoring

on:
push:
branches: [ refactor-optimizer-selection ]
pull_request:
branches: [ main ]

jobs:
test-refactoring:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', 3.11]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install numpy
pip install -e .

- name: Run syntax check
run: |
python -m py_compile tutorials/benchmarking_lsbbo_2_improved.py

- name: Test optimizer loading
run: |
python -c "
import sys
sys.path.append('tutorials')
from benchmarking_lsbbo_2_improved import get_optimizer_class, OPTIMIZER_CONFIGS

# Test a few optimizers
test_optimizers = ['CMAES', 'PRS', 'JADE']
for opt in test_optimizers:
try:
cls = get_optimizer_class(opt)
print(f'✓ {opt}: {cls.__name__}')
except Exception as e:
print(f'✗ {opt}: {e}')
sys.exit(1)

print(f'Total optimizers configured: {len(OPTIMIZER_CONFIGS)}')
"

- name: Test argument validation
run: |
python tutorials/benchmarking_lsbbo_2_improved.py --help

- name: Test invalid optimizer
run: |
python tutorials/benchmarking_lsbbo_2_improved.py --start 0 --end 0 --optimizer INVALID --ndim_problem 10 || echo "Expected failure for invalid optimizer"

- name: Quick integration test
run: |
timeout 60 python tutorials/benchmarking_lsbbo_2_improved.py \
--start 0 --end 0 --optimizer CMAES --ndim_problem 2 || true

code-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Install linting tools
run: |
pip install flake8 black isort mypy

- name: Check code formatting with black
run: black --check --diff tutorials/benchmarking_lsbbo_2_improved.py

- name: Check import sorting
run: isort --check-only --diff tutorials/benchmarking_lsbbo_2_improved.py

- name: Lint with flake8
run: flake8 tutorials/benchmarking_lsbbo_2_improved.py --max-line-length=100

- name: Type checking with mypy
run: mypy tutorials/benchmarking_lsbbo_2_improved.py --ignore-missing-imports

documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Generate optimizer list documentation
run: |
python -c "
import sys
sys.path.append('tutorials')
from benchmarking_lsbbo_2_improved import OPTIMIZER_CONFIGS

print('# Supported Optimizers')
print()
categories = {}
for name, config in sorted(OPTIMIZER_CONFIGS.items()):
category = config.module_path.split('.')[2] # e.g., 'rs', 'es', etc.
if category not in categories:
categories[category] = []
categories[category].append((name, config.requires_sigma))

for category, optimizers in sorted(categories.items()):
print(f'## {category.upper()}')
for name, needs_sigma in optimizers:
sigma_note = ' (requires sigma)' if needs_sigma else ''
print(f'- {name}{sigma_note}')
print()
" > OPTIMIZERS.md

- name: Upload documentation
uses: actions/upload-artifact@v3
with:
name: optimizer-documentation
path: OPTIMIZERS.md
Loading
Loading