@@ -65,20 +65,12 @@ module Make (M : STORE) : S with type t = M.t = struct
6565 Some (ArrayNode. parent node)
6666
6767 let group_metadata node t =
68- if not @@ group_exists t node then
69- Result. error @@
70- `Store_read (GroupNode. show node ^ " is not a member of this store." )
71- else
72- get t @@ GroupNode. to_metakey node >> = fun bytes ->
73- GM. decode bytes
68+ get t @@ GroupNode. to_metakey node >> = fun bytes ->
69+ GM. decode bytes >> ? fun msg -> `Store_read msg
7470
7571 let array_metadata node t =
76- if not @@ array_exists t node then
77- Result. error @@
78- `Store_read (ArrayNode. show node ^ " is not a member of this store." )
79- else
80- get t @@ ArrayNode. to_metakey node >> = fun bytes ->
81- AM. decode bytes
72+ get t @@ ArrayNode. to_metakey node >> = fun bytes ->
73+ AM. decode bytes >> ? fun msg -> `Store_read msg
8274
8375 (* Assumes without checking that [metakey] is a valid node metadata key.*)
8476 let unsafe_node_type t metakey =
@@ -87,22 +79,16 @@ module Make (M : STORE) : S with type t = M.t = struct
8779 |> Util. member " node_type" |> Util. to_string
8880
8981 let find_child_nodes t node =
90- if group_exists t node then
91- Result. ok @@
92- List. fold_left
93- (fun (lacc , racc ) pre ->
94- let p = " /" ^ String. (length pre - 1 |> sub pre 0 ) in
95- if unsafe_node_type t (pre ^ " zarr.json" ) = " array" then
96- let x = Result. get_ok @@ ArrayNode. of_path p in
97- x :: lacc, racc
98- else
99- let x = Result. get_ok @@ GroupNode. of_path p in
100- lacc, x :: racc)
101- ([] , [] ) (snd @@ list_dir t @@ GroupNode. to_prefix node)
102- else
103- let msg =
104- GroupNode. show node ^ " is not a node in this heirarchy." in
105- Result. error @@ `Store_read msg
82+ List. fold_left
83+ (fun (lacc , racc ) pre ->
84+ let p = " /" ^ String. (length pre - 1 |> sub pre 0 ) in
85+ if unsafe_node_type t (pre ^ " zarr.json" ) = " array" then
86+ let x = Result. get_ok @@ ArrayNode. of_path p in
87+ x :: lacc, racc
88+ else
89+ let x = Result. get_ok @@ GroupNode. of_path p in
90+ lacc, x :: racc)
91+ ([] , [] ) (snd @@ list_dir t @@ GroupNode. to_prefix node)
10692
10793 let find_all_nodes t =
10894 let keys =
@@ -138,11 +124,11 @@ module Make (M : STORE) : S with type t = M.t = struct
138124 Owl_types. index array ->
139125 (a , b ) Ndarray. t ->
140126 t ->
141- (unit , [> error ]) result
127+ (unit , [> error ]) result
142128 = fun node slice x t ->
143129 let open Util in
144130 get t @@ ArrayNode. to_metakey node >> = fun bytes ->
145- AM. decode bytes >> = fun meta ->
131+ AM. decode bytes >> ? ( fun msg -> `Store_write msg) >> = fun meta ->
146132 (if Ndarray. shape x = Indexing. slice_shape slice @@ AM. shape meta then
147133 Ok ()
148134 else
@@ -199,7 +185,7 @@ module Make (M : STORE) : S with type t = M.t = struct
199185 = fun node slice kind t ->
200186 let open Util in
201187 get t @@ ArrayNode. to_metakey node >> = fun bytes ->
202- AM. decode bytes >> = fun meta ->
188+ AM. decode bytes >> ? ( fun msg -> `Store_read msg) >> = fun meta ->
203189 (if AM. is_valid_kind meta kind then
204190 Ok ()
205191 else
@@ -245,7 +231,8 @@ module Make (M : STORE) : S with type t = M.t = struct
245231 let reshape t node shape =
246232 let mkey = ArrayNode. to_metakey node in
247233 get t mkey >> = fun bytes ->
248- AM. decode bytes >> = fun meta ->
234+ AM. decode bytes >> ? (fun msg -> `Store_write msg)
235+ >> = fun meta ->
249236 (if Array. length shape = Array. length @@ AM. shape meta then
250237 Ok ()
251238 else
0 commit comments