Skip to content

Commit

Permalink
Add tensorstore missing warning when making zarr array
Browse files Browse the repository at this point in the history
  • Loading branch information
jni committed Nov 4, 2023
1 parent 7ecd6f9 commit a8cd6e5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/zarpaint/_zarpaint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ast
import os
import warnings
import yaml

from magicgui import magic_factory
Expand All @@ -11,6 +12,7 @@
tensorstore_available = True
except ModuleNotFoundError:
tensorstore_available = False
have_warned = False
import zarr
import toolz as tz

Expand Down Expand Up @@ -102,6 +104,15 @@ def open_zarr(labels_file: pathlib.Path, *, shape=None, chunks=None):
if tensorstore_available:
data = ts.open(labels_ts_spec, create=False, open=True).result()
else:
global have_warned
if not have_warned:
warnings.warn(
'tensorstore not available, falling back to zarr.\n'
'Drawing with tensorstore is *much faster*. We recommend '
'you install tensorstore with '
'`python -m pip install tensorstore`.'
)
have_warned = True
data = labels_temp
return data

Expand Down

0 comments on commit a8cd6e5

Please sign in to comment.