-
-
Notifications
You must be signed in to change notification settings - Fork 358
fix/group no error #3426
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
fix/group no error #3426
Conversation
I can take a quick look now - will post back in an hour or so either way if I find any fixes or not 😄 |
As a starter for 10, de-duplicating diff --git a/src/zarr/api/asynchronous.py b/src/zarr/api/asynchronous.py
index 7ff73cc0..0cde9103 100644
--- a/src/zarr/api/asynchronous.py
+++ b/src/zarr/api/asynchronous.py
@@ -673,13 +673,6 @@ async def group(
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
- mode: AccessModeLiteral
- if overwrite:
- mode = "w"
- else:
- mode = "w-"
- store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
-
if chunk_store is not None:
warnings.warn("chunk_store is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
if cache_attrs is not None:
@@ -689,20 +682,7 @@ async def group(
if meta_array is not None:
warnings.warn("meta_array is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
- if attributes is None:
- attributes = {}
-
- try:
- return await AsyncGroup.open(store=store_path, zarr_format=zarr_format)
- except (KeyError, FileNotFoundError):
- _zarr_format = zarr_format or _default_zarr_format()
- return await AsyncGroup.from_store(
- store=store_path,
- zarr_format=_zarr_format,
- overwrite=overwrite,
- attributes=attributes,
- )
-
+ return await create_group(store=store, path=path, overwrite=overwrite, zarr_format=zarr_format, attributes=attributes, storage_options=storage_options)
async def create_group(
*,
@@ -742,9 +722,7 @@ async def create_group(
if zarr_format is None:
zarr_format = _default_zarr_format()
- mode: Literal["a"] = "a"
-
- store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
+ store_path = await make_store_path(store, path=path, mode="a", storage_options=storage_options)
return await AsyncGroup.from_store(
store=store_path, (I will PR my findings to your branch when I'm done, but thought I'd post along the way) |
It looks like d-v-b#147 does the trick. I'm not entirely sure why, but it works and deduplicates some code so 🤷 |
i'd like to take this opportunity to flag the fact that, collectively, permissions for stores have consumed a lot of developer energy. I would LOVE to find something more literate than arcane string codes like |
@@ -2159,7 +2159,7 @@ def test_group_members_performance(store: Store) -> None: | |||
|
|||
latency_store = LatencyStore(store, get_latency=get_latency) | |||
# create a group with some latency on get operations | |||
group_read = zarr.group(store=latency_store) | |||
group_read = zarr.open_group(store=latency_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.
The change also caught this, which was trying to create a group on top of another group - I changed it to open the existing roup instead.
Related to this PR, it seems like |
i'm glad you suggested this! it should absolutely be deprecated. |
Dammit I missed some failing tests. I think they can be fixed easily enough by replacing some calls to |
attributes=attributes, | ||
) | ||
|
||
return await create_group(store=store, path=path, overwrite=overwrite, zarr_format=zarr_format, attributes=attributes, storage_options=storage_options) |
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.
(sorry I realise my comments are scattergun) If group()
is actually meant to try opening a group first (it's not documented like that, but I guess it's existing behaviour we shouldn't break...?), maybe the try/except statement needs putting back, but the new create_group
call should go in the except
block?
we don't need this any more now that #3431 is in |
This PR adds tests for the error reported in #3406, and makes a change to the mode handling in
zarr.api.asynchronous.group
that resolves the error reported there, but causes tests elsewhere in the test suite to fail.I'm posting this incomplete PR so that anyone who enjoys debugging store permissions problems can pick it up.