Refactor package structure, add tests, and update documentation#25
Merged
Conversation
- 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>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
.github/workflows/ci.yml) for continuous integration, running linting and tests on Python 3.11 and 3.12 usinguvas the package manager..python-versionfile to specify Python 3.12 for development environments.Documentation & Developer Experience:
README.mdwith a CI badge, improved installation instructions (includinguvandpipoptions), quick start code examples, and development commands for linting, testing, and building. [1] [2]API & Usability Improvements:
EpochTuner,BatchSizeTuner, andLrTunerclasses to accept an optionaltraining_fnparameter, enabling dependency injection for easier testing and operation without TensorFlow or dataset files. Also addeddataset_dirparameter for flexible dataset paths. [1] [2] [3] [4] [5] [6]__init__.pyto thealgorithmpackage, exposing the main tuner classes for import.TensorFlow Dependency Handling:
training_fnis provided. Added helper for OOM error detection inBatchSizeTuner. [1] [2]Searcherto use local imports for TensorFlow and Keras, improving optional dependency handling.Code Quality & Robustness:
These changes collectively make the project easier to use, test, and extend, while also improving reliability and developer onboarding.