You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developers/store_permissions.md
+25-4Lines changed: 25 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,28 @@ Zarr Python has two data models (`Array` and `Group`) and one storage model (`St
10
10
11
11
## Store properties related to permissions
12
12
13
-
### `supports_writes`
13
+
### Instance properties
14
+
15
+
#### `read_only`
16
+
17
+
The `read_only` property indicates whether store *instances* should allow `set`, `delete` operations and their permutations. If `read_only` is `True`, then the store should reject any write or delete operations. If `read_only` is `False`, then the store should allow write and delete operations. The property is tested by `Store` methods by calling `self._check_writable()`, which raises a `ValueError` if the store's `read_only` property is true.
18
+
19
+
The `read_only` property is one of the most likely places to encounter a bug for a few reasons:
20
+
21
+
-`Store` implementations must remember to call `super.__init__(read_only=read_only)` in their `__init__` method to set the `read_only` property correctly.
22
+
-`Store` implementations must remember to call `self._check_writable()` in their `set` and `delete` methods to enforce the `read_only` property.
23
+
-`Array` and `Group` classes must remember to check alignment with the `read_only` property of the store with any `overwrite` arguments.
24
+
- Top level API functions must remember to check the `read_only` property of the store when creating new arrays or groups. This is complicated by the API functions using "mode" semantics like "w", "r", "a", etc., which are not directly related to the `read_only` property. Each function typically has its own logic for matching mode semntics to the `read_only` property of the store.
25
+
26
+
This is one of the most likely place to encounter a bug where a `read_only` property is not respected because implementations must remember to call `self._check_writable()` when implementing `store.set()`, which is not implemented in the `Store` abstract base class.
27
+
28
+
The Zarr spec does not seem to define how APIs should constrain write/delete permissions at the instance level.
29
+
30
+
### Class properties
31
+
32
+
The Zarr spec provides distinctions between readable, writeable, and listable stores, but does not define how to distinguish between these groups of store operations. The Zarr Python library has adopted the following properties to distinguish between these groups of operations at the *class* level, which are used by the `Store` abstract base class and the testing framework.
33
+
34
+
#### `supports_writes`
14
35
15
36
This is a property of the *class* that should indicate whether the store implements the following methods:
16
37
@@ -19,7 +40,7 @@ This is a property of the *class* that should indicate whether the store impleme
19
40
20
41
`supports_writes` is primarily used by tests to determine the expected result of write operations. It is not used by the library to enforce permissions.
21
42
22
-
### `supports_partial_writes`
43
+
####`supports_partial_writes`
23
44
24
45
The purpose of this property of the *class* is currently ambiguous.
25
46
@@ -31,7 +52,7 @@ But the `FsspecStore` class does not implement this method, but it does have `su
31
52
32
53
Another interpretation is that it indicates whether the store supports a `byte_range` argument in the `set` method.
33
54
34
-
### `supports_deletes`
55
+
####`supports_deletes`
35
56
36
57
This is a property of the *class* that should indicate whether the store implements the following methods:
37
58
@@ -46,7 +67,7 @@ The `supports_deletes` property is also used by the testing framework to determi
46
67
!!! note
47
68
Store implementations are agnostic to the Zarr data model. They will delete everything under the given prefix, regardless of whether it is an array, group, or unrelated to the Zarr store.
48
69
49
-
### `supports_listing`
70
+
####`supports_listing`
50
71
51
72
This is a property of the *class* that should indicate whether the store implements the following method:
0 commit comments