-
-
Notifications
You must be signed in to change notification settings - Fork 377
fix/nested shard reads #3655
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
Open
d-v-b
wants to merge
7
commits into
zarr-developers:main
Choose a base branch
from
d-v-b:fix/nested-shard-reads
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+33
−28
Open
fix/nested shard reads #3655
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4379a66
fix partial nested shard reads
d-v-b 9255369
Merge branch 'main' into fix/nested-shard-reads
d-v-b 0282f30
changelog
d-v-b 99bcb81
Merge branch 'main' of github.com:zarr-developers/zarr-python into fi…
d-v-b 19e0e0c
Merge branch 'fix/nested-shard-reads' of github.com:d-v-b/zarr-python…
d-v-b 3270fe3
Merge branch 'main' into fix/nested-shard-reads
d-v-b 38015ae
Merge branch 'main' into fix/nested-shard-reads
d-v-b 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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixed a bug in the sharding codec that prevented nested shard reads in certain cases. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ | |
| TransposeCodec, | ||
| ) | ||
| from zarr.core.buffer import NDArrayLike, default_buffer_prototype | ||
| from zarr.errors import ZarrUserWarning | ||
| from zarr.storage import StorePath, ZipStore | ||
|
|
||
| from ..conftest import ArrayRequest | ||
|
|
@@ -239,12 +238,14 @@ def test_sharding_partial_overwrite( | |
| assert np.array_equal(data, read_data) | ||
|
|
||
|
|
||
| # Zip storage raises a warning about a duplicate name, which we ignore. | ||
| @pytest.mark.filterwarnings("ignore:Duplicate name.*:UserWarning") | ||
| @pytest.mark.parametrize( | ||
| "array_fixture", | ||
| [ | ||
| ArrayRequest(shape=(128,) * 3, dtype="uint16", order="F"), | ||
| ArrayRequest(shape=(127, 128, 129), dtype="uint16", order="F"), | ||
| ], | ||
| indirect=["array_fixture"], | ||
| indirect=True, | ||
| ) | ||
| @pytest.mark.parametrize( | ||
| "outer_index_location", | ||
|
|
@@ -263,24 +264,23 @@ def test_nested_sharding( | |
| ) -> None: | ||
| data = array_fixture | ||
| spath = StorePath(store) | ||
| msg = "Combining a `sharding_indexed` codec disables partial reads and writes, which may lead to inefficient performance." | ||
| with pytest.warns(ZarrUserWarning, match=msg): | ||
| a = zarr.create_array( | ||
| spath, | ||
| shape=data.shape, | ||
| chunks=(64, 64, 64), | ||
| dtype=data.dtype, | ||
| fill_value=0, | ||
| serializer=ShardingCodec( | ||
| chunk_shape=(32, 32, 32), | ||
| codecs=[ | ||
| ShardingCodec(chunk_shape=(16, 16, 16), index_location=inner_index_location) | ||
| ], | ||
| index_location=outer_index_location, | ||
| ), | ||
| ) | ||
| # compressors=None ensures no BytesBytesCodec is added, which keeps | ||
| # supports_partial_decode=True and exercises the partial decode path | ||
| a = zarr.create_array( | ||
| spath, | ||
| data=data, | ||
| chunks=(64,) * data.ndim, | ||
| compressors=None, | ||
|
Contributor
Author
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. setting |
||
| serializer=ShardingCodec( | ||
| chunk_shape=(32,) * data.ndim, | ||
| codecs=[ | ||
| ShardingCodec(chunk_shape=(16,) * data.ndim, index_location=inner_index_location) | ||
| ], | ||
| index_location=outer_index_location, | ||
| ), | ||
| ) | ||
|
|
||
| a[:, :, :] = data | ||
| a[:] = data | ||
|
|
||
| read_data = a[0 : data.shape[0], 0 : data.shape[1], 0 : data.shape[2]] | ||
| assert isinstance(read_data, NDArrayLike) | ||
|
|
@@ -326,13 +326,10 @@ def test_nested_sharding_create_array( | |
| filters=None, | ||
| compressors=None, | ||
| ) | ||
| print(a.metadata.to_dict()) | ||
|
|
||
| a[:, :, :] = data | ||
| a[:] = data | ||
|
|
||
| read_data = a[0 : data.shape[0], 0 : data.shape[1], 0 : data.shape[2]] | ||
| assert isinstance(read_data, NDArrayLike) | ||
| assert data.shape == read_data.shape | ||
| read_data = a[:] | ||
| assert np.array_equal(data, read_data) | ||
|
|
||
|
|
||
|
|
||
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.
by making the shape of the array irregular w.r.t to the chunk shape, we hit the partial decode path, which required for evoking the bug reported in #3652