-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Obscure h5netcdf http serialization issue with python's http.server #6662
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
Python's HTTP server does not normally provide content lengths without some extra work, that might be the difference. |
Don't think that's it.
|
The with fsspec.open('http://127.0.0.1:8000/tiny.nc', mode='rb') as fp:
with xr.open_dataset(fp, engine='h5netcdf') as ds1:
ds1.load() |
Can you please explicitly check the |
with fsspec.open('http://127.0.0.1:8000/tiny.nc', mode='rb') as fp:
with xr.open_dataset(fp, engine='h5netcdf') as ds1:
print(type(fp))
print(fp.__dict__)
ds1.load()
|
Following up on the suggestion from @shoyer in to not use a context manager, if I redefine my function as def open_pickle_and_reload(path):
of = fsspec.open(path, mode='rb').open()
ds1 = xr.open_dataset(of, engine='h5netcdf')
# pickle it and reload it
ds2 = loads(dumps(ds1))
ds2.load() ...it appears to work fine. |
What is your issue?
In Pangeo Forge, we try to test our ability to read data over http. This often surfaces edge cases involving xarray and fsspec. This is one such edge case. However, it is kind of important, because it affects our ability to reliably test http-based datasets using python's built-in http server.
Here is some code that:
python -m http.server
.load()
to load the data into memoryAs you can see, this works with a local file, but not with the http file, with h5py raising a checksum-related error.
full traceback
Strangely, a similar workflow does work with http files hosted elsewhere, e.g.
This suggests there is something peculiar about python's
http.server
as compared to other http servers that makes this break.I would appreciate any thoughts or ideas about what might be going on here (pinging @martindurant and @shoyer)
xref:
The text was updated successfully, but these errors were encountered: