From b5fd5b8933b9ad46a8ca10a086e36742e84d0f68 Mon Sep 17 00:00:00 2001 From: pattonw Date: Fri, 9 Sep 2022 14:37:53 -0700 Subject: [PATCH] Remove affogato as a dependency. also update README with updated installation instructions. affogato was removed as a python dependency because there is a different package on pypi also called affogato that we do not want. This is also breaking the conda recipe tests since pip check does not recognize the conda version of affogato as satisfying the dependency --- README.md | 15 ++++++++++++--- setup.cfg | 1 - src/napari_affinities/widgets/mutex_watershed.py | 13 ++++++++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7702426..ce6a197 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ https://napari.org/plugins/stable/index.html ## Installation -Pre-requisites: - - 1) Install lsds with: `pip install git+https://github.com/pattonw/lsd.git@no-convenience-imports` (This is necessary since we need lsds but the package name `lsd` is already taken on pypi. While we resolve this the specific lsd version needs to be specified) +You will need a conda environment for everything to run +smoothly. Supported python versions are 3.7, 3.8, 3.9. +### pip You can install `napari-affinities` via [pip]: `pip install napari-affinities` @@ -43,6 +43,15 @@ Install conda requirements: conda install -c conda-forge affogato +### conda + +If you install via conda, there are fewer steps since +affogato and pytorch will be installed for you. + +You can install `napari-affinities` via [conda]: + + `conda install -c conda-forge napari-affinities` + ### Download example model: #### 2D: diff --git a/setup.cfg b/setup.cfg index 19e89a7..5c11f65 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,7 +39,6 @@ install_requires = magicgui bioimageio.core gunpowder - affogato matplotlib diff --git a/src/napari_affinities/widgets/mutex_watershed.py b/src/napari_affinities/widgets/mutex_watershed.py index c6124cf..c84c0a7 100644 --- a/src/napari_affinities/widgets/mutex_watershed.py +++ b/src/napari_affinities/widgets/mutex_watershed.py @@ -3,7 +3,13 @@ from napari.types import LabelsData, LayerDataTuple from napari.layers import Labels, Image -from affogato.segmentation import MWSGridGraph, compute_mws_clustering +try: + from affogato.segmentation import MWSGridGraph, compute_mws_clustering +except ImportError as e: + raise ImportError( + "To use mutex watershed please install affogato via: " + "conda install -c conda-forge affogato" + ) from e import numpy as np from typing import Optional @@ -13,6 +19,7 @@ import napari from napari.qt.threading import FunctionWorker, thread_worker + def toggle_interactivity_callback(widget, interactive_callbacks): def callback(live): # remove old callbacks @@ -23,14 +30,17 @@ def callback(live): if live: # add callback for seed_layer change if seed_layer is not None: + def change(*args, **kwargs): # this sets off the auto run widget.toggle.value = 1 - widget.toggle.value cb = seed_layer.events.set_data.connect(change) interactive_callbacks.append(cb) + return callback + def add_interactive_callback(widget, interactive_callbacks): def callback(seed_layer): if seed_layer is not None: @@ -47,6 +57,7 @@ def change(*args, **kwargs): # add new callback cb = seed_layer.events.set_data.connect(change) interactive_callbacks.append(cb) + return callback