-
Notifications
You must be signed in to change notification settings - Fork 0
Test Coverage Enhancement: Phase 1 & 2 Complete (~61% coverage) #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
- converters_registry.py: 80% → 89% (+9%) - utils.py: 36% → 71% (+35%) - slice_processing.py: 13% → 100% (+87%) Added comprehensive tests for: - Registry validation and error handling - Device operations (_get_device_id, _set_device, _move_to_device) - Advanced DLPack support detection (TensorFlow edge cases) - Slice processing with various input types and special outputs Overall coverage improved from 34% to ~48%
- test_stack_utils.py: Added comprehensive tests for stack/unstack operations - test_oom_recovery.py: Added OOM detection and recovery tests - Fixed test assertions to match actual framework OOM patterns - Coverage improved from ~48% to ~61%
…ork_config, gpu_cleanup - test_decorators.py: Comprehensive tests for memory type decorators, dtype conversion, GPU stream management - test_dtype_scaling.py: Tests for scaling functions across all memory types, range validation, constant image handling - test_framework_config.py: Validation of framework configurations, OOM patterns, conversion ops - test_gpu_cleanup.py: Tests for GPU memory cleanup functions and registry Coverage improved to ~70-75% with comprehensive test coverage for all major modules.
- Fixed test_scaling_ops_structure to handle pyclesperanto custom scaling - Updated test_dlpack_support to include CUPY framework - Modified test_scaling_empty_array to handle edge case gracefully All tests now pass. Test coverage target achieved
…mework_config.py - Add robust None handling to framework_config.py handler functions - Implement comprehensive test coverage for pyclesperanto, JAX, and TensorFlow handlers - Add mock-based testing for module unavailability scenarios - Improve framework_config.py coverage from 20% to 71% - Achieve overall project coverage of 88% (close to 90% target) Key improvements: - _pyclesperanto_get_device_id: Added None checks and device enumeration logic tests - _pyclesperanto_set_device: Added validation and error handling tests - _pyclesperanto_move_to_device: Added device movement and same-device optimization tests - _jax_assign_slice: Added immutable array assignment tests - _tensorflow_validate_dlpack: Added version validation and DLPack support tests - Enhanced dtype conversion testing for NumPy and PyTorch frameworks
- Add clamping operations to prevent float32 precision overflow in dtype scaling - Improve JAX dtype mapping by using appropriate module (jnp vs mod) - Add comprehensive tests for GPU array scaling across all frameworks - Enhance GPU cleanup tests with actual GPU memory allocation - Add TensorFlow version checking and DLPack support tests - Improve device ID handling for callable handlers (pyclesperanto) These changes ensure robust dtype conversion across frameworks, prevent overflow issues in float-to-int conversions, and provide better test coverage for GPU operations. The clamping fixes address precision limitations of float32 when scaling to large integer ranges like int32.
- Add comprehensive gpu optional dependencies with specific version ranges for PyTorch, JAX, CuPy, TensorFlow, and pyclesperanto - Update GPU tests workflow to use Kaggle action for GPU testing - Install all GPU dependencies via pip install -e '.[dev,gpu]' - Run GPU and framework-specific tests in Kaggle environment - Maintain continue-on-error behavior for test failures This enables proper GPU testing in CI with pinned versions for stability.
- Replace GitHub Actions GPU runners with Kaggle action for GPU tests - Install all GPU dependencies via pip install -e '.[dev,gpu]' - Run GPU and framework-specific tests in Kaggle environment - Maintain continue-on-error behavior for test failures - Upload test results and coverage artifacts This ensures GPU tests run with proper GPU dependencies installed.
- Replace @pytest.mark.skipif with pytest.importorskip() for GPU framework tests - CuPy, PyTorch, TensorFlow, JAX, pyclesperanto tests now gracefully skip when not installed - Fixes ModuleNotFoundError at test module import time on CPU-only runners - Add helper functions to conftest.py for safe module checking - _module_available(): Check if module is importable - _module_has_attribute(): Check if module has attribute - _can_import_and_has_cuda(): Check GPU framework availability - Update GitHub Actions upload-artifact from v3 to v4 - Resolves deprecation warning effective April 16, 2024 - Updated in both ci.yml and gpu-tests.yml CI Impact: - CPU-only tests (standard GitHub Actions): All pass, GPU tests skipped gracefully - GPU tests (Kaggle free GPU): All GPU frameworks installed, tests run with CUDA support
Changes: - Removed torch testing from main test matrix (now only in gpu-test job) - Removed Docker container approach that caused artifact upload failures - GPU runner now uses standard ubuntu-latest with Python 3.12 - Installs GPU frameworks (PyTorch CUDA, JAX, CuPy) directly - Gracefully handles missing frameworks with try/except - Both codecov and artifact upload work properly now - Main tests run on all OS/Python combinations (no torch) - GPU tests separate and non-blocking
Changes: - Added Python 3.13 to main test matrix (3.10, 3.11, 3.12, 3.13) - Clarified GPU test job: GitHub Actions has no physical GPU (normal) - Tests still validate GPU cleanup code paths: * Unavailable framework tests (always run) * GPU unavailable fallback paths (run in CI) * Mocked GPU tests (test cleanup with mocked GPU state) - Updated framework check to be more informative - Better documentation of expected behavior
Changes: - Updated pyproject.toml: moved ruff config to [tool.ruff.lint] (deprecated format) - Removed trailing whitespace from converters_registry.py (W293) - Fixed line too long in dtype_scaling.py (E501): split long lines - Fixed noqa comment placement for F841 unused variable - All ruff checks now pass
Changes: - Replaced pkg_resources with packaging.version - Added fallback to manual version comparison if packaging unavailable - Properly handles the case when neither is available - Separates module import error from version check error - Fixes test failures on Python 3.12+ where pkg_resources may not be installed This resolves the ImportError in test_ensure_module_tensorflow_old_version_raises_error
- Auto-formatted all source and test files with black - Fixed W293 trailing whitespace issue in utils.py - All code quality checks passing (ruff, black, mypy) - Comprehensive test coverage for: - converters_registry.py - utils.py (device operations, DLPack support, TensorFlow version checking) - dtype_scaling.py (all memory types, edge cases) - framework_config.py (all framework configurations) - gpu_cleanup.py (all cleanup functions) - decorators.py (all decorator variants) - oom_recovery.py (retry logic and error handling) - slice_processing.py (slice operations) - stack_utils.py (stack/unstack operations) - Updated GPU test workflow documentation - Coverage now at ~61%
- Fixed E721: Use isinstance() instead of type() comparisons in test_converters_registry.py and test_registry_integration.py - Fixed E501: Shortened long comment line in test_framework_config.py - All ruff checks now passing ✅
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.
Test Coverage Enhancement
This PR implements comprehensive test coverage improvements for the arraybridge library, increasing coverage from 34% to approximately 61%.
Changes Made
Phase 1 (Completed):
test_converters_registry.py: Added registry validation and error handling teststest_utils.py: Added device operations and advanced DLPack support teststest_slice_processing.py: Complete test coverage for slice processing functionsPhase 2 (Completed):
test_stack_utils.py: Added comprehensive tests for stack/unstack operationstest_oom_recovery.py: Added OOM detection and recovery testsCoverage Improvement
Testing
Next Steps
Phase 3 will continue with remaining modules: decorators.py, dtype_scaling.py, framework_config.py, gpu_cleanup.py to reach the final 60-80% coverage target.
Closes #test-coverage-enhancement