From a8cd6e520a526486d4dea05c1490f63ff8791de1 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Sun, 5 Nov 2023 10:05:56 +1100 Subject: [PATCH] Add tensorstore missing warning when making zarr array --- src/zarpaint/_zarpaint.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/zarpaint/_zarpaint.py b/src/zarpaint/_zarpaint.py index 283b3c1..53660f3 100644 --- a/src/zarpaint/_zarpaint.py +++ b/src/zarpaint/_zarpaint.py @@ -1,5 +1,6 @@ import ast import os +import warnings import yaml from magicgui import magic_factory @@ -11,6 +12,7 @@ tensorstore_available = True except ModuleNotFoundError: tensorstore_available = False + have_warned = False import zarr import toolz as tz @@ -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