Conversation
pnuu
left a comment
There was a problem hiding this comment.
Just one question and one typo fix inline. In general I'm fine with this.
| from multiprocessing import Process | ||
| p = Process(target=_create_netcdf_file, args=(filename, )) | ||
| p.start() | ||
| p.join() |
There was a problem hiding this comment.
Why this complication, does it help us in some way?
There was a problem hiding this comment.
yes, see the text I wrote in the PR note. Basically, it’s because in some environments (like mine), writing with netcdf4 and reading with h5netdf from the same process crashes, making all the h5netcdf tests fail in my case.
There was a problem hiding this comment.
Ah, ok. I didn't see the connection between the comment and the fixture.
Co-authored-by: Panu Lahtinen <[email protected]>
| # WARN: This is very confusing, but it seems to work: The reader_kwargs, when passed without a reader key, | ||
| # are put into a dictionary where keys are individual letters of the reader name, and the value is the | ||
| # reader kwargs; however, notice the `reader[idx]` part in the call here, as idx is 0 and thus the first | ||
| # letter of the reader is used to index `reader_kwargs_without_filter`, thus retrieving the correct | ||
| # reader_kwargs. |
There was a problem hiding this comment.
So basically this logic is incorrect and works by luck/chance and needs to be fixed?
There was a problem hiding this comment.
I'm not sure if it was the intended behaviour or not... It's working in the end, so maybe it is? But yeah, it would definitely benefit from a dedicated test and then a refactor...
There was a problem hiding this comment.
So what did you do to run into the issue? You called it from the Scene or noticed it within a test you already had?
Is this intended to not work? Is this a bug in h5netcdf then? Is it something that can or should be fixed upstream? The forking with the pytest flag I can kind of agree with...maybe, but the process creation inside the test file creation is too much for me when all of this comes down to an HDF5 issue from what we can tell. |
|
Oh and if you have error messages could you please put then in the PR description so in the future this PR is easily discoverable. |
|
I'm guessing you're running into the same issues users describe here when installing packages from PyPI: If you're able to reproduce this easily that'd be great for making progress on that issue. |
Good point! Here is the error I get from pytest repeatedly in the h5netcdf cases (and I tried creating coordinate variables, doesn't help, the only thing that helps is when netCDF4 is not loaded). TL;DR: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3331 +/- ##
==========================================
- Coverage 96.34% 96.33% -0.01%
==========================================
Files 463 463
Lines 58916 58854 -62
==========================================
- Hits 56760 56697 -63
- Misses 2156 2157 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if ds_id["name"] == "lat": | ||
| data = data.where((data > -90.0) & (data < 90.0), drop=True) | ||
| else: | ||
| # Is there such a case? | ||
| data = data.where((data.y > 0) & (data.y < len(data.y) - 1), drop=True) |
There was a problem hiding this comment.
@TAlonglong That's the part I'm unsure about...
|
|
||
|
|
||
| class TestGEOCATReader(unittest.TestCase): | ||
| @pytest.fixture(scope="session") |
There was a problem hiding this comment.
If these aren't used outside of this module then the scope should be module, not session.
This PR address caching scalar values in the netcdf util when using h5netcdf >= 1.7.0.
The solution (catching a ValueError on top of the IndexError) was already available, but in a duplicated part of the code that was not used for the caching part.
While setting up the test case corresponding to this issue and adding more h5netcdf engine tests (through simply parametrising existing tests to also use that engine), it became clear that netcdf4 and h5netcdf cannot be imported at the same time in some environments, hence the changes in the netcdf file creation fixture, the removal of netcdf4 as top level import, and the usage of pytest-forked in ci. For information, I am running on my RHEL9 laptop inside a uv environment with python 3.14.