-
-
Notifications
You must be signed in to change notification settings - Fork 356
Added ArrayNotFoundError #3367
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
base: main
Are you sure you want to change the base?
Added ArrayNotFoundError #3367
Conversation
thank you, this looks good. we should make sure we cover all the places in the codebase where we try to read an array. maybe it's just the 1 place you found, but we should double-check. |
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.
Two inline comments. In addition, did you thoroughly check that there's only a single place where an ArrayNotFoundError
should be raised?
tests/test_api.py
Outdated
@@ -161,7 +166,7 @@ async def test_open_array(memory_store: MemoryStore, zarr_format: ZarrFormat) -> | |||
assert z.read_only | |||
|
|||
# path not found | |||
with pytest.raises(FileNotFoundError): | |||
with pytest.raises(ArrayNotFoundError): |
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.
This is currently failing the tests, because it actually raises a GroupNotFoundError
now. I think the sensible thing to do here would be to create another new error, NodeNotFoundError
, that is raised when a non-specific function is used (e.g., just open
) to try and open either an array or a group.
it might be helpful to check out #3012, which unfortunately was too bloated to merge |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3367 +/- ##
==========================================
- Coverage 94.55% 94.51% -0.05%
==========================================
Files 79 79
Lines 9447 9466 +19
==========================================
+ Hits 8933 8947 +14
- Misses 514 519 +5
🚀 New features to boost your workflow:
|
tests/test_api.py
Outdated
@@ -185,10 +192,27 @@ async def test_open_array(memory_store: MemoryStore, zarr_format: ZarrFormat) -> | |||
assert z.read_only | |||
|
|||
# path not found | |||
with pytest.raises(FileNotFoundError): | |||
with pytest.raises((NodeNotFoundError, GroupNotFoundError)): |
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.
how is this raising two errors?
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.
Yeah fair point, I was getting errors in my tests with only 1 error raised but now I've changed it so GroupNotFoundError
and ArrayNotFoundError
inherit from NodeNotFoundError
def __init__(self, *args: Any) -> None: | ||
if len(args) == 1: | ||
# Pre-formatted message | ||
super(BaseZarrError, self).__init__(args[0]) | ||
else: | ||
# Store and path arguments - format them | ||
_msg = "No group found in store {!r} at path {!r}" | ||
super(BaseZarrError, self).__init__(_msg.format(*args)) |
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 a separate PR we should remove the pre-formatting of exception messages, and make every exception just take a single string
@@ -0,0 +1 @@ | |||
Added `~zarr.errors.ArrayNotFoundError`, which is raised when attempting to open a zarr array that does not exist. |
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.
Added `~zarr.errors.ArrayNotFoundError`, which is raised when attempting to open a zarr array that does not exist. | |
Added `zarr.errors.ArrayNotFoundError`, which is raised when attempting to open a zarr array that does not exist, and `zarr.errors.NodeNotFoundError`, which is raised when failing to open an array or a group in a context where either an array or a group was expected. |
Fixes #2961
TODO:
docs/user-guide/*.rst
changes/