Skip to content
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

Improve test coverage for storage classes #2693

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

maxrjones
Copy link
Member

@maxrjones maxrjones commented Jan 13, 2025

This PR improves the test coverage for the various storage classes. While testing the storage classes, I fixed a few issues:

  • Implement open() for LoggingStore
  • Add _is_open property and setter for WrapperStore
  • Use stdout rather than stderr as the default stream for LoggingStore
  • Ensure that ZipStore is open before getting or setting any values
  • Update equality for LoggingStore and WrapperStore such that the types much be equal. This is an opinionated change. For example, previously a LocalStore and LoggingStore instance could be evaluated as equal, whereas now they are distinct.

Here's the change in coverage:

src/zarr/abc/store.py                    84% -> 93%
src/zarr/storage/__init__.py             94% -> 94%
src/zarr/storage/_utils.py               94% -> 97%
src/zarr/storage/common.py               80% -> 91%
src/zarr/storage/fsspec.py               25% -> 90%
src/zarr/storage/local.py                86% -> 92%
src/zarr/storage/logging.py              62% -> 96%
src/zarr/storage/memory.py               82% -> 85%
src/zarr/storage/wrapper.py              56% -> 94%
src/zarr/storage/zip.py                  96% -> 97%
src/zarr/testing/store.py                92% -> 99%

src/zarr/storage/memory.py coverage is low because it includes the GPUStore and I don't have a test environment with cuda. I'm opening this PR now even though it's not at 100% coverage because I don't expect to have much time to work on it during the week and would rather the PR not get stale if the team has time for a review.

The set partial values methods are addressed separately because they require discussion (xref #2688).

src/zarr/storage/_fsspec.py Outdated Show resolved Hide resolved
src/zarr/storage/_logging.py Outdated Show resolved Hide resolved
src/zarr/testing/store.py Outdated Show resolved Hide resolved
@d-v-b
Copy link
Contributor

d-v-b commented Jan 13, 2025

this looks great, I had some minor suggestions.

maxrjones and others added 3 commits January 13, 2025 08:57
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
@dstansby dstansby added the needs release notes Automatically applied to PRs which haven't added release notes label Jan 14, 2025
@dstansby
Copy link
Contributor

Thanks for this, and thanks for fixing some issues along the way! For the user-facing issues you fixed, can you add a short entry in docs/release-notes.rst, so users know what's been fixed?

@maxrjones
Copy link
Member Author

Thanks for this, and thanks for fixing some issues along the way! For the user-facing issues you fixed, can you add a short entry in docs/release-notes.rst, so users know what's been fixed?

For sure, I'm hoping to find time to address the remaining comments within the next day or two. I'll add release notes at that time.

maxrjones and others added 4 commits January 14, 2025 15:15
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Jan 14, 2025
@maxrjones
Copy link
Member Author

maxrjones commented Jan 14, 2025

I believe that I've addressed all the suggestions (thank you for the review, Davis!), except that I will need to wait on clarification about the expected behavior for get/set on closed stores before any final changes/changelog additions.

@d-v-b
Copy link
Contributor

d-v-b commented Jan 14, 2025

I don't think my questions about open / closed behavior should block this PR. I can spin that out into a separate issue.

@maxrjones
Copy link
Member Author

I don't think my questions about open / closed behavior should block this PR. I can spin that out into a separate issue.

Sounds good, thanks. There's still a couple new untested lines still in this PR - I should have time to fix that tomorrow morning.

Copy link
Contributor

@dstansby dstansby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, big 👍 for improving our testing.

Two major points:

  • Since StoreTests is public API, we should carefully document everything that's been changed/added in the release notes. I added some comments on this PR inline to changes I spotted that need a release note.
  • Like @d-v-b, I am confused by Improve test coverage for storage classes #2693 (comment) - would be good to discuss/resolve that comment

src/zarr/storage/_logging.py Show resolved Hide resolved
"""Kwargs for instantiating a store"""
...

@abstractmethod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these new abstract methods get a changelog entry? I also presume this is a breaking change, because anyone implementing a child of StoreTests will now be forced to implement these methods?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can mention it in the changelog entry. I do not consider this a breaking change because the previous 'NotImplementedError' caused these tests to fail unless they were implemented in the inheriting class. I think this is just a more Pythonic way to indicate that they need to be implemented.

src/zarr/testing/store.py Show resolved Hide resolved
@@ -135,6 +154,26 @@ async def test_get(self, store: S, key: str, data: bytes, byte_range: ByteReques
expected = data_buf[start:stop]
assert_bytes_equal(observed, expected)

async def test_get_not_open(self, store_not_open: S) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is also surprising to me!

tests/test_store/test_local.py Outdated Show resolved Hide resolved
@maxrjones
Copy link
Member Author

Like @d-v-b, I am confused by #2693 (comment) - would be good to discuss/resolve that comment

@d-v-b @jhamman could I join the developers meeting tomorrow to discuss the Store open and set behavior (xref #2688)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants