-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
more extensive api
x store
testing
#2447
base: main
Are you sure you want to change the base?
Conversation
this became a bit of a saga. S3 test fixturesI moved the s3 test fixture to the main
|
The remaining test falures are in the python 3.13 tests where |
…x/open-v2-array-remotestore
…x/open-v2-array-remotestore
…-python into fix/open-v2-array-remotestore
…ix/open-v2-array-remotestore
def test_open_store_with_mode_r(store: Store) -> None: | ||
# 'r' means read only (must exist) | ||
with pytest.raises(FileNotFoundError): | ||
zarr.open(store=store, mode="r") | ||
|
||
z1 = zarr.ones(store=store, shape=(3, 3)) | ||
assert z1.fill_value == 1 | ||
|
||
z2 = zarr.open(store=store, mode="r") | ||
assert isinstance(z2, Array) | ||
assert z2.fill_value == 1 | ||
assert (z2[:] == 1).all() | ||
with pytest.raises(ValueError): | ||
z2[:] = 3 |
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.
@jhamman this test is failing in this PR. What's the expected behavior here, given the new semantics of read_only
for stores? Should we raise an error in zarr.open
if the mode is r
but the store is not read only?
Note the test below, which is copied from main
, passes, but in that case zarr.open
takes a path / string and thus has the opportunity to create the store in read only mode.
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.
see #2447 (comment)
…x/open-v2-array-remotestore
…x/open-v2-array-remotestore
…s in storepath creation; get tests to pass
getting the lasts tests to pass required adding two new methods to the stores: I think this PR is pretty important insofar as it opens up the possibility of testing the store classes much more uniformly, it would be great to get this looked at soon! |
A major downside to this PR is the additional time required for tests -- with these changes, tests in CI take nearly 20m to complete! On the other hand, I have found many bugs by testing extensively. Not sure how to find balance here. |
Hypothesis property tests! You can even configure it to run for longer on CI and shorter locally. You can also ensure specific cases always run |
@@ -412,6 +412,18 @@ async def getsize_prefix(self, prefix: str) -> int: | |||
sizes = await concurrent_map(keys, self.getsize, limit=limit) | |||
return sum(sizes) | |||
|
|||
def _as_immutable(self: Self) -> Self: |
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.
in icechunk we have these as set_read_only
and set_writeable
which I mildly prefer. Simple words are nice.
@pytest.mark.parametrize("store", ["local", "memory", "remote"], indirect=True) | ||
def test_create_array(store: Store) -> None: |
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.
@pytest.mark.parametrize("store", ["local", "memory", "remote"], indirect=True) | |
def test_create_array(store: Store) -> None: | |
from hypothesis import given | |
import hypothesis.strategies as st | |
stores = st.sampled_from(["local", "memory", "remote"]) | |
@given(store=stores()) | |
def test_create_array(store: Store) -> None: |
@@ -412,6 +412,18 @@ async def getsize_prefix(self, prefix: str) -> int: | |||
sizes = await concurrent_map(keys, self.getsize, limit=limit) | |||
return sum(sizes) | |||
|
|||
def _as_immutable(self: Self) -> Self: | |||
""" | |||
Return a mutable copy of the store. |
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.
It looks like perhaps the words "mutable" and "immutable" should be swapped between this method and the _as_mutable
method, no?
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.
oops, good catch!
The
api
module contains a lot of our user-facing code, but we are essentially only testing it againstLocalStore
andMemoryStore
. A better situation would be to test the functions inapi
against all the stores. That's what this PR adds. Note that there are many test failures. I will try to get them all fixed.This PR also contains a fix for #2444, but the central addition is the (currently failing) test for that scenario.
TODO: