Skip to content

Refactor package structure, add tests, and update documentation#25

Merged
outsidermm merged 7 commits into
mainfrom
xjm/feat/prep_for_release
May 25, 2026
Merged

Refactor package structure, add tests, and update documentation#25
outsidermm merged 7 commits into
mainfrom
xjm/feat/prep_for_release

Conversation

@outsidermm
Copy link
Copy Markdown
Owner

This pull request introduces several improvements and enhancements to the project, focusing on developer experience, usability, and code maintainability. The most significant changes are the addition of a CI workflow, improved installation and usage documentation, and major refactoring of the core algorithm classes to support dependency injection and TensorFlow-optional operation. The codebase is now more modular, testable, and user-friendly.

Continuous Integration & Tooling:

  • Added a GitHub Actions workflow (.github/workflows/ci.yml) for continuous integration, running linting and tests on Python 3.11 and 3.12 using uv as the package manager.
  • Added .python-version file to specify Python 3.12 for development environments.

Documentation & Developer Experience:

  • Updated README.md with a CI badge, improved installation instructions (including uv and pip options), quick start code examples, and development commands for linting, testing, and building. [1] [2]

API & Usability Improvements:

  • Refactored EpochTuner, BatchSizeTuner, and LrTuner classes to accept an optional training_fn parameter, enabling dependency injection for easier testing and operation without TensorFlow or dataset files. Also added dataset_dir parameter for flexible dataset paths. [1] [2] [3] [4] [5] [6]
  • Improved docstrings and type annotations for all tuners, clarifying usage and return types. [1] [2] [3] [4]
  • Added __init__.py to the algorithm package, exposing the main tuner classes for import.

TensorFlow Dependency Handling:

  • Refactored TensorFlow imports to be local/lazy and added runtime checks so the code can run in non-TensorFlow environments when a custom training_fn is provided. Added helper for OOM error detection in BatchSizeTuner. [1] [2]
  • Refactored Searcher to use local imports for TensorFlow and Keras, improving optional dependency handling.

Code Quality & Robustness:

  • Improved error handling, type safety, and modularity throughout the algorithm classes, including normalization of return types and more robust search logic. [1] [2] [3] [4]

These changes collectively make the project easier to use, test, and extend, while also improving reliability and developer onboarding.

outsidermm and others added 6 commits May 25, 2026 15:32
- Add pyproject.toml with hatchling build backend, min-version deps,
  TF/Keras as optional [tf] extra, requires-python>=3.11
- Generate uv.lock (43 packages)
- Pin Python 3.12 via .python-version
- Remove requirements.txt (superseded)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add __init__.py to algorithm/, grid_search/, trend/ with __all__ exports
- Remove all sys.path.append('.') hacks
- Fix bare imports (from searcher import Searcher) to use relative imports
- Make TF/Keras imports lazy so the package is importable without TF installed
- Replace print() calls with logging.getLogger(__name__) throughout
- Fix hardcoded ./dataset/ and ./algorithm/ paths; use pathlib.Path with
  mkdir(parents=True) and accept dataset_dir constructor arg on DataLoader
- Fix undefined-before-use bug for 'mid' in EpochTuner.binary_search_efficient_epoch
- Fix IndexError on best_epoch[0] in EpochTuner return (was already a scalar)
- Add NumPy-style docstrings to all public classes and key methods
- Add training_fn parameter to EpochTuner, BatchSizeTuner, LrTuner so callers
  can inject a plain callable instead of requiring TF/dataset files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- tests/test_helper_func.py: 11 tests for min_max_scalar, weighted_avg,
  write_csv, write_header — no mocking required
- tests/test_epoch_tuner.py: binary search convergence and efficiency scoring
- tests/test_batch_size_tuner.py: search bounds, OOM sentinel, accuracy range
- tests/test_lr_tuner.py: local maximum detection and training call caching
- TF-dependent test files skip cleanly via pytest.importorskip when TF is absent
- Add conftest.py with shared mock_dataloader and mock_searcher_training fixtures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Runs on every push and PR across Python 3.11 and 3.12:
- Install uv and sync dev dependencies (no TF)
- ruff check for linting
- pytest (TF-dependent tests skip automatically)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Uses synthetic accuracy/time curves so the full search logic is exercisable
on any machine straight after cloning. Run with: uv run python demo.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add CI status badge
- Replace clone+pip instructions with uv/pip install sections
- Add Quick Start code snippet covering all three tuners
- Add Development section (pytest, ruff, uv build commands)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@outsidermm outsidermm self-assigned this May 25, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@outsidermm outsidermm merged commit 605a6c2 into main May 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant