This repository was archived by the owner on Jan 10, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change 21
21
22
22
LOG = logging .getLogger (__name__ )
23
23
24
- __all__ = ["open_dataset" , "open_zarr" ]
24
+ __all__ = ["open_dataset" , "open_zarr" , "debug_zarr_loading" ]
25
+
26
+ DEBUG_ZARR_LOADING = False
27
+
28
+
29
+ def debug_zarr_loading (on_off ):
30
+ global DEBUG_ZARR_LOADING
31
+ DEBUG_ZARR_LOADING = on_off
25
32
26
33
27
34
class Dataset :
@@ -258,15 +265,36 @@ def __getitem__(self, key):
258
265
return response ["Body" ].read ()
259
266
260
267
268
+ class DebugStore (ReadOnlyStore ):
269
+ def __init__ (self , store ):
270
+ self .store = store
271
+
272
+ def __getitem__ (self , key ):
273
+ print ("GET" , key )
274
+ return self .store [key ]
275
+
276
+ def __len__ (self ):
277
+ return len (self .store )
278
+
279
+ def __iter__ (self ):
280
+ return iter (self .store )
281
+
282
+
261
283
def open_zarr (path ):
262
284
try :
263
285
store = path
286
+
264
287
if store .startswith ("http://" ) or store .startswith ("https://" ):
265
288
store = HTTPStore (store )
266
289
267
290
elif store .startswith ("s3://" ):
268
291
store = S3Store (store )
269
292
293
+ if DEBUG_ZARR_LOADING :
294
+ if isinstance (store , str ):
295
+ store = zarr .storage .DirectoryStore (store )
296
+ store = DebugStore (store )
297
+
270
298
return zarr .convenience .open (store , "r" )
271
299
except Exception :
272
300
LOG .exception ("Failed to open %r" , path )
You can’t perform that action at this time.
0 commit comments