Skip to content

Able to delete group even when opened as readonly #3147

Closed
@TomNicholas

Description

@TomNicholas

Zarr version

v3.0.8

Numcodecs version

0.16.1

Python Version

3.12.4

Operating System

linux

Installation

pip

Description

I was not expecting to be able to delete a group when opening from the store using mode='r'.

Steps to reproduce

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
# ]
# ///

import zarr

store = zarr.storage.MemoryStore()
root = zarr.create_group(store=store)
foo = root.create_group('foo')
bar = root.create_group('bar')
root.members()
# (('foo', <Group memory://139839476802624/foo>),
# ('bar', <Group memory://139839476802624/bar>))

# re-open root group in a supposedly readonly state
root_readonly = zarr.open_group(store, path='/', mode='r')

# delete a child group
del root_readonly['foo']

root_readonly.members()
# (('bar', <Group memory://139839476802624/bar>),)

zarr.print_debug_info()
platform: Linux-5.10.220-209.869.amzn2.x86_64-x86_64-with-glibc2.35
python: 3.12.4
zarr: 3.0.8

**Required dependencies:**
packaging: 24.1
numpy: 1.26.4
numcodecs: 0.16.1
typing_extensions: 4.12.2
donfig: 0.8.1.post1

**Optional dependencies:**
botocore: 1.34.106
fsspec: 2024.6.0
numcodecs: 0.16.1
s3fs: 2024.6.0
gcsfs: 2024.6.0
rich: 13.7.1

**Not Installed:**
cupy-cuda12x
universal-pathlib
obstore

Additional output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions