fix: address PR review feedback - warning emission, cached_property compatibility, and documentation#62
Conversation
Co-authored-by: rhoadesScholar <37990507+rhoadesScholar@users.noreply.github.com>
…m_workers Co-authored-by: rhoadesScholar <37990507+rhoadesScholar@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses critical review feedback from PR #61, fixing issues with warning emission, a TypeError bug in dataset sizing, cached_property compatibility, and documentation accuracy.
Changes:
- Fixed warning emission in datasplit.py, multidataset.py, and image.py by replacing instantiated Warning objects with
logger.warning()calls - Fixed TypeError in
CellMapDataset.sizeproperty by changing.items()to.values()to properly unpack bounding box numeric bounds - Fixed
CellMapDataset.empty()to be compatible with@cached_propertyby directly setting__dict__["sampling_box_shape"] - Updated dataloader.py documentation to reflect current implementation (
arrayinstead of_array) and clarify tensorstore_cache_bytes behavior with minimum 1-byte allocation - Added test coverage for cache warning emission when cache budget is insufficient for worker count
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_dataloader.py | Added test to verify warning emission and 1-byte minimum enforcement when tensorstore_cache_bytes < num_workers |
| src/cellmap_data/multidataset.py | Fixed warning emission in validation_indices property to use logger.warning() instead of instantiating UserWarning |
| src/cellmap_data/image.py | Fixed warning emission in array property to use logger.warning() instead of instantiating Warning/UserWarning objects |
| src/cellmap_data/datasplit.py | Fixed warning emission in validation_datasets_combined to use logger.warning() instead of instantiating UserWarning |
| src/cellmap_data/dataset.py | Fixed TypeError in size property (.items() → .values()) and cached_property compatibility in empty() method |
| src/cellmap_data/dataloader.py | Updated documentation for module docstring and tensorstore_cache_bytes parameter to reflect current implementation |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## improve_cache #62 +/- ##
=================================================
+ Coverage 70.33% 70.48% +0.15%
=================================================
Files 28 28
Lines 2451 2450 -1
=================================================
+ Hits 1724 1727 +3
+ Misses 727 723 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot The TypeError in CellMapDataset.size property (.items() where it should have been .values() to properly unpack bounding box numeric bounds) should have been caught by tests. Why wasn't it? Add tests to improve coverage of this patch. |
Co-authored-by: rhoadesScholar <37990507+rhoadesScholar@users.noreply.github.com>
The bug wasn't caught because the Added three new tests in commit ffb91b9:
These tests now ensure the |
Addresses 8 review comments on PR #61 regarding improper warning emission, a critical bug in the
sizeproperty,cached_propertycompatibility issues, and missing documentation.Warning Emission Fixes
UserWarning(...)/Warning(...)instantiation withlogger.warning()calls. Previously warnings were constructed but never emitted, silently hiding validation failures and fallback behaviors.Critical Bug Fixes
dataset.py
sizeproperty: FixedTypeErrorfrom.items()yielding(axis, [start, stop])tuples. Changed to.values()to properly unpack numeric bounds:dataset.py
empty()method: Fixed incompatibility with@cached_propertydecorator. Changed from setting_sampling_box_shapeattribute to directly populating__dict__["sampling_box_shape"]to bypass property computation.Documentation Updates
dataloader.py module docstring: Updated stale reference from
"_array"to"array"to match current@cached_propertyimplementation.dataloader.py
tensorstore_cache_bytesparameter: Clarified that whencache_bytes < num_workers, each worker receives minimum 1 byte (not 0, which TensorStore treats as unlimited), causing aggregate cache to exceed the requested total.Test Coverage
test_warning_when_cache_less_than_workersto verify warning emission and 1-byte minimum enforcement when cache budget is insufficient for worker count.sizeandbounding_box_shapeproperties: Three new tests (test_bounding_box_shape,test_size_property,test_size_property_with_known_dimensions) ensure the.values()fix is covered and validate that these previously untested properties work correctly. Thesizeproperty bug wasn't caught by existing tests because the property was never accessed in any test or internal code path.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.