-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[pydap backend] enables downloading/processing multiple arrays within single http request #10629
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
base: main
Are you sure you want to change the base?
Conversation
|
hmm - the test I see that fails (sporadically) concerns the following assertion: where the groups have reverse ordering in the way dimensions show up ( |
shoyer
left a comment
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.
Thanks @Mikejmnez !
This is a little concerning! Not sure how this could be a bug on the Xarray side, unless we're using the wrong API for getting variable dimensions from Pydap. |
I'm seeing the same error over here: Not quite sure what to make of this, but seems to be a separate bug. |
|
Thanks @shoyer ! I am participating all week in a hackathon, but I will try to check and address your comments as fast as I can :) |
b3c77a0 to
aaa07c4
Compare
|
@shoyer I had a second go at this finally. Moved much of the logic to the backend. Here is the current state of things:
|
1687221 to
20fb5cd
Compare
|
@shoyer This is ready for further reviewing. Pydap has a new release that fixes some issues on the backend xml parser (there was a bug that got fixed). I think there may be some additional work to be needed in the next couple of weeks, but these are unrelated to this PR anyways...
|
aac3163 to
4b516b4
Compare
|
@shoyer Let me know if there is any feedback, concerns, further reviewing, etc. This PR enables a new (non-default) feature that was added to the pydap backend over the span of several months, namely the ability to download multiple variables within single request, according to the opendap spec. Without this feature, each variable is downloaded separately, which does not take advantage of the opendap protocol, and can make pydap unusable when each remote file has ~>2-3 variables, and there are at least >10 urls to consolidate (for example via mds = xr.open_mfdataset and then mdf.to_zarr or something). This PR also makes it so that when accessing via dap4 protocol, all dimensions are downloaded within single request by default, always. This is the most performant approach compared to downloading each dimension using a separate request. This again improves performance when "only opening" multiple remote files. |
35e390e to
9d819a2
Compare
| ~~~~~~~~~~~~ | ||
|
|
||
| - Improved ``pydap`` backend behavior and performance when using :py:func:`open_dataset`, :py:func:`open_datatree` when downloading dap4 (opendap) data (:issue:`10628`, :pull:`10629`). | ||
| ``batch=True|False`` is a new ``backend_kwarg`` that further enables downloading multiple arrays in single response. In addition ``checksums`` is added as optional argument to be passed to ``pydap`` backend. |
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.
Can you help me undestand -- why would a user not want to enable batch mode if they are using a new enough version of pydap?
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.
That is a good question. The route map for pydap is for batch=True always for dap4. So a dap4-url would automatically do this batch=true thingy. But right now, batch=true or false follow slightly different pathways internally within pydap (some of it very old, as you may know). In the roadmap for pydap, there is definitely is a major refactoring in sight.
FYI: Even when batch=False by default, dimension data is always batched (downloaded at once) when protocol= dap4, as long as they are using a "new enough version of pydap (>=3.5.6)" (see new line 177 on backends.pydap_). I think this is the first step to making this dap4 <--> batch=True in the future.
But enabling batch=True for streaming/downloading data that is being subset by Xarray (e.g. ds.isel(lat=slice1, lon=slice2).to_netcdf can become rapidly complex (in particular in the presence of hierarchies). I done plenty of testing (with both hierarchical data, and data on staggered grids), and while things work well so far, I think "soft launching" this feature on xarray makes the most sense to me. It seems safer to me at least.
…ed at once (per group)
b0826fe to
796ec7a
Compare
|
@shoyer any further comments? I'd be happy if at least some of the features within this PR are incorporated, specially the feature of always downloading all dimensions at once (i.e. single dap url for all N dims instead of N dap urls for N dims), when In the general case (which this PR enables), the user needs to specify |
whats-new.rstWith this PR, the following is true:
And so the dimensions are batched (downloaded) together in same always in DAP4.
In addition to this, and to preserve backwards functionality before, I added an backend argument
batch=True | False. Whenbatch=True, this makes it possible to download all non-dimension arrays in same response (ideal when streaming data to store locally).When
batch=False, which is the default, each non-dimension array is downloaded with its own http requests, as before. This is ideal in many scenarios when performing some data exploration.When
batch=False(Falseis the default) , the last step (ds.load()) triggers individual downloads.These changes allow a more performant download experience with xarray+pydap.
However ,must of these changes depend on a yet-to-release version of pydap (pydap3.5.6). I want to check that things go smoothly here before making a new release, i.e. perhaps I will need to make a change to the backend base code.3.5.6has been released!