feat: Set up complete Python testing infrastructure with Poetry - #25
feat: Set up complete Python testing infrastructure with Poetry#25llbbl wants to merge 1 commit into
Conversation
- Initialize Poetry package manager with pyproject.toml configuration - Add pytest, pytest-cov, and pytest-mock as development dependencies - Configure comprehensive pytest and coverage settings - Create tests directory structure with unit/integration subdirectories - Add shared fixtures in conftest.py for common testing patterns - Update .gitignore with testing and Claude-specific entries - Fix deprecated async=True syntax in utils.py for Python 3.8+ compatibility - Add validation tests to verify infrastructure setup
|
Hi, could you provide a bit more context on what this PR is? From a quick look, it seems like the tests are not actually testing for anything specific to the SWA implementation in this package? Overall, the implementation of SWA has been added to PyTorch (https://docs.pytorch.org/docs/stable/optim.html#weight-averaging-swa-and-ema), and this repo is just a minimal implementation to go with the paper for reference, rather than something that should actually be used in practice. |
|
Sure no problem. |
Set Up Python Testing Infrastructure
Summary
This PR establishes a complete testing infrastructure for the PyTorch SWA-Gaussian project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
pyproject.tomlwith Poetry configuration as the project's package managerTesting Configuration
pytest Configuration:
Coverage Settings:
models,utils, andtrainmodulesDirectory Structure
Testing Utilities
Created comprehensive fixtures in
conftest.py:temp_dir: Temporary directory managementmock_model: Mock PyTorch model for testingmock_optimizer: Mock optimizermock_dataloader: Mock data loader with sample datasample_checkpoint_data: Sample checkpoint structuremock_args: Mock command-line argumentscuda_available: CUDA availability checksmall_model: Simple neural network for testingreset_random_seeds: Reproducible random seedscapture_stdout: Output capture utilitiesmock_time: Time mocking for consistent measurementsAdditional Updates
async=Truetonon_blocking=Trueinutils.pyfor Python 3.8+ compatibilityUsage Instructions
Install Dependencies
Run Tests
Two equivalent commands are available:
Run Tests Without Coverage
poetry run test --no-covRun Specific Test Markers
Run Specific Test Files
poetry run test tests/test_infrastructure_validation.pyGenerate Coverage Reports
After running tests, coverage reports are available in:
htmlcov/index.html(HTML report)coverage.xml(XML report for CI/CD)Notes