25
25
)
26
26
from rich .spinner import Spinner
27
27
from rich_argparse import RichHelpFormatter
28
- from zarr .storage import DirectoryStore
28
+ import zarr .storage
29
+
30
+ if hasattr (zarr .storage , "DirectoryStore" ):
31
+ LocalStore = zarr .storage .DirectoryStore
32
+ else :
33
+ LocalStore = zarr .storage .LocalStore
29
34
30
35
from .cli_input_to_ngff_image import cli_input_to_ngff_image
31
36
from .config import config
@@ -61,7 +66,18 @@ def _multiscales_to_ngff_zarr(
61
66
)
62
67
)
63
68
return
64
- to_ngff_zarr (output_store , multiscales , progress = rich_dask_progress )
69
+ if args .use_tensorstore :
70
+ if hasattr (output_store , "root" ):
71
+ output_store = output_store .root
72
+ else :
73
+ output_store = output_store .path
74
+ to_ngff_zarr (
75
+ output_store ,
76
+ multiscales ,
77
+ progress = rich_dask_progress ,
78
+ use_tensorstore = args .use_tensorstore ,
79
+ version = args .ome_zarr_version ,
80
+ )
65
81
66
82
67
83
def _ngff_image_to_multiscales (
@@ -191,6 +207,12 @@ def main():
191
207
type = int ,
192
208
default = 0 ,
193
209
)
210
+ metadata_group .add_argument (
211
+ "--ome-zarr-version" ,
212
+ help = "OME-Zarr version" ,
213
+ default = "0.4" ,
214
+ choices = ["0.4" , "0.5" ],
215
+ )
194
216
195
217
processing_group = parser .add_argument_group ("processing" , "Processing options" )
196
218
processing_group .add_argument (
@@ -226,6 +248,11 @@ def main():
226
248
processing_group .add_argument (
227
249
"--cache-dir" , help = "Directory to use for caching with large datasets"
228
250
)
251
+ processing_group .add_argument (
252
+ "--use-tensorstore" ,
253
+ action = "store_true" ,
254
+ help = "Use the TensorStore library for I/O" ,
255
+ )
229
256
230
257
args = parser .parse_args ()
231
258
@@ -236,7 +263,7 @@ def main():
236
263
cache_dir = Path (args .cache_dir ).resolve ()
237
264
if not cache_dir .exists ():
238
265
Path .makedirs (cache_dir , parents = True )
239
- config .cache_store = zarr . storage . DirectoryStore (cache_dir , ** zarr_kwargs )
266
+ config .cache_store = LocalStore (cache_dir , ** zarr_kwargs )
240
267
241
268
console = Console ()
242
269
progress = RichProgress (
@@ -303,7 +330,7 @@ def shutdown_client(sig_id, frame): # noqa: ARG001
303
330
)
304
331
output_store = None
305
332
if args .output and output_backend is ConversionBackend .NGFF_ZARR :
306
- output_store = DirectoryStore (args .output , ** zarr_kwargs )
333
+ output_store = LocalStore (args .output , ** zarr_kwargs )
307
334
308
335
subtitle = "[red]generation"
309
336
if not args .output :
@@ -332,7 +359,7 @@ def shutdown_client(sig_id, frame): # noqa: ARG001
332
359
return
333
360
334
361
if input_backend is ConversionBackend .NGFF_ZARR :
335
- store = zarr . storage . DirectoryStore (args .input [0 ])
362
+ store = LocalStore (args .input [0 ])
336
363
multiscales = from_ngff_zarr (store )
337
364
_multiscales_to_ngff_zarr (
338
365
live , args , output_store , rich_dask_progress , multiscales
0 commit comments