celldetective 1.5.0b5__py3-none-any.whl → 1.5.0b7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
celldetective/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.5.0b5"
1
+ __version__ = "1.5.0b7"
@@ -879,6 +879,14 @@ class StackVisualizer(CelldetectiveWidget):
879
879
  # Event handler for closing the widget
880
880
  if self.loader_thread:
881
881
  self.loader_thread.stop()
882
+ self.loader_thread = None
882
883
  if hasattr(self, "frame_cache") and isinstance(self.frame_cache, OrderedDict):
883
884
  self.frame_cache.clear()
884
885
  self.canvas.close()
886
+
887
+ def __del__(self):
888
+ try:
889
+ if hasattr(self, "loader_thread") and self.loader_thread:
890
+ self.loader_thread.stop()
891
+ except:
892
+ pass
@@ -122,15 +122,29 @@ class UnifiedBatchProcess(Process):
122
122
  signal_model = None
123
123
 
124
124
  if self.run_signals:
125
- from celldetective.utils.event_detection import _prep_event_detection_model
126
-
127
125
  try:
126
+ from celldetective.utils.event_detection import (
127
+ _prep_event_detection_model,
128
+ )
129
+
128
130
  logger.info("Loading the event detection model...")
129
131
  self.queue.put({"status": "Loading event detection model..."})
130
132
  model_name = self.signal_args["model_name"]
131
133
  signal_model = _prep_event_detection_model(
132
134
  model_name, use_gpu=self.signal_args.get("gpu", True)
133
135
  )
136
+ except (ImportError, ModuleNotFoundError) as e:
137
+ if "tensorflow" in str(e):
138
+ logger.warning(
139
+ "Tensorflow not found/installed. Signal analysis will be skipped."
140
+ )
141
+ self.run_signals = False
142
+ else:
143
+ logger.error(
144
+ f"Failed to initialize event detection model: {e}",
145
+ exc_info=True,
146
+ )
147
+ self.run_signals = False
134
148
  except Exception as e:
