From 544b7d271cfd9f04a357ccf240be9653629e8d03 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 19 May 2024 17:23:52 +0100 Subject: [PATCH 1/8] Clean up GitHub actions config --- .github/workflows/test_and_deploy.yml | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 2899c76..669d3d0 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -8,13 +8,11 @@ name: tests on: push: branches: - - master - main tags: - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 pull_request: branches: - - master - main workflow_dispatch: @@ -28,21 +26,15 @@ jobs: python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - # these libraries, along with pytest-xvfb (added in the `deps` in - # tox.ini), enable testing on Qt on linux - - name: Install Linux libraries - if: runner.os == 'Linux' - run: | - sudo apt-get install -y libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 \ - libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \ - libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 + # these libraries enable testing on Qt on linux + - uses: tlambert03/setup-qt-libs@v1 # strategy borrowed from vispy for installing opengl libs on windows - name: Install Windows OpenGL @@ -58,16 +50,18 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools tox tox-gh-actions + python -m pip install tox tox-gh-actions # this runs the platform-specific tests declared in tox.ini - name: Test with tox - run: tox + uses: aganders3/headless-gui@v1 + with: + run: tox env: PLATFORM: ${{ matrix.platform }} - name: Coverage - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 with: fail_ci_if_error: false From 862352294afb7b02a8bbcdbc6c8b741bb080cbac Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 19 May 2024 18:08:37 +0100 Subject: [PATCH 2/8] Use pathlib for testing paths --- napari_ome_zarr/_tests/test_reader.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/napari_ome_zarr/_tests/test_reader.py b/napari_ome_zarr/_tests/test_reader.py index 4c2d957..ca4f209 100644 --- a/napari_ome_zarr/_tests/test_reader.py +++ b/napari_ome_zarr/_tests/test_reader.py @@ -1,4 +1,5 @@ import sys +from pathlib import Path import numpy as np import pytest @@ -9,14 +10,17 @@ class TestNapari: @pytest.fixture(autouse=True) - def initdir(self, tmpdir): - self.path_3d = tmpdir.mkdir("data_3d") - create_zarr(str(self.path_3d), astronaut, "astronaut") - self.path_2d = tmpdir.mkdir("data_2d") - create_zarr(str(self.path_2d)) + def initdir(self, tmp_path: Path): + self.path_3d = tmp_path / "data_3d" + self.path_3d.mkdir() + create_zarr(self.path_3d, astronaut, "astronaut") + + self.path_2d = tmp_path / "data_2d" + self.path_2d.mkdir() + create_zarr(self.path_2d) def test_get_reader_hit(self): - reader = napari_get_reader(str(self.path_3d)) + reader = napari_get_reader(self.path_3d) assert reader is not None assert callable(reader) @@ -81,12 +85,12 @@ def test_image(self, path): self.assert_layers(layers, True, False, path) def test_labels(self): - filename = str(self.path_3d.join("labels")) + filename = self.path_3d / "labels" layers = napari_get_reader(filename)() self.assert_layers(layers, False, True) def test_label(self): - filename = str(self.path_3d.join("labels", "astronaut")) + filename = self.path_3d / "labels" / "astronaut" layers = napari_get_reader(filename)() self.assert_layers(layers, False, True) From 415c5a36b3a80554a453962adf9ac201758dfa4b Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 19 May 2024 18:17:37 +0100 Subject: [PATCH 3/8] Improve readaility of initdir --- napari_ome_zarr/_tests/test_reader.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/napari_ome_zarr/_tests/test_reader.py b/napari_ome_zarr/_tests/test_reader.py index ca4f209..712ca3c 100644 --- a/napari_ome_zarr/_tests/test_reader.py +++ b/napari_ome_zarr/_tests/test_reader.py @@ -11,14 +11,21 @@ class TestNapari: @pytest.fixture(autouse=True) def initdir(self, tmp_path: Path): + """ + Write some temporary test data. + + create_zarr() creates an image pyramid and labels zarr directories. + """ self.path_3d = tmp_path / "data_3d" self.path_3d.mkdir() - create_zarr(self.path_3d, astronaut, "astronaut") + create_zarr(self.path_3d, method=astronaut, label_name="astronaut") self.path_2d = tmp_path / "data_2d" self.path_2d.mkdir() create_zarr(self.path_2d) + self.n_layers = 2 + def test_get_reader_hit(self): reader = napari_get_reader(self.path_3d) assert reader is not None @@ -29,7 +36,7 @@ def test_reader(self, path): path_str = str(getattr(self, path)) reader = napari_get_reader(path_str) results = reader(path_str) - assert len(results) == 2 + assert len(results) == self.n_layers image, label = results assert isinstance(image[0], list) assert isinstance(image[1], dict) @@ -54,7 +61,7 @@ def test_get_reader_pass(self): def assert_layers(self, layers, visible_1, visible_2, path="path_3d"): # TODO: check name - assert len(layers) == 2 + assert len(layers) == self.n_datasets image, label = layers data, metadata, layer_type = self.assert_layer(image) From 4a261bf734efcdce35176198b26035f18711e44e Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 6 Jun 2024 17:25:20 +0100 Subject: [PATCH 4/8] Fix test Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com> --- napari_ome_zarr/_tests/test_reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napari_ome_zarr/_tests/test_reader.py b/napari_ome_zarr/_tests/test_reader.py index 712ca3c..ec15f78 100644 --- a/napari_ome_zarr/_tests/test_reader.py +++ b/napari_ome_zarr/_tests/test_reader.py @@ -61,7 +61,7 @@ def test_get_reader_pass(self): def assert_layers(self, layers, visible_1, visible_2, path="path_3d"): # TODO: check name - assert len(layers) == self.n_datasets + assert len(layers) == self.n_layers image, label = layers data, metadata, layer_type = self.assert_layer(image) From 561cc8febf2e4331a24d87f1ddf34c351116b696 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 6 Jun 2024 17:31:58 +0100 Subject: [PATCH 5/8] Don't fail fast --- .github/workflows/test_and_deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 669d3d0..ae16528 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -21,6 +21,7 @@ jobs: name: ${{ matrix.platform }} py${{ matrix.python-version }} runs-on: ${{ matrix.platform }} strategy: + fail-fast: false matrix: platform: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] From 5aa53045bec9c37abf155f5fb6a451c21027e455 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 6 Jun 2024 17:39:39 +0100 Subject: [PATCH 6/8] Remove n_layers attribute --- napari_ome_zarr/_tests/test_reader.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/napari_ome_zarr/_tests/test_reader.py b/napari_ome_zarr/_tests/test_reader.py index ec15f78..7d19015 100644 --- a/napari_ome_zarr/_tests/test_reader.py +++ b/napari_ome_zarr/_tests/test_reader.py @@ -24,8 +24,6 @@ def initdir(self, tmp_path: Path): self.path_2d.mkdir() create_zarr(self.path_2d) - self.n_layers = 2 - def test_get_reader_hit(self): reader = napari_get_reader(self.path_3d) assert reader is not None @@ -36,7 +34,7 @@ def test_reader(self, path): path_str = str(getattr(self, path)) reader = napari_get_reader(path_str) results = reader(path_str) - assert len(results) == self.n_layers + assert len(results) == 2 image, label = results assert isinstance(image[0], list) assert isinstance(image[1], dict) @@ -61,7 +59,7 @@ def test_get_reader_pass(self): def assert_layers(self, layers, visible_1, visible_2, path="path_3d"): # TODO: check name - assert len(layers) == self.n_layers + assert len(layers) == 2 image, label = layers data, metadata, layer_type = self.assert_layer(image) From b63a80a98bfc59f9f7554889aab437e61fb8317a Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 6 Jun 2024 17:46:00 +0100 Subject: [PATCH 7/8] Use string filenames in tests --- napari_ome_zarr/_tests/test_reader.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/napari_ome_zarr/_tests/test_reader.py b/napari_ome_zarr/_tests/test_reader.py index 7d19015..ebff828 100644 --- a/napari_ome_zarr/_tests/test_reader.py +++ b/napari_ome_zarr/_tests/test_reader.py @@ -18,14 +18,14 @@ def initdir(self, tmp_path: Path): """ self.path_3d = tmp_path / "data_3d" self.path_3d.mkdir() - create_zarr(self.path_3d, method=astronaut, label_name="astronaut") + create_zarr(str(self.path_3d), method=astronaut, label_name="astronaut") self.path_2d = tmp_path / "data_2d" self.path_2d.mkdir() - create_zarr(self.path_2d) + create_zarr(str(self.path_2d)) def test_get_reader_hit(self): - reader = napari_get_reader(self.path_3d) + reader = napari_get_reader(str(self.path_3d)) assert reader is not None assert callable(reader) @@ -90,12 +90,12 @@ def test_image(self, path): self.assert_layers(layers, True, False, path) def test_labels(self): - filename = self.path_3d / "labels" + filename = str(self.path_3d / "labels") layers = napari_get_reader(filename)() self.assert_layers(layers, False, True) def test_label(self): - filename = self.path_3d / "labels" / "astronaut" + filename = str(self.path_3d / "labels" / "astronaut") layers = napari_get_reader(filename)() self.assert_layers(layers, False, True) From 6b790ed25b6288e0c18d2b764a03bfc036b91dae Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Thu, 21 Nov 2024 11:31:43 +0100 Subject: [PATCH 8/8] Bump other block --- .github/workflows/test_and_deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index ae16528..2f0e079 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -74,9 +74,9 @@ jobs: runs-on: ubuntu-latest if: contains(github.ref, 'tags') steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.x" - name: Install dependencies