-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Inconsistent File Hashes When Resaving NetCDF Files with Chunks #10028
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
Comments
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! |
Do you see a difference in |
Thanks for your quick response @dcherian! I don't see a difference in Test data saved without chunks:
Test data saved with chunks:
|
Ah I missed the dask dependency. Reminds me of #7522 |
@NoraLoose Can you check this please with |
If I set
So like #7522, there's something about the parallel write that changes the metadata. EDIT: Sadly this implies this issue is hard to fix. You could instead read back the Dataset with |
Thanks @dcherian and @kmuehlbauer! I see some differences when using Without chunks:
With chunks (first save):
|
@dcherian Agreed, comparing the metadata somehow needs to be skipped. If I change my
I get consistent file hashes throughout:
|
Nice if you are going to do this, I recommend using xxhash to save some time. |
Great, I think we can close this issue. Thanks again for your input @dcherian and @kmuehlbauer! |
What happened?
When resaving a NetCDF file using
xarray
, the resulting file has a consistent hash if opened without chunks. However, when the dataset is opened with chunks and resaved, the file hash changes with each save, even if the data remains unchanged. This behavior suggests non-deterministic output when working with chunked datasets.What did you expect to happen?
I expect that resaving a dataset, whether opened with or without chunks, should produce deterministic file output if the data remains unchanged. This is particularly important for workflows that rely on file integrity checks.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
INSTALLED VERSIONS
commit: None
python: 3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:24:40) [GCC 13.3.0]
python-bits: 64
OS: Linux
OS-release: 5.14.21-150400.24.46-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.2
libnetcdf: 4.9.4-development
xarray: 2024.10.0
pandas: 2.2.3
numpy: 1.26.4
scipy: 1.14.1
netCDF4: 1.7.2
pydap: None
h5netcdf: None
h5py: None
zarr: 2.18.4
cftime: 1.6.4.post1
nc_time_axis: None
iris: None
bottleneck: 1.4.2
dask: 2025.1.0
distributed: 2025.1.0
matplotlib: 3.9.2
cartopy: 0.24.1
seaborn: None
numbagg: None
fsspec: 2024.12.0
cupy: None
pint: None
sparse: 0.15.4
flox: None
numpy_groupies: None
setuptools: 69.5.1
pip: 24.0
conda: None
pytest: 8.3.4
mypy: None
IPython: 8.29.0
sphinx: None
The text was updated successfully, but these errors were encountered: