Uh oh!
There was an error while loading. Please reload this page.
Zarr: Optimize region="auto" detection - #8997
Merged
Merged
Conversation
dcherian
commented
May 3, 2024
| for k, v in self.get_variables().items() | ||
| if k in existing_variable_names | ||
| }, | ||
| {k: self.open_store_variable(name=k) for k in existing_variable_names}, |
ContributorAuthor
There was a problem hiding this comment.
Just open the needed variables instead of opening all of them.
dcherian
commented
May 3, 2024
Comment on lines
+807
to
+812
| variable = conventions.decode_cf_variable( | ||
| dim, self.open_store_variable(dim).compute() | ||
| ) | ||
| assert variable.dims == (dim,) | ||
| index = pd.Index(variable.data) | ||
| idxs = index.get_indexer(ds[dim].data) |
ContributorAuthor
There was a problem hiding this comment.
Lines 812-817: This is the main logic change.
dcherian
commented
May 3, 2024
| region[dim] = slice(idxs[0], idxs[-1] + 1) | ||
| return region | ||
| def _validate_and_autodetect_region(self, ds, region) -> dict[str, slice]: |
dcherian
commented
May 3, 2024
| write_empty=write_empty_chunks, | ||
| ) | ||
| if region is not None: |
ContributorAuthor
There was a problem hiding this comment.
Moved down so we only open the Zarr store once.
dcherian
commented
May 3, 2024
| ds = xr.Dataset({"foo": ("x", np.arange(30))}, coords={"x": np.arange(30)}) | ||
| # Any of the following region specifications are valid | ||
| ds.isel(x=slice(0, 10)).to_zarr(path, region="auto") | ||
| ds.isel(x=slice(10, 20)).to_zarr(path, region={"x": "auto"}) |
ContributorAuthor
There was a problem hiding this comment.
This last line does not do what it looks like it's doing if there are no indexes!
region="auto" detectionmax-sixty
commented
May 4, 2024
Collaborator
Looks great! |
dcherian
commented
May 7, 2024
ContributorAuthor
Thanks for taking a look, Max! |
andersy005 pushed a commit
that referenced
this pull request
May 10, 2024
* Zarr: Optimize region detection * Fix for unindexed dimensions. * Better example * small cleanup
andersy005 added a commit
that referenced
this pull request
May 10, 2024
* main: Avoid auto creation of indexes in concat (#8872) Fix benchmark CI (#9013) Avoid extra read from disk when creating Pandas Index. (#8893) Add a benchmark to monitor performance for large dataset indexing (#9012) Zarr: Optimize `region="auto"` detection (#8997) Trigger CI only if code files are modified. (#9006) Fix for ruff 0.4.3 (#9007) Port negative frequency fix for `pandas.date_range` to `cftime_range` (#8999) Bump codecov/codecov-action from 4.3.0 to 4.3.1 in the actions group (#9004) Speed up localize (#8536) Simplify fast path (#9001) Add argument check_dims to assert_allclose to allow transposed inputs (#5733) (#8991) Fix syntax error in test related to cupy (#9000)
andersy005 added a commit
to hmaarrfk/xarray
that referenced
this pull request
May 10, 2024
* backend-indexing: Trigger CI only if code files are modified. (pydata#9006) Enable explicit use of key tuples (instead of *Indexer objects) in indexing adapters and explicitly indexed arrays (pydata#8870) add `.oindex` and `.vindex` to `BackendArray` (pydata#8885) temporary enable CI triggers on feature branch Avoid auto creation of indexes in concat (pydata#8872) Fix benchmark CI (pydata#9013) Avoid extra read from disk when creating Pandas Index. (pydata#8893) Add a benchmark to monitor performance for large dataset indexing (pydata#9012) Zarr: Optimize `region="auto"` detection (pydata#8997) Trigger CI only if code files are modified. (pydata#9006) Fix for ruff 0.4.3 (pydata#9007) Port negative frequency fix for `pandas.date_range` to `cftime_range` (pydata#8999) Bump codecov/codecov-action from 4.3.0 to 4.3.1 in the actions group (pydata#9004) Speed up localize (pydata#8536) Simplify fast path (pydata#9001) Add argument check_dims to assert_allclose to allow transposed inputs (pydata#5733) (pydata#8991) Fix syntax error in test related to cupy (pydata#9000)
This file contains hidden or 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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ZarrStoreso we only open the store once.pd.Indexdirectly to "auto"-infer the region.The diff is large mostly because a bunch of code moved from
backends/api.pytobackends/zarr.py