135
149
  logger.error(
136
150
  f"Failed to initialize event detection model: {e}", exc_info=True
@@ -104,14 +104,27 @@ def _prep_cellpose_model(
104
104
  `diam_labels` are attributes of the model.
105
105
  """
106
106
 
107
- import torch
107
+ try:
108
+ import torch
109
+ except ImportError as e:
110
+ raise RuntimeError(
111
+ "Torch is not installed. Please install it to use this feature.\n"
112
+ "You can install the full package with: pip install celldetective[all]\n"
113
+ ) from e
108
114
 
109
115
  if not use_gpu:
110
116
  device = torch.device("cpu")
111
117
  else:
112
118
  device = torch.device("cuda")
113
119
 
114
- from cellpose.models import CellposeModel
120
+ try:
121
+ from cellpose.models import CellposeModel
122
+ except ImportError as e:
123
+ raise RuntimeError(
124
+ "Cellpose is not installed. Please install it to use this feature.\n"
125
+ "You can install the full package with: pip install celldetective[all]\n"
126
+ "Or specifically: pip install celldetective[cellpose]"
127
+ ) from e
115
128
 
116
129
  try:
117
130
  model = CellposeModel(
@@ -77,18 +77,39 @@ def download_url_to_file(url, dst, progress=True):
77
77
  Default: True
78
78
 
79
79
  """
80
- file_size = None
81
80
  import ssl
81
+ import time
82
+ from urllib.error import HTTPError, URLError
82
83
 
84
+ file_size = None
83
85
  ssl._create_default_https_context = ssl._create_unverified_context
84
- u = urlopen(url)
85
- meta = u.info()
86
- if hasattr(meta, "getheaders"):
87
- content_length = meta.getheaders("Content-Length")
88
- else:
89
- content_length = meta.get_all("Content-Length")
90
- if content_length is not None and len(content_length) > 0:
91
- file_size = int(content_length[0])
86
+
87
+ # Retry configuration
88
+ max_retries = 5
89
+ retry_delay = 10 # Initial delay in seconds
90
+
91
+ for attempt in range(max_retries):
92
+ try:
93
+ u = urlopen(url)
94
+ meta = u.info()
95
+ if hasattr(meta, "getheaders"):
96
+ content_length = meta.getheaders("Content-Length")
97
+ else:
98
+ content_length = meta.get_all("Content-Length")
99
+ if content_length is not None and len(content_length) > 0:
100
+ file_size = int(content_length[0])
101
+ break # Success
102
+ except (HTTPError, URLError) as e:
103
+ if attempt < max_retries - 1:
104
+ logger.warning(
105
+ f"Download check failed: {e}. Retrying in {retry_delay}s..."
106
+ )
107
+ time.sleep(retry_delay)
108
+ retry_delay *= 2 # Exponential backoff
109
+ else:
110
+ logger.error(f"Download check failed after {max_retries} attempts: {e}")
111
+ raise e
112
+
92
113
  # We deliberately save it in a temp file and move it after
93
114
  dst = os.path.expanduser(dst)
94
115
  dst_dir = os.path.dirname(dst)
@@ -143,14 +164,27 @@ def download_url_to_file(url, dst, progress=True):
143
164
  unit_divisor=1024,
144
165
  ) as pbar:
145
166
  while True:
146
- buffer = u.read(8192) # 8192
147
- if len(buffer) == 0:
148
- break
149
- f.write(buffer)
150
- pbar.update(len(buffer))
167
+ try:
168
+ buffer = u.read(8192) # 8192
169
+ if len(buffer) == 0:
170
+ break
171
+ f.write(buffer)
172
+ pbar.update(len(buffer))
173
+ except (HTTPError, URLError) as e:
174
+ # Attempt rudimentary resume-like behavior or just fail?
175
+ # Simple retry of read is hard without Range headers on a stream.
176
+ # Best to just fail the whole download and rely on outer retry if we wrapped the whole thing.
177
+ # For now, let's just let it raise, but really we should wrap the whole download block.
178
+ raise e
151
179
 
152
180
  f.close()
153
181
  shutil.move(f.name, dst)
182
+ except Exception as e:
183
+ f.close()
184
+ remove_file_if_exists(f.name)
185
+ # If we failed during download reading (after open), we should probably retry the whole function from start
186
+ # but that requires significant refactoring. Given the error was 504 on open, the retry block above handles it.
187
+ raise e
154
188
  finally:
155
189
  f.close()
156
190
  remove_file_if_exists(f.name)
@@ -43,7 +43,13 @@ def _prep_stardist_model(
43
43
  - GPU support depends on the availability of compatible hardware and software setup.
44
44
  """
45
45
 
46
- from stardist.models import StarDist2D
46
+ try:
47
+ from stardist.models import StarDist2D
48
+ except ImportError as e:
49
+ raise RuntimeError(
50
+ "StarDist is not installed. Please install it to use this feature.\n"
51
+ "You can install the full package with: pip install celldetective[all]"
52
+ ) from e
47
53
 
48
54
  model = StarDist2D(None, name=model_name, basedir=path)
49
55
  model.config.use_gpu = use_gpu
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: celldetective
3
- Version: 1.5.0b5
3
+ Version: 1.5.0b7
4
4
  Summary: description
5
5
  Home-page: http://github.com/remyeltorro/celldetective
6
6
  Author: Rémy Torro
@@ -15,11 +15,8 @@ Requires-Dist: sphinx_rtd_theme
15
15
  Requires-Dist: sphinx
16
16
  Requires-Dist: jinja2
17
17
  Requires-Dist: ipykernel
18
- Requires-Dist: stardist
19
- Requires-Dist: cellpose<3
20
18
  Requires-Dist: scikit-learn
21
19
  Requires-Dist: btrack
22
- Requires-Dist: tensorflow~=2.15.0
23
20
  Requires-Dist: napari<0.6.0
24
21
  Requires-Dist: tqdm
25
22
  Requires-Dist: mahotas
@@ -48,6 +45,15 @@ Requires-Dist: prettyprint
48
45
  Requires-Dist: pandas
49
46
  Requires-Dist: matplotlib
50
47
  Requires-Dist: prettytable
48
+ Requires-Dist: scikit-image
49
+ Requires-Dist: natsort
50
+ Provides-Extra: tensorflow
51
+ Requires-Dist: tensorflow~=2.15.0; extra == "tensorflow"
52
+ Requires-Dist: stardist; extra == "tensorflow"
53
+ Provides-Extra: all
54
+ Requires-Dist: cellpose<3; extra == "all"
55
+ Requires-Dist: stardist; extra == "all"
56
+ Requires-Dist: tensorflow~=2.15.0; extra == "all"
51
57
  Dynamic: author
52
58
  Dynamic: author-email
53
59
  Dynamic: description
@@ -55,6 +61,7 @@ Dynamic: description-content-type
55
61
  Dynamic: home-page
56
62
  Dynamic: license
57
63
  Dynamic: license-file
64
+ Dynamic: provides-extra
58
65
  Dynamic: requires-dist
59
66
  Dynamic: summary
60
67
 
@@ -148,10 +155,12 @@ To use the software, you must install python, *e.g.* through
148
155
 
149
156
  Celldetective requires a version of Python between 3.9 and 3.11 (included). If your Python version is older or more recent, consider using `conda` to create an environment as described below.
150
157
 
151
- With the proper Python version, Celldetective can be directly installed with `pip`:
158
+ With the proper Python version, Celldetective can be directly installed with `pip`.
159
+ **Important**: By default, `pip install celldetective` will **not** install deep-learning libraries (`tensorflow`, `cellpose`, `stardist`) to allow users to manage their own GPU environment (e.g. `torch`, `cuda`).
152
160
 
161
+ If you want the standard full installation (recommended for most users), use:
153
162
  ``` bash
154
- pip install celldetective
163
+ pip install celldetective[all]
155
164
  ```
156
165
 
157
166
  We recommend that you create an environment to use Celldetective, to protect your package versions and fix the Python version *e.g.*
@@ -160,7 +169,7 @@ with `conda`:
160
169
  ``` bash
161
170
  conda create -n celldetective python=3.11 pyqt
162
171
  conda activate celldetective
163
- pip install celldetective
172
+ pip install celldetective[all]
164
173
  ```
165
174
 
166
175
  Need an update? Simply type the following in the terminal (in your
@@ -1,6 +1,6 @@
1
1
  celldetective/__init__.py,sha256=LfnOyfUnYPGDc8xcsF_PfYEL7-CqAb7BMBPBIWGv84o,666
2
2
  celldetective/__main__.py,sha256=Rzzu9ArxZSgfBVjV-lyn-3oanQB2MumQR6itK5ZaRpA,2597
3
- celldetective/_version.py,sha256=WqWa8H3XCjzmFMLQoflfXoLyQGm-ej1fcgZfMqTF--U,24
3
+ celldetective/_version.py,sha256=PxAZ8DovjTTFvob973OaT7yXi4GAYpuAcRntt0ZchLM,24
4
4
  celldetective/events.py,sha256=n15R53c7QZ2wT8gjb0oeNikQbuRBrVVbyNsRCqXjzXA,8166
5
5
  celldetective/exceptions.py,sha256=f3VmIYOthWTiqMEV5xQCox2rw5c5e7yog88h-CcV4oI,356
6
6
  celldetective/extra_properties.py,sha256=s_2R4_El2p-gQNZ_EpgDxgrN3UnRitN7KDKHhyLuoHc,21681
@@ -87,7 +87,7 @@ celldetective/gui/table_ops/_merge_one_hot.py,sha256=gKRgem-u_-JENkVkbjRobsH4TkS
87
87
  celldetective/gui/table_ops/_query_table.py,sha256=K-XHSZ1I4v2wwqWjyQAgyFRZJbem3CmTfHmO0vijh9g,1345
88
88
  celldetective/gui/table_ops/_rename_col.py,sha256=UAgDSpXJo_h4pLJpHaNc2w2VhbaW4D2JZTgJ3cYC4-g,1457
89
89
  celldetective/gui/viewers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
90
- celldetective/gui/viewers/base_viewer.py,sha256=ir3J8QyLDAijOMu0Np56lUR0fSeWhz_1xdb_bX6rdRk,31939
90
+ celldetective/gui/viewers/base_viewer.py,sha256=wA2Zrje5nQSUmwnAFCe9hcL1MOWg8uMKwFTWhEYiMXI,32159
91
91
  celldetective/gui/viewers/channel_offset_viewer.py,sha256=cywBkxyMPyKIuwZTGA03DBSS4a-H1SAohMJYOPISLEE,16289
92
92
  celldetective/gui/viewers/contour_viewer.py,sha256=riHj03LKXLoa-Ys2o2EhCE5nULfcHMohx9LFoXbI6zU,14720
93
93
  celldetective/gui/viewers/size_viewer.py,sha256=uXITjaxg5dhQ09Q6TNUxwLxi-ZglyGFcxEH1RtGIZWw,6020
@@ -126,7 +126,7 @@ celldetective/processes/segment_cells.py,sha256=klGl5y3tHbLbQFNAQz0PV1FspmiPC-GH
126
126
  celldetective/processes/track_cells.py,sha256=ndKZpVXonnooOVnHK5AVED5i_i2bZ4FefTt1_dEZS48,15188
127
127
  celldetective/processes/train_segmentation_model.py,sha256=j1aPgR4CzF2OR-9njriNmUStVViiWaiicQA9YWRWOTo,25411
128
128
  celldetective/processes/train_signal_model.py,sha256=HInUHCXNePhfQs8-DQOreJ19LtLkQopvYSyX8tj0mOo,9498
129
- celldetective/processes/unified_process.py,sha256=vHAS_LbtwmlOjKho_FpwDy7WHVgyY38s3X2BtHxep7A,11671
129
+ celldetective/processes/unified_process.py,sha256=xvNrYtZaRgpjEWzrPSYoY6dmqJbC81udDojkHuT4iTc,12251
130
130
  celldetective/regionprops/__init__.py,sha256=ohe9vC7j4lnpKnGXidVo1PVfoQfC8TqCuHTNo8rXmdg,44
131
131
  celldetective/regionprops/_regionprops.py,sha256=spq_Mb43HjHiKqot7yjLJl_jrMTNfIP8NLrPnCEm8Nc,13306
132
132
  celldetective/regionprops/props.json,sha256=sCwACmbh0n-JAw9eve9yV85REukoMBJLsRjxCwTRMm8,2424
@@ -143,7 +143,7 @@ celldetective/utils/color_mappings.py,sha256=yarqOTSrTsnOPPiPrrN_vLoPCbgWqF3wjqF
143
143
  celldetective/utils/data_cleaning.py,sha256=K-2gScxLreX7QkrM0h3dZdP0IsmvCzcxNh2-M9PALZY,22025
144
144
  celldetective/utils/data_loaders.py,sha256=6Jg99U93qYjjs2xZErc2cz37tcH5e4vEqDH8PJgoEJs,17077
145
145
  celldetective/utils/dataset_helpers.py,sha256=3ezpHO6nytw2Mx0D3maP_4535V2ohOTQn6Qpfk8gnms,6898
146
- celldetective/utils/downloaders.py,sha256=BIl_8XCeaKvtMVC36WITT2g5-O-n0csoMEQXVoa1B4o,7887
146
+ celldetective/utils/downloaders.py,sha256=o5sogEeYr-LR8mp1D7uNHH1aUJN3V82VVwYZvoSNTkQ,9506
147
147
  celldetective/utils/experiment.py,sha256=bgADS70QuW4KGbzDJbVpVM-tw4qmZKMWtDT1cSxugrY,58342
148
148
  celldetective/utils/image_augmenters.py,sha256=USYd8z6dVn5z1x96IYJ4mG0smN9I_S21QMGU0wyHmjc,11654
149
149
  celldetective/utils/image_cleaning.py,sha256=KliQ3K5hdwPx4eFxJnmg3yi-ZIoimEveunPJkbbA6wA,2388
@@ -161,12 +161,12 @@ celldetective/utils/parsing.py,sha256=1zpIH9tyULCRmO5Kwzy6yA01fqm5uE_mZKYtondy-V
161
161
  celldetective/utils/resources.py,sha256=3Fz_W0NYWl_Ixc2AjEmkOv5f7ejXerCLJ2z1iWhGWUI,1153
162
162
  celldetective/utils/stats.py,sha256=4TVHRqi38Y0sed-izaMI51sMP0fd5tC5M68EYyfJjkE,3636
163
163
  celldetective/utils/types.py,sha256=lRfWSMVzTkxgoctGGp0NqD551akuxu0ygna7zVGonTg,397
164
- celldetective/utils/cellpose_utils/__init__.py,sha256=MeRDojrAkBSXe-wlLu5KIih5wXP9B2aPdP39JLYpoGE,5417
164
+ celldetective/utils/cellpose_utils/__init__.py,sha256=g41EiR6p29bHkXQN-SFHymoeaoTEfuozEFSGMuTd30Q,5991
165
165
  celldetective/utils/event_detection/__init__.py,sha256=KX20PwPTevdbZ-25otDy_QTmealcDx5xNCfH2SOVIZM,323
166
166
  celldetective/utils/plots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
167
167
  celldetective/utils/plots/regression.py,sha256=oUCn29-hp7PxMqC-R0yoL60KMw5ZWpZAIoCDh2ErlcY,1764
168
- celldetective/utils/stardist_utils/__init__.py,sha256=e9s3DEaTKCUOGZb5k_DgShBTl4B0U-Jmg3Ioo8D5PyE,3978
169
- celldetective-1.5.0b5.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
168
+ celldetective/utils/stardist_utils/__init__.py,sha256=SY2kxFNXSRjXN4ncs3heDdXT3UNk8M3dELJQySysAf4,4231
169
+ celldetective-1.5.0b7.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
170
170
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
171
171
  tests/test_cellpose_fallback.py,sha256=BJZTDFF8sFR1x7rDbvZQ2RQOB1OP6wuFBRfc8zbl5zw,3513
172
172
  tests/test_events.py,sha256=eLFwwEEJfQAdwhews3-fn1HSvzozcNNFN_Qn0gOvQkE,685
@@ -175,6 +175,7 @@ tests/test_io.py,sha256=gk5FmoI7ANEczUtNXYRxc48KzkfYzemwS_eYaLq4_NI,2093
175
175
  tests/test_measure.py,sha256=FEUAs1rVHylvIvubCb0bJDNGZLVmkgXNgI3NaGQ1dA8,4542
176
176
  tests/test_neighborhood.py,sha256=gk5FmoI7ANEczUtNXYRxc48KzkfYzemwS_eYaLq4_NI,2093
177
177
  tests/test_notebooks.py,sha256=7HVmYiytsz0QIJ11iRkGGs4_hzNjofXAUs_OZou3Gm0,301
178
+ tests/test_partial_install.py,sha256=G69-GNcJ9YNgs6K2bVTEZO0Jpb14xMRQWTm8A6VuIco,2841
178
179
  tests/test_preprocessing.py,sha256=c0rKS9d5h37uDcV7fVOTnn5GMVbEB84b8ZTCTdRmvFs,1422
179
180
  tests/test_segmentation.py,sha256=k1b_zIZdlytEdJcHjAUQEO3gTBAHtv5WvrwQN2xD4kc,3470
180
181
  tests/test_signals.py,sha256=No4cah6KxplhDcKXnU8RrA7eDla4hWw6ccf7xGnBokU,3599
@@ -185,8 +186,8 @@ tests/gui/test_enhancements.py,sha256=3x9au_rkQtMZ94DRj3OaEHKPr511RrWqBAUAcNQn1y
185
186
  tests/gui/test_measure_annotator_bugfix.py,sha256=tPfgWNKC0UkvrVssSrUcVDC1qgpzx6l2yCqvKtKYkM4,4544
186
187
  tests/gui/test_new_project.py,sha256=wRjW2vEaZb0LWT-f8G8-Ptk8CW9z8-FDPLpV5uqj6ck,8778
187
188
  tests/gui/test_project.py,sha256=KzAnodIc0Ovta0ARL5Kr5PkOR5euA6qczT_GhEZpyE4,4710
188
- celldetective-1.5.0b5.dist-info/METADATA,sha256=HXfAb1NZp3md807sossVoljx3m1O4VYRaJrgjaq8T0c,10947
189
- celldetective-1.5.0b5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
190
- celldetective-1.5.0b5.dist-info/entry_points.txt,sha256=2NU6_EOByvPxqBbCvjwxlVlvnQreqZ3BKRCVIKEv3dg,62
191
- celldetective-1.5.0b5.dist-info/top_level.txt,sha256=6rsIKKfGMKgud7HPuATcpq6EhdXwcg_yknBVWn9x4C4,20
192
- celldetective-1.5.0b5.dist-info/RECORD,,
189
+ celldetective-1.5.0b7.dist-info/METADATA,sha256=qOwqT_qSpFnGY0CXpVIFdSUV4atTi3FV4M4Kn57tNAg,11523
190
+ celldetective-1.5.0b7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
191
+ celldetective-1.5.0b7.dist-info/entry_points.txt,sha256=2NU6_EOByvPxqBbCvjwxlVlvnQreqZ3BKRCVIKEv3dg,62
192
+ celldetective-1.5.0b7.dist-info/top_level.txt,sha256=6rsIKKfGMKgud7HPuATcpq6EhdXwcg_yknBVWn9x4C4,20
193
+ celldetective-1.5.0b7.dist-info/RECORD,,
@@ -0,0 +1,75 @@
1
+ import unittest
2
+ from unittest.mock import MagicMock, patch
3
+ import sys
4
+ import importlib
5
+
6
+
7
+ class TestPartialValidation(unittest.TestCase):
8
+
9
+ def test_imports_without_extras(self):
10
+ """Test that main modules can be imported even if optional extras are missing."""
11
+ # This test assumes the environment MIGHT have them, so we must mock them as missing
12
+ # to ensure the code handles it.
13
+
14
+ with patch.dict(
15
+ sys.modules,
16
+ {
17
+ "tensorflow": None,
18
+ "torch": None,
19
+ "stardist": None,
20
+ "cellpose": None,
21
+ "cellpose.models": None,
22
+ "stardist.models": None,
23
+ },
24
+ ):
25
+ # Force reload of celldetective.segmentation to test its imports
26
+ try:
27
+ import celldetective.segmentation
28
+
29
+ importlib.reload(celldetective.segmentation)
30
+ except ImportError as e:
31
+ self.fail(
32
+ f"Could not import celldetective.segmentation without extras: {e}"
33
+ )
34
+ except Exception as e:
35
+ self.fail(f"Unexpected error importing celldetective.segmentation: {e}")
36
+
37
+ def test_graceful_failure_stardist(self):
38
+ """Test that calling stardist functions raises RuntimeError if missing."""
39
+ with patch.dict(sys.modules, {"stardist": None, "stardist.models": None}):
40
+ # We need to reload the util module to pick up the missing module
41
+ import celldetective.utils.stardist_utils
42
+
43
+ importlib.reload(celldetective.utils.stardist_utils)
44
+
45
+ from celldetective.utils.stardist_utils import _prep_stardist_model
46
+
47
+ with self.assertRaises(RuntimeError) as cm:
48
+ _prep_stardist_model("fake_model", "fake_path")
49
+
50
+ self.assertIn("StarDist is not installed", str(cm.exception))
51
+
52
+ def test_graceful_failure_cellpose(self):
53
+ """Test that calling cellpose functions raises RuntimeError if missing."""
54
+ with patch.dict(
55
+ sys.modules, {"cellpose": None, "cellpose.models": None, "torch": None}
56
+ ):
57
+ import celldetective.utils.cellpose_utils
58
+
59
+ importlib.reload(celldetective.utils.cellpose_utils)
60
+
61
+ from celldetective.utils.cellpose_utils import _prep_cellpose_model
62
+
63
+ with self.assertRaises(RuntimeError) as cm:
64
+ _prep_cellpose_model("fake_model", "fake_path")
65
+
66
+ # Message check might correspond to torch or cellpose depending on which import hits first
67
+ # Our code checks torch first.
68
+ self.assertTrue(
69
+ "Torch is not installed" in str(cm.exception)
70
+ or "Cellpose is not installed" in str(cm.exception)
71
+ )
72
+
73
+
74
+ if __name__ == "__main__":
75
+ unittest.main()