Skip to content

Commit 8d7ee71

Browse files
Merge pull request #139 from computational-cell-analytics/model-fixes
Fix mitochondria2 model and add proper model test
2 parents 4dc4b21 + ba1e5e7 commit 8d7ee71

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

synapse_net/inference/inference.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def get_model_training_resolution(model_type: str) -> Dict[str, float]:
112112
"active_zone": {"x": 1.38, "y": 1.38, "z": 1.38},
113113
"compartments": {"x": 3.47, "y": 3.47, "z": 3.47},
114114
"mitochondria": {"x": 2.07, "y": 2.07, "z": 2.07},
115+
# TODO: this is just copied from the previous mito model, it may be necessary to update this.
116+
"mitochondria2": {"x": 2.07, "y": 2.07, "z": 2.07},
115117
"cristae": {"x": 1.44, "y": 1.44, "z": 1.44},
116118
"ribbon": {"x": 1.188, "y": 1.188, "z": 1.188},
117119
"vesicles_2d": {"x": 1.35, "y": 1.35},

test/test_inference.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from shutil import rmtree
55

66
import imageio.v3 as imageio
7+
import requests
78
from synapse_net.file_utils import read_mrc
89
from synapse_net.sample_data import get_sample_data
910

@@ -23,6 +24,26 @@ def tearDown(self):
2324
except OSError:
2425
pass
2526

27+
# Test that all models can be accessed by pooch and have the necessary resolution information.
28+
def test_models(self):
29+
from synapse_net.inference.inference import _get_model_registry, get_model_training_resolution
30+
31+
def check_url(url):
32+
try:
33+
# Make a HEAD request to the URL, which fetches HTTP headers but no content.
34+
response = requests.head(url, allow_redirects=True)
35+
# Check if the HTTP status code is one that indicates availability (200 <= code < 400).
36+
return response.status_code < 400
37+
except requests.RequestException:
38+
# Handle connection exceptions
39+
return False
40+
41+
registry = _get_model_registry()
42+
for name in registry.registry.keys():
43+
url_exists = check_url(registry.get_url(name))
44+
self.assertTrue(url_exists)
45+
get_model_training_resolution(name)
46+
2647
def test_run_segmentation(self):
2748
from synapse_net.inference import run_segmentation, get_model
2849

0 commit comments

Comments
 (0)