-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Lock related problem in on travis-ci but not on local machine #2560
Comments
Thanks for the report! This might be an xarray issue, or it might also be a netCDF4 issue -- I wonder if you might have different versions of libnetcdf installed locally and on Traivs-CI? |
Could you share a link the file in which these tests are defined? I couldn't find it on the master branch. |
I am having the exact same problem. Have you found a solution/workaround? |
if you have a simpler example, that would make things easier to debug. The error you're seeing here is basically "HDF5 encountered an error" which could happen for any number of reasons. |
Sorry guys. I've found the problem and solution. The problem is that filesystem not supporting lock mechanism. The solution is to export the following variable: |
OK, I think I understand what's going on here and why this issue only appears with xarray v0.11. The problem is related to how you are opening files with xarray but not closing them: With v0.11, xarray introduced a least-recently-used cache for netCDF files. This means xarray's LRUCache is holding on to a reference to your files, so they never get garbage collected, and automatically closed by netCDF4-Python. Hence the HDF5 locks never get released. Although it is indeed a good practice to always explicitly close files, I think we should explore using weak references to keep track of files in our cache so we don't hold on to them for holding than necessary. |
If either of you have time, it would be great if you could test out #2595 to see if that resolves your issue without requiring the environment variable. |
I have done a bit more testing on this, and I believe the issue may not necessarily be with I can reproduce the following on Ubuntu and on Travis CI. On Mac OS none of these errors occur. Minimum example: import xarray as xr
import numpy as np
import rasterio # The rasterio import makes the last line of this code fail.
ds = xr.Dataset()
ds['data'] = (('y', 'x'), np.ones((10, 10)))
ds.to_netcdf('test.nc', engine='netcdf4') I was able to fix the error by prepending a import netCDF4 at the very top of the script. A very similar thing happens with |
See also #2535 for rasterio/netCDF4 issues. |
There is a
KeyError
atxarray.backends.file_manager.CachingFileManager
for theacquire
method on these lines:which does not happen when I test on my macos.
Let me know if you require further testing on my part.
Full log:
The text was updated successfully, but these errors were encountered: