-
Notifications
You must be signed in to change notification settings - Fork 295
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
Implement py public decomp wt hrit base #2903
Implement py public decomp wt hrit base #2903
Conversation
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.
Thanks a lot for looking into replacing the xrit decompression with this nice library!
That removes quite some code, which is really nice :)
I have a couple of comments inline, but also a few questions:
Do we have tests that cover this new functionality? I would suspect we don't, because we don't have a test compressed hrit file in the repo. If I'm right, I was wondering if pyPulbicDecompWT
also provides a function to compress a file? Because we are creating stub hrit files for testsing, so if we could compress one, we could actually test the decompression.
pyproject.toml
Outdated
@@ -16,6 +16,7 @@ dependencies = [ | |||
"pykdtree", | |||
"pyorbital", | |||
"pyproj>=2.2", | |||
"pyPublicDecompWT", |
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.
I think this should be in the optional dependencies for seviri_l1b_hrit rather than here, right?
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.
Yes, this is correct. Note that the seviri_l1b_hrit
reader will no longer be available without explicitly installing the necessary dependencies. Therefore, the default functionalities after a plain pip install satpy
will change slightly. Even for reading uncompressed HRIT files, the pyPublicDecompWT
package will be required. From my perspective, this is not an issue.
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.
This is an issue for at least us, as we want to keep the containers used in production as minimal as possible. Our file transfer system (Trollmoves) already decompresses the HRIT files so we don't need the decompression library installed. So pyPublicDeompWT
should be an optional extra, as it is also simple to make it such.
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.
Ok, so I think we need to move that dependency to the optional dependency part.
But also, in order to keep backwards compatibility, we should do the import inside the decompress
function. Otherwise, as you say, the library needs to be installed even when reading non-compressed data.
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.
ok, I have moved it to the optional dependencies
Also the tests are failing because pyPublicDecompWT is not included in the environment file for github actions: https://github.com/pytroll/satpy/blob/main/continuous_integration/environment.yaml |
Co-authored-by: Martin Raspaud <martin.raspaud@smhi.se>
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.
Simple changes to make the decompression library optional.
@Graenni CI is failing, is the |
@mraspaud yes, I am able to successfully read and process compressed HRIT files. |
Which Python version are you using while running Satpy locally? The error is FAILED satpy/tests/reader_tests/test_hrit_base.py::TestHRITFileHandlerCompressed::test_read_band_filepath - TypeError: a bytes-like object is required, not 'str' I'll see what I get running the tests, but first lunch 😁 |
I run Python3.11. I can successfully load seviri l1b hrit with compression. |
I get the same error while running the tests locally. Do they pass for you? |
That is, does |
I added a debugger break-point in the |
No wonder the function is not called as the first mock just overrides it: with mock.patch("satpy.readers.hrit_base.decompress", side_effect=fake_decompress) as mock_decompress: |
I did not run the tests locally so far, sorry. I just used satpy with the changes of this pr as I would normally and then the decompression worked as expected. Seems to be an issue with the way tests are configured as you already figured out. |
@Graenni I think I fixed the tests, can you check my changes and tell me if the fake decompression is inline with what you expect? |
I got |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2903 +/- ##
=======================================
Coverage 96.06% 96.07%
=======================================
Files 370 371 +1
Lines 54320 54288 -32
=======================================
- Hits 52185 52158 -27
+ Misses 2135 2130 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Pull Request Test Coverage Report for Build 10922986535Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
@mraspaud yes, the return value of fake_decompress is in agreement with what is returned by the original decompress function. |
I'm merging this, thanks for the contribution @Graenni ! |
AUTHORS.md
if not there already