Skip to content

asyncgroup.delitem silently fails if the key is missing #2967

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

Open
d-v-b opened this issue Apr 7, 2025 · 5 comments
Open

asyncgroup.delitem silently fails if the key is missing #2967

d-v-b opened this issue Apr 7, 2025 · 5 comments
Labels
bug Potential issues with the zarr-python library

Comments

@d-v-b
Copy link
Contributor

d-v-b commented Apr 7, 2025

this should raise a keyerror. instead it silently does nothing.

# /// script
# requires-python = ">=3.11"
# dependencies = ["zarr"]
# ///

import zarr
store = {}
z = zarr.create_group(store)
del z['i do not exist']
@paraseba
Copy link
Contributor

paraseba commented Apr 7, 2025

Sometimes the current behavior is useful. The HTTP protocol, and many others, define deletes as idempotent, so deleting twice, sequentially, an existing key should result in the same response each time. In a sense, when you delete something that is not there, the server is not wrong if it responds with "it was deleted".

This idempotency property is particularly useful in concurrent workflows.

I don't oppose to changing the behavior, but we should make sure it's an improvement.

@d-v-b
Copy link
Contributor Author

d-v-b commented Apr 7, 2025

you raise a good point about the advantages of idempotent deletes. I was expecting that people used to python dict-style semantics would consider it surprising that del would not raise a KeyError here. But if people don't find the current behavior weird, then we can leave this as-is.

@jhamman
Copy link
Member

jhamman commented Apr 8, 2025

Zarr 2 raised a KeyError and I'll argue that we should go back to that behavior. If you want idempotent deletes from the dict-like interface, use Group.pop(key, None).

@jhamman jhamman added the bug Potential issues with the zarr-python library label Apr 8, 2025
@paraseba
Copy link
Contributor

paraseba commented Apr 8, 2025

Are there any Zarr stores that couldn't implement this behavior? For example, because of the property I mentioned above, an HTTP store probably cannot fail on missing key deletes efficiently (or consistently).

@jhamman
Copy link
Member

jhamman commented Apr 10, 2025

Today, Zarr's HTTP stores don't support writes or deletes of any kind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library
Projects
None yet
Development

No branches or pull requests

3 participants