-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
zarr.open should fall back to opening a group #2310
zarr.open should fall back to opening a group #2310
Conversation
src/zarr/api/asynchronous.py
Outdated
except KeyError: | ||
except (KeyError, ValueError): | ||
# KeyError for a missing key | ||
# ValueError for failing to parse node metadata as an array when it's |
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.
maybe we should create a specific exception for this case, since "valid document but the wrong node type" is different from "invalid document"
https://github.com/TomAugspurger/zarr-python/blob/tom/fix/batched-io/src/zarr/core/metadata/_io.py has the start of that. I like the idea of using |
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.
One test suggestion but otherwise this looks good to me.
Closes #2309
I'm not happy with this implementation. I broke / fixed this in my consolidated metadata PR as well.
Relying on the exception type from
open_array
to decide whether to fall back to opening a group seems pretty fragile. I might spend a few minutes trying out an alternative way of doing things that'll be a bit more robust (potentially at the cost of some unnecessary I/O; but I think that's OK foropen
sinceopen_group
andopen_array
offer more direct ways of doing things).TODO: