Skip to content

Commit 9a27cdf

Browse files
authored
Merge pull request #7 from weigertlab/fix-ilp-err-msg
Add gentle error for missing ILP install
2 parents 3b2cf5e + f2147fe commit 9a27cdf

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ testing = [
3939
"napari",
4040
"pyqt5",
4141
]
42+
dev = [
43+
"napari-trackastra[testing]",
44+
"pre-commit",
45+
"ruff",
46+
"twine",
47+
"build",
48+
]
4249

4350
[project.entry-points."napari.manifest"]
4451
napari-trackastra = "napari_trackastra:napari.yaml"

src/napari_trackastra/_widget.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def __init__(
130130
self._model_type.changed.connect(self._model_type_changed)
131131
self._model_pretrained.changed.connect(self._update_model)
132132
self._model_path.changed.connect(self._update_model)
133+
self._linking_mode.changed.connect(self._update_linking_mode)
133134
self._run_button.changed.connect(self._run)
134135

135136
# self._save_path.changed.connect(self._save)
@@ -171,6 +172,20 @@ def _update_model(self, event=None):
171172
self._model_path.value, device=self._device
172173
)
173174

175+
def _update_linking_mode(self, event=None):
176+
if self._linking_mode.value == "ilp":
177+
try:
178+
import motile # noqa F401
179+
180+
return True
181+
except ModuleNotFoundError:
182+
napari.utils.notifications.show_warning(
183+
"For tracking with an ILP, please conda install the optional `motile`"
184+
" dependency following https://funkelab.github.io/motile/install.html."
185+
)
186+
return False
187+
return True
188+
174189
def _show_activity_dock(self, state=True):
175190
# show/hide activity dock if there is actual progress to see
176191
self._viewer.window._status_bar._toggle_activity_dock(state)
@@ -181,6 +196,9 @@ def _run(self, event=None):
181196
if self.model is None:
182197
raise ValueError("Model not loaded")
183198

199+
if not self._update_linking_mode():
200+
return
201+
184202
imgs = np.asarray(self._image_layer.value.data)
185203
masks = np.asarray(self._mask_layer.value.data)
186204

0 commit comments

Comments
 (0)