-
-
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
Load nonindex coords ahead of concat() #1551
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e626a9b
Merge remote-tracking branch 'upstream/master'
gimperiale 398ac28
Load non-index coords to memory ahead of concat
gimperiale 32c9145
Merge remote-tracking branch 'upstream/master' into load_nonindex_coords
gimperiale fcc96c9
Merge remote-tracking branch 'upstream/master' into load_nonindex_coords
gimperiale 1065f4c
Update unit test after #1522
gimperiale 0ae6cf4
Merge remote-tracking branch 'upstream/master' into load_nonindex_coords
gimperiale ab90318
Minimise loads on concat. Extend new concat logic to data_vars.
gimperiale 68d51c6
Trivial tweaks
gimperiale 1c30474
Added unit tests
gimperiale 72cf0e7
Merge remote-tracking branch 'upstream/master' into load_nonindex_coords
gimperiale f99313c
Add xfail for #1586
gimperiale 9f51711
Merge remote-tracking branch 'upstream/master' into load_nonindex_coords
gimperiale 2f80cef
Revert "Add xfail for #1586"
gimperiale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,17 @@ def differs(vname): | |
return concat_over | ||
|
||
|
||
def _load_coords(dataset): | ||
"""Load into memory any non-index coords. Preserve original. | ||
""" | ||
if all(coord._in_memory for coord in dataset.coords.values()): | ||
return dataset | ||
dataset = dataset.copy() | ||
for coord in dataset.coords.values(): | ||
coord.load() | ||
return dataset | ||
|
||
|
||
def _dataset_concat(datasets, dim, data_vars, coords, compat, positions): | ||
""" | ||
Concatenate a sequence of datasets along a new or existing dimension | ||
|
@@ -208,6 +219,8 @@ def _dataset_concat(datasets, dim, data_vars, coords, compat, positions): | |
dim, coord = _calc_concat_dim_coord(dim) | ||
datasets = [as_dataset(ds) for ds in datasets] | ||
datasets = align(*datasets, join='outer', copy=False, exclude=[dim]) | ||
# TODO: compute dask coords with a single invocation of dask.compute() | ||
datasets = [_load_coords(ds) for ds in datasets] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only need this if the argument |
||
|
||
concat_over = _calc_concat_over(datasets, dim, data_vars, coords) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Yes, this would be even better :).
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.
I didn't bother as it would be a considerable complication and it would not do any good in the most common case where the "dask" variable is just a lazy load from disk