-
Notifications
You must be signed in to change notification settings - Fork 11
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
fix: Workaround for lack of zsd support in czifile #1142
Conversation
WalkthroughRecent updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CziImageReader
participant image_file
User->>CziImageReader: read(image_path, mask_path, ext)
CziImageReader->>CziImageReader: Determine max_workers
CziImageReader->>image_file: asarray(max_workers)
image_file->>CziImageReader: Return image data
CziImageReader->>User: Return Image
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
🧙 Sourcery has finished reviewing your pull request! Tips
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- package/PartSegImage/image_reader.py (3 hunks)
Additional comments not posted (6)
package/PartSegImage/image_reader.py (6)
6-6
: LGTM! New imports are appropriate.The new imports are necessary for the new functionalities introduced related to ZSTD decoding and version checking.
Also applies to: 11-11, 17-17
28-37
: LGTM! ClassZSTD1Header
is well-defined.The class represents the header structure for ZSTD1 compression and references an external source for clarity.
39-57
: LGTM! Functionparse_zstd1_header
is correctly implemented.The function parses the header for ZSTD1 compression using data and size parameters and references an external source for accuracy.
60-61
: Potential maintenance issue with_get_dtype
.The function relies on specific assumptions about the calling context, which could lead to maintenance challenges. Ensure that the context in which this function is used is well-documented and consistent.
81-83
: LGTM! Dictionary modifications are appropriate.The
DECOMPRESS
dictionary is correctly updated to handle ZSTD0 and ZSTD1 decoding.
335-335
: LGTM! Addition ofmax_workers
parameter is beneficial.The
max_workers
parameter potentially improves performance by enabling parallel processing.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1142 +/- ##
===========================================
+ Coverage 93.01% 93.02% +0.01%
===========================================
Files 207 207
Lines 32658 32700 +42
===========================================
+ Hits 30376 30420 +44
+ Misses 2282 2280 -2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- package/PartSegImage/image_reader.py (3 hunks)
- package/tests/test_PartSegImage/test_image_reader.py (1 hunks)
Additional comments not posted (7)
package/tests/test_PartSegImage/test_image_reader.py (1)
38-45
: LGTM!The test function
test_czi_file_read_compressed
is well-written and effectively tests the decompression functionality of CZI files.package/PartSegImage/image_reader.py (6)
1-17
: LGTM!The new imports are necessary and correctly imported.
28-37
: LGTM!The class
ZSTD1Header
is well-defined and includes appropriate attributes with a clear docstring.
39-57
: LGTM!The function
parse_zstd1_header
is well-written and includes a clear docstring. The logic for parsing the header is correct.
60-61
: LGTM!The function
_get_dtype
correctly determines the data type usinginspect
.
343-343
: LGTM!The addition of the
max_workers
parameter in theimage_file.asarray()
call potentially improves performance by leveraging parallel processing.
81-86
: Replacenp.fromstring
withnp.frombuffer
.The function decodes ZSTD0 data correctly, but
np.fromstring
is deprecated.- return np.fromstring(imagecodecs.zstd_decode(data), dtype) + return np.frombuffer(imagecodecs.zstd_decode(data), dtype)Likely invalid or redundant comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- package/PartSegImage/image_reader.py (4 hunks)
- package/tests/test_PartSegImage/test_image_reader.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- package/PartSegImage/image_reader.py
Additional comments not posted (1)
package/tests/test_PartSegImage/test_image_reader.py (1)
6-6
: Review of New Imports, Fixtures, and Test Functions
New Imports:
- The imports on lines 6 and 12 (
version
fromimportlib.metadata
andparse_version
frompackaging.version
) are correctly added and relevant to the new features being tested, particularly the version checking forczifile
.New Fixture
_set_max_workers_czi
:
- This fixture correctly sets the
CZI_MAX_WORKERS
to 1 usingmonkeypatch
. This is a good practice to ensure that the tests are not affected by parallel execution environments which might introduce non-determinism.New Test
test_czi_file_read_compressed
:
- The test uses version checking to skip tests for versions of
czifile
below2019.7.2
, which is a good practice to ensure backward compatibility.- The use of
pytest.mark.parametrize
to test multiple file types (test_czi_zstd0.czi
,test_czi_zstd1.czi
,test_czi_zstd1_hilo.czi
) is excellent for ensuring that all relevant cases are covered.- Assertions in the test are comprehensive, checking for non-zero channel data, correct number of channels and layers, file path correctness, and spatial dimensions.
Assertions:
- The assertions on lines 39 and 67 are crucial for verifying the integrity and correctness of the image data loaded from different types of CZI files.
These changes are well-implemented and follow good testing practices. No further action is required unless additional test scenarios are considered necessary.
Also applies to: 12-12, 18-22, 39-39, 47-61, 67-67
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- package/PartSegImage/image_reader.py (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- package/PartSegImage/image_reader.py
Workaround for bug reported cgohlke/czifile#10
Summary by CodeRabbit
New Features
max_workers
parameter for improved image processing performance.Tests
fix PARTSEG-V0