Skip to content

Commit 9ef8d80

Browse files
authored
Merge pull request #635 from AllenCell/bugfix/fix_layers_changed_deprecation
Bugfix/fix layers changed deprecation
2 parents c026aff + d66df1b commit 9ef8d80

File tree

8 files changed

+38
-14
lines changed

8 files changed

+38
-14
lines changed

.github/workflows/test_lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: Force opencv-python-headless
4949
run: |
5050
pip uninstall -y opencv-python
51-
pip install opencv-python-headless
51+
pip install "numpy<2.0" opencv-python-headless
5252
- name: Test with pytest
5353
run: |
5454
pytest -v --color=yes --cov=allencell_ml_segmenter --cov-report=xml

.github/workflows/test_lint_pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
strategy:
1717
matrix:
1818
os: [macos-latest, windows-latest]
19-
python-version: ["3.9", "3.10"]
19+
python-version: ["3.10"]

.github/workflows/test_lint_push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest]
17-
python-version: ["3.9", "3.10"]
17+
python-version: ["3.10"]

docs/user_docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
project = "Segmenter ML Plugin for napari"
1111
copyright = "2024, Allen Institute for Cell Science"
1212
author = "Segmenter ML plugin team"
13-
release = "1.0.0"
13+
release = "1.0.1rc1"
1414

1515

1616
# -- General configuration ---------------------------------------------------

pyproject.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ build-backend = "setuptools.build_meta"
88
# https://peps.python.org/pep-0621/
99
[project]
1010
name = "allencell-segmenter-ml"
11-
version = "1.0.0"
11+
version = "1.0.1rc1"
1212
description = "A plugin to leverage ML segmentation in napari"
1313
readme = "README.md"
14-
requires-python = ">=3.9,<3.11"
14+
requires-python = ">=3.10,<3.11"
1515
license = { file = "LICENSE" }
1616

1717
classifiers = [
@@ -24,14 +24,13 @@ classifiers = [
2424
"Programming Language :: Python",
2525
"Programming Language :: Python :: 3",
2626
"Programming Language :: Python :: 3 :: Only",
27-
"Programming Language :: Python :: 3.9",
2827
"Programming Language :: Python :: 3.10",
2928
"Topic :: Scientific/Engineering :: Image Processing",
3029
]
3130

3231
dependencies = [
3332
"npe2>=0.6.2",
34-
"numpy",
33+
"numpy<2.0",
3534
"hydra-core==1.3.2",
3635
"bioio==1.1.0",
3736
"bioio-base==1.0.4",
@@ -51,7 +50,7 @@ Documentation = "https://github.com/AllenCell/allencell-ml-segmenter#README.md"
5150
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
5251
[project.optional-dependencies]
5352
napari = [
54-
"napari>=0.4.18",
53+
"napari>=0.6.2",
5554
"pyqt5",
5655
]
5756

@@ -67,7 +66,7 @@ test_lint = [
6766
"mypy",
6867
"toml",
6968
"bumpver",
70-
"napari>=0.4.18",
69+
"napari>=0.6.2",
7170
"magicgui"
7271
]
7372

@@ -118,7 +117,7 @@ where = ["src"]
118117

119118
# https://pypi.org/project/bumpver
120119
[tool.bumpver]
121-
current_version = "1.0.0"
120+
current_version = "1.0.1rc1"
122121
version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
123122
commit_message = "Bump version {old_version} -> {new_version}"
124123
commit = true

src/allencell_ml_segmenter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.0.0"
1+
__version__ = "1.0.1rc1"
22

33
from allencell_ml_segmenter.napari.napari_reader import napari_get_reader
44
from allencell_ml_segmenter.napari.sample_data import make_sample_data

src/allencell_ml_segmenter/_tests/main/test_main_widget.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from allencell_ml_segmenter.main.main_widget import MainWidget
1414
from unittest.mock import Mock, patch
1515
import napari
16+
from napari.utils.events import EmitterGroup
17+
1618

1719
# IMPORTANT NOTE: MainWidget is different from the other widgets since we do not directly
1820
# instantiate it in our code. So, it will always receive a napari.Viewer object in
@@ -21,6 +23,20 @@
2123
# but for now I'm just mocking it here.
2224

2325

26+
class FakeLayers:
27+
def __init__(self):
28+
self.events = EmitterGroup(
29+
source=self,
30+
inserting=None,
31+
inserted=None,
32+
removing=None,
33+
removed=None,
34+
moving=None,
35+
moved=None,
36+
changed=None,
37+
) # all napari layer events
38+
39+
2440
@pytest.fixture
2541
def main_widget(qtbot: QtBot) -> MainWidget:
2642
"""
@@ -155,10 +171,14 @@ def test_experiments_home_initialized(qtbot: QtBot) -> None:
155171
settings.set_user_experiments_path(
156172
None
157173
) # Simulates state where users has not yet chosen an experiments home.
174+
viewer = Mock(
175+
spec="napari.Viewer"
176+
) # set up fake viewer with layers that can emit events
177+
viewer.layers = FakeLayers()
158178

159179
# ACT
160180
MainWidget(
161-
Mock(spec=napari.Viewer), settings
181+
viewer, settings
162182
) # If the users settings does not find an experiments home path, it will prompt the user for one and persist it.
163183

164184
# ASSERT

src/allencell_ml_segmenter/main/viewer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ def get_layers_nonthreshold(self) -> list[Layer]:
121121
def subscribe_layers_change_event(
122122
self, function: Callable[[NapariEvent], None]
123123
) -> None:
124-
self.viewer.events.layers_change.connect(function)
124+
# keeps layer list synced with the layer checkboxes in our plugin when
125+
# items are added, removed, moved, or changed
126+
self.viewer.layers.events.changed.connect(function)
127+
self.viewer.layers.events.inserted.connect(function)
128+
self.viewer.layers.events.removed.connect(function)
129+
self.viewer.layers.events.moved.connect(function)
125130

126131
def _get_layer_by_name(self, name: str) -> Optional[Layer]:
127132
layers: list[Layer] = self.get_layers()

0 commit comments

Comments
 (0)