-
Notifications
You must be signed in to change notification settings - Fork 303
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 FCI L1c reader for African products #2866
Conversation
…o enable the nominal padding mechanism (which should not be actually activated anyway)
…ducts is modified correctly
if self.filename_info["coverage"] == "AF": | ||
# change number of chunk from 0 to 1 so that the padding is not activated (chunk 1 is present and only 1 | ||
# chunk is expected), as the African dissemination products come in one file per full disk. | ||
self.filename_info["count_in_repeat_cycle"] = 1 |
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 sorts out the padding activation bug for the African products
@@ -897,24 +921,30 @@ def test_get_segment_position_info(self, reader_configs, fh_param, expected_pos_ | |||
segpos_info = filetype_handler.get_segment_position_info() | |||
assert segpos_info == expected_pos_info | |||
|
|||
@mock.patch("satpy.readers.yaml_reader.GEOVariableSegmentYAMLReader") |
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 mocking was preventing the test to actually test the execution
try: | ||
# attempt to load the channel | ||
reader.load([channel]) | ||
except KeyError: | ||
# If get_segment_position_info is called, the code will fail with a KeyError because of the mocking. | ||
# So we catch the error here for now, but the test will still fail with the following assert_not_called | ||
pass | ||
gspi.assert_not_called() |
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 let the code run accepting the errors due to the mocking, but would still fail when checking the function call
reader_configs, compare_tuples) | ||
|
||
@pytest.mark.parametrize(("channel", "resolution", "compare_tuples"), | ||
[("vis_06", "3km", (1, 10, |
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.
changing from 0 to 1 here checks that the chunk numbering is modified correctly
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2866 +/- ##
==========================================
+ Coverage 95.97% 95.99% +0.01%
==========================================
Files 368 368
Lines 53973 53985 +12
==========================================
+ Hits 51801 51821 +20
+ Misses 2172 2164 -8
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 10302081017Warning: 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 |
except KeyError: | ||
# If get_segment_position_info is called, the code will fail with a KeyError because of the mocking. | ||
# So we catch the error here for now, but the test will still fail with the following assert_not_called | ||
pass |
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.
Is there something we can do besides except->pass? Maybe https://docs.python.org/3/library/contextlib.html#contextlib.suppress? Or what about no except
at all? I guess maybe I'm confused why a KeyError would get to this level of execution and we shouldn't care about it?
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 switched to suppress, that's a good idea, thanks! I also tried to clarify a bit more my comment in the code for why the test is setup like this.
In other words: without the fix of this PR, get_segment_position_info
would be called (which we don't want), and would then currently fail with KeyError
. My point is that we want to test that the function is not called at all, which is what the test is doing. If instead we would check for the KeyError
to happen, someone could technically change get_segment_position_info
to avoid the KeyError
, the test would then pass, but the bug/unexpected behaviour would likely still be there.
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.
Hhhmmm ok. My other suggestion was going to be a try/finally or to do the assert in the except clause, but then as you said it could be skipped depending on how someone changed the code. Ok. I guess this is good with me then. I do assume you've done way more testing than I will be able to analyze from the code.
…iles can be read at the same time and the highest resolution is picked, as with with the normal 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.
LGTM, thanks for taking the time to clean up the code also. I really like when we get rid of mocking :)
This PR fixes the
fci_l1c_nc
reader for the African products, after #2843 introduced/exposed a bug.#2843 changes the filename pattern from
erraneous_count_in_repeat_cycle
tocount_in_repeat_cycle
. With this, this line:satpy/satpy/readers/yaml_reader.py
Line 1192 in bf0d9cd
does not use the
get
default1
value anymore, but uses the actual value coming from the actual filepattern, which is0
. This then activates the padding mechanism, which then fails due tofci_l1c_nc.FCIL1cNCFileHandler.get_segment_position_info
not supporting the African products (as it shouldn't need to).The test that was specifically implemented to check that
get_segment_position_info
is not called, and that should have failed in the #2843 PR, was faulty due to an extra unnecessary mocking that was invalidating the test.This PR
get_segment_position_info
execution by assigning the chunk number1
to the African products, so that the padding does not get activated (1 chunk is present and one is expected).On top
WV
useIR
in the filenameSorry for the noise of the reformatting, to make the review easier I have marked with comments the actual relevant code changes.