From 40c0381b0fd2ff4646fddf0c23cb1defb4564ba3 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 17:57:49 -0400 Subject: [PATCH 01/20] ci: test windows --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f28129..d5d0620 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.10", "3.11"] test-array-libs: From 645f2d5a4649da5ad2184b21e02f180d83aafb7b Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 19:33:02 -0400 Subject: [PATCH 02/20] try pyvista --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5d0620..6b11cc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,17 +23,33 @@ jobs: - run: pipx run check-manifest test: - uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2 - with: - os: ${{ matrix.os }} - python-version: ${{ matrix.python-version }} - coverage-upload: artifact - qt: pyqt6 + name: ${{ matrix.platform }} (${{ matrix.python-version }}) + runs-on: ${{ matrix.platform }} strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.8", "3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12"] + platform: [ubuntu-latest, macos-latest, windows-latest] + + steps: + - uses: actions/checkout@v4 + - uses: pyvista/setup-headless-display-action@v2 + with: + qt: true + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache-dependency-path: "pyproject.toml" + cache: "pip" + + - name: Install Dependencies + run: | + python -m pip install -U pip + python -m pip install .[test,pyqt] + + - name: 🧪 Run Tests + run: pytest --color=yes --cov --cov-report=xml --cov-report=term-missing test-array-libs: uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2 From d23706217d58c32557f0b6be4793912d43d841d7 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 19:36:33 -0400 Subject: [PATCH 03/20] also add qtlibs --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b11cc3..e9bef4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,7 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: tlambert03/setup-qt-libs@v1 - uses: pyvista/setup-headless-display-action@v2 with: qt: true From ef08e19becfcfd125ab9e8d17a5819cd915f3628 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 19:45:21 -0400 Subject: [PATCH 04/20] more stuff --- .github/workflows/ci.yml | 21 +++++++++++++++++++-- pyproject.toml | 1 - src/ndv/viewer/_data_wrapper.py | 6 ++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9bef4b..0f60d84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,10 +33,12 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: tlambert03/setup-qt-libs@v1 - uses: pyvista/setup-headless-display-action@v2 with: qt: true + + - if: runner.os == 'Linux' + run: sudo apt-get install -y libxcb-xinput0 - uses: actions/setup-python@v4 with: @@ -50,7 +52,22 @@ jobs: python -m pip install .[test,pyqt] - name: 🧪 Run Tests - run: pytest --color=yes --cov --cov-report=xml --cov-report=term-missing + run: coverage run -p -m pytest --color=yes + + - name: Generate UUID + shell: bash + run: | + if [[ "$RUNNER_OS" == "Windows" ]]; then + echo "UUID=$(powershell -Command "[guid]::NewGuid().ToString()")" >> $GITHUB_ENV + else + echo "UUID=$(uuidgen)" >> $GITHUB_ENV + fi + + - name: Upload coverage data + uses: actions/upload-artifact@v4 + with: + name: covreport-${{ matrix.platform }}-py${{ matrix.python-version }}-${{ env.UUID }} + path: ./.coverage* test-array-libs: uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2 diff --git a/pyproject.toml b/pyproject.toml index d575fd4..a60aacf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,6 @@ test = [ "ndv[vispy,pygfx]", "dask[array]", "imageio[tifffile]", - "pytest-cov", "pytest-qt", "pytest", ] diff --git a/src/ndv/viewer/_data_wrapper.py b/src/ndv/viewer/_data_wrapper.py index dd4983e..bc1d0cb 100644 --- a/src/ndv/viewer/_data_wrapper.py +++ b/src/ndv/viewer/_data_wrapper.py @@ -2,6 +2,7 @@ from __future__ import annotations +import atexit import logging import sys from abc import abstractmethod @@ -61,6 +62,11 @@ def __gt__(self, other: _T_contra, /) -> bool: ... _EXECUTOR = ThreadPoolExecutor(max_workers=2) +@atexit.register +def _cleanup_executor() -> None: + _EXECUTOR.shutdown(wait=True, cancel_futures=True) + + def _recurse_subclasses(cls: _T) -> Iterator[_T]: for subclass in cls.__subclasses__(): yield subclass From 8590f715d8654941a8cdf9c05cadd9715ee14e89 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 19:46:36 -0400 Subject: [PATCH 05/20] add back pytest-cov --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a60aacf..d575fd4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,7 @@ test = [ "ndv[vispy,pygfx]", "dask[array]", "imageio[tifffile]", + "pytest-cov", "pytest-qt", "pytest", ] From 19f05e8f90f6cf8e9cc70b4126ed7fe22c571a88 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 19:48:39 -0400 Subject: [PATCH 06/20] add libdbus --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f60d84..5c95f76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: qt: true - if: runner.os == 'Linux' - run: sudo apt-get install -y libxcb-xinput0 + run: sudo apt-get install -y libxcb-xinput0 libdbus-1-3 - uses: actions/setup-python@v4 with: From f316c2f55d1297c9821b3e5b7016fe9fdfa36fde Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 19:50:53 -0400 Subject: [PATCH 07/20] add x11 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c95f76..eb80c94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: qt: true - if: runner.os == 'Linux' - run: sudo apt-get install -y libxcb-xinput0 libdbus-1-3 + run: sudo apt-get install -y libxcb-xinput0 libdbus-1-3 x11-utils - uses: actions/setup-python@v4 with: From 96c375c58e5a01341cdef4003106fe83fb31e267 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 19:53:00 -0400 Subject: [PATCH 08/20] add libegl1-mesa --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb80c94..bc2e883 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: qt: true - if: runner.os == 'Linux' - run: sudo apt-get install -y libxcb-xinput0 libdbus-1-3 x11-utils + run: sudo apt-get install -y libxcb-xinput0 libdbus-1-3 x11-utils libegl1-mesa - uses: actions/setup-python@v4 with: From d91d148c867d1cac23f54a24ab9a1c0fe21a92b5 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 19:58:12 -0400 Subject: [PATCH 09/20] who knows --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc2e883..889314f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,12 +33,13 @@ jobs: steps: - uses: actions/checkout@v4 + - if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libdbus-1-3 libegl1-mesa libxcb-xinput0 x11-utils - uses: pyvista/setup-headless-display-action@v2 with: qt: true - - - if: runner.os == 'Linux' - run: sudo apt-get install -y libxcb-xinput0 libdbus-1-3 x11-utils libegl1-mesa - uses: actions/setup-python@v4 with: From fb6bed2ad87be52b1c82b7e7bf9845a52ecbef90 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 19:59:41 -0400 Subject: [PATCH 10/20] back to qt-libs --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 889314f..165a199 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,10 +33,11 @@ jobs: steps: - uses: actions/checkout@v4 - - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y libdbus-1-3 libegl1-mesa libxcb-xinput0 x11-utils + # - if: runner.os == 'Linux' + # run: | + # sudo apt-get update + # sudo apt-get install -y libdbus-1-3 libegl1-mesa libxcb-xinput0 x11-utils + - uses: tlambert03/setup-qt-libs@v1 - uses: pyvista/setup-headless-display-action@v2 with: qt: true From 35742139ec8683b3b2337e067b93d3bde9db1da1 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 20:03:36 -0400 Subject: [PATCH 11/20] move line --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 165a199..6dbc133 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,14 +33,14 @@ jobs: steps: - uses: actions/checkout@v4 - # - if: runner.os == 'Linux' - # run: | - # sudo apt-get update - # sudo apt-get install -y libdbus-1-3 libegl1-mesa libxcb-xinput0 x11-utils - - uses: tlambert03/setup-qt-libs@v1 + - uses: pyvista/setup-headless-display-action@v2 with: qt: true + - if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libegl1 libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 x11-utils libxcb-cursor0 libopengl0 libegl1-mesa - uses: actions/setup-python@v4 with: From 793dd506fa2e306a4be3e1a3ed7d30cc027d07ae Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 20:07:44 -0400 Subject: [PATCH 12/20] reduce again --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6dbc133..8ce6ad2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,10 @@ jobs: - if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y libegl1 libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 x11-utils libxcb-cursor0 libopengl0 libegl1-mesa + sudo apt-get install -y libegl1-mesa libdbus-1-3 libxcb-xinput0 x11-utils libxcb-cursor0 + # sudo apt-get install -y libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 \ + # libxcb-xfixes0 libopengl0 libegl1 libosmesa6 mesa-utils libxcb-shape0 + # sudo apt install libgl1-mesa-glx xvfb x11-xserver-utils - uses: actions/setup-python@v4 with: From 13b7cdbb7927895e1ec669c535361416ff44d836 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 20:10:55 -0400 Subject: [PATCH 13/20] remove x11 utils --- .github/workflows/ci.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ce6ad2..70a6c57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,13 +38,8 @@ jobs: with: qt: true - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y libegl1-mesa libdbus-1-3 libxcb-xinput0 x11-utils libxcb-cursor0 - # sudo apt-get install -y libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 \ - # libxcb-xfixes0 libopengl0 libegl1 libosmesa6 mesa-utils libxcb-shape0 - # sudo apt install libgl1-mesa-glx xvfb x11-xserver-utils - + run: sudo apt-get install -y libegl1-mesa libdbus-1-3 libxcb-xinput0 libxcb-cursor0 + # x11-utils - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From f8d67187dbd3ad9170a7d518497e7a7ec86a7249 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 20:14:53 -0400 Subject: [PATCH 14/20] remove mesa --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70a6c57..cea253a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,8 @@ jobs: with: qt: true - if: runner.os == 'Linux' - run: sudo apt-get install -y libegl1-mesa libdbus-1-3 libxcb-xinput0 libxcb-cursor0 - # x11-utils + run: sudo apt-get install -y libdbus-1-3 libxcb-xinput0 libxcb-cursor0 + # x11-utils libegl1-mesa - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From f2ce055610908138241038da37fb7fffdaa7b645 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 20:16:37 -0400 Subject: [PATCH 15/20] remove dbus --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cea253a..bb6e4db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,8 @@ jobs: with: qt: true - if: runner.os == 'Linux' - run: sudo apt-get install -y libdbus-1-3 libxcb-xinput0 libxcb-cursor0 - # x11-utils libegl1-mesa + run: sudo apt-get install -y libxcb-xinput0 libxcb-cursor0 + # x11-utils libegl1-mesa libdbus-1-3 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From ec95e1d2d10f97f279f96a204e645e539c9d48d0 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 20:17:48 -0400 Subject: [PATCH 16/20] remove cursor --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb6e4db..fd20f1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,8 @@ jobs: with: qt: true - if: runner.os == 'Linux' - run: sudo apt-get install -y libxcb-xinput0 libxcb-cursor0 - # x11-utils libegl1-mesa libdbus-1-3 + run: sudo apt-get install -y libxcb-xinput0 + # x11-utils libegl1-mesa libdbus-1-3 libxcb-cursor0 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 9cdda29f4e6a19264ae46a2cffbe2ffa06d061b1 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 20:26:26 -0400 Subject: [PATCH 17/20] just cursor --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd20f1f..6a60b29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,13 +33,14 @@ jobs: steps: - uses: actions/checkout@v4 - + - uses: pyvista/setup-headless-display-action@v2 with: qt: true + # strangely, this lib is in headless-display-action, but doesn't get installed - if: runner.os == 'Linux' - run: sudo apt-get install -y libxcb-xinput0 - # x11-utils libegl1-mesa libdbus-1-3 libxcb-cursor0 + run: sudo apt-get install -y libxcb-cursor0 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 6fb697fc723534f2ebdb40d58ef1e9d258ac1367 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 20:41:32 -0400 Subject: [PATCH 18/20] try lock --- src/ndv/viewer/_data_wrapper.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ndv/viewer/_data_wrapper.py b/src/ndv/viewer/_data_wrapper.py index bc1d0cb..f15bb0b 100644 --- a/src/ndv/viewer/_data_wrapper.py +++ b/src/ndv/viewer/_data_wrapper.py @@ -5,6 +5,7 @@ import atexit import logging import sys +import threading from abc import abstractmethod from concurrent.futures import Future, ThreadPoolExecutor from contextlib import suppress @@ -110,6 +111,7 @@ def create(cls, data: ArrayT) -> DataWrapper[ArrayT]: def __init__(self, data: ArrayT) -> None: self._data = data + self._lock = threading.Lock() @property def data(self) -> ArrayT: @@ -274,8 +276,11 @@ class ArrayLikeWrapper(DataWrapper, Generic[ArrayT]): PRIORITY = 100 def isel(self, indexers: Indices) -> np.ndarray: - idx = tuple(indexers.get(k, slice(None)) for k in range(len(self._data.shape))) - return self._asarray(self._data[idx]) + with self._lock: + idx = tuple( + indexers.get(k, slice(None)) for k in range(len(self._data.shape)) + ) + return self._asarray(self._data[idx]) def _asarray(self, data: npt.ArrayLike) -> np.ndarray: return np.asarray(data) From f0c45b4bbaca65abc831893738edbb72be0b9631 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 20:45:24 -0400 Subject: [PATCH 19/20] more locks --- src/ndv/viewer/_data_wrapper.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/ndv/viewer/_data_wrapper.py b/src/ndv/viewer/_data_wrapper.py index f15bb0b..fbc9a13 100644 --- a/src/ndv/viewer/_data_wrapper.py +++ b/src/ndv/viewer/_data_wrapper.py @@ -205,7 +205,8 @@ class XarrayWrapper(DataWrapper["xr.DataArray"]): """Wrapper for xarray DataArray objects.""" def isel(self, indexers: Indices) -> np.ndarray: - return np.asarray(self._data.isel(indexers)) + with self._lock: + return np.asarray(self._data.isel(indexers)) def sizes(self) -> Mapping[Hashable, int]: return {k: int(v) for k, v in self._data.sizes.items()} @@ -260,8 +261,9 @@ def isel(self, indexers: Indices) -> np.ndarray: labels, values = zip(*indexers.items()) origins = (0,) * len(labels) slc = self._ts.d[labels].translate_to[origins][values] - result = self._data[slc].read().result() - return np.asarray(result) + with self._lock: + result = self._data[slc].read().result() + return np.asarray(result) @classmethod def supports(cls, obj: Any) -> TypeGuard[ts.TensorStore]: @@ -316,8 +318,11 @@ class DaskWrapper(DataWrapper["da.Array"]): """Wrapper for dask array objects.""" def isel(self, indexers: Indices) -> np.ndarray: - idx = tuple(indexers.get(k, slice(None)) for k in range(len(self._data.shape))) - return np.asarray(self._data[idx].compute()) + with self._lock: + idx = tuple( + indexers.get(k, slice(None)) for k in range(len(self._data.shape)) + ) + return np.asarray(self._data[idx].compute()) @classmethod def supports(cls, obj: Any) -> TypeGuard[da.Array]: @@ -385,8 +390,9 @@ def sizes(self) -> Sizes: def isel(self, indexers: Indices) -> np.ndarray: # convert possibly named indices to integer indices - real_indexers = {self._name2index.get(k, k): v for k, v in indexers.items()} - return super().isel(real_indexers) + with self._lock: + real_indexers = {self._name2index.get(k, k): v for k, v in indexers.items()} + return super().isel(real_indexers) class TorchTensorWrapper(DataWrapper["torch.Tensor"]): @@ -408,10 +414,13 @@ def sizes(self) -> Sizes: def isel(self, indexers: Indices) -> np.ndarray: # convert possibly named indices to integer indices - real_indexers = {self._name2index.get(k, k): v for k, v in indexers.items()} - # convert to tuple of slices - idx = tuple(real_indexers.get(i, slice(None)) for i in range(self.data.ndim)) - return self.data[idx].numpy(force=True) # type: ignore [no-any-return] + with self._lock: + real_indexers = {self._name2index.get(k, k): v for k, v in indexers.items()} + # convert to tuple of slices + idx = tuple( + real_indexers.get(i, slice(None)) for i in range(self.data.ndim) + ) + return self.data[idx].numpy(force=True) # type: ignore [no-any-return] @classmethod def supports(cls, obj: Any) -> TypeGuard[torch.Tensor]: From d36de8821c844be991b5639b2a5750310e914022 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 15 Jun 2024 21:09:51 -0400 Subject: [PATCH 20/20] wait false --- src/ndv/viewer/_data_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ndv/viewer/_data_wrapper.py b/src/ndv/viewer/_data_wrapper.py index fbc9a13..0f2a4c5 100644 --- a/src/ndv/viewer/_data_wrapper.py +++ b/src/ndv/viewer/_data_wrapper.py @@ -65,7 +65,7 @@ def __gt__(self, other: _T_contra, /) -> bool: ... @atexit.register def _cleanup_executor() -> None: - _EXECUTOR.shutdown(wait=True, cancel_futures=True) + _EXECUTOR.shutdown(wait=False) def _recurse_subclasses(cls: _T) -> Iterator[_T]: