Skip to content

Commit dc372ce

Browse files
authored
POL5802 harmonize async() with python 3.12 (PolusAI#286)
1 parent ad62055 commit dc372ce

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

src/nyx/workflow_wholeslide.cpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ namespace Nyxus
7676
if (vroi.aux_image_matrix._pix_plane.size())
7777
std::vector<PixIntens>().swap(vroi.aux_image_matrix._pix_plane);
7878

79-
// allow heyboard interrupt
80-
#ifdef WITH_PYTHON_H
81-
if (PyErr_CheckSignals() != 0)
82-
{
83-
sureprint("\nAborting per user input\n");
84-
throw pybind11::error_already_set();
85-
}
86-
#endif
87-
8879
// no need to calculate neighbor features in WSI, returning
8980
return true;
9081
}
@@ -200,15 +191,6 @@ namespace Nyxus
200191
// Not saving nested ROI related info because this image is single-ROI (whole-slide)
201192
//
202193

203-
// allow heyboard interrupt
204-
#ifdef WITH_PYTHON_H
205-
if (PyErr_CheckSignals() != 0)
206-
{
207-
sureprint("\nAborting per user input\n");
208-
throw pybind11::error_already_set();
209-
}
210-
#endif
211-
212194
rv = 0; // success
213195
}
214196

@@ -336,6 +318,15 @@ namespace Nyxus
336318
rval);
337319
}
338320
}
321+
322+
// allow keyboard interrupt
323+
#ifdef WITH_PYTHON_H
324+
if (PyErr_CheckSignals() != 0)
325+
{
326+
sureprint("\nAborting per user input\n");
327+
throw pybind11::error_already_set();
328+
}
329+
#endif
339330
}
340331

341332
//**** finalize Apache output

tests/python/test_nyxus.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,34 @@ def test_image_quality_montage_single_roi(self):
695695

696696
assert directory_features.shape[1] > 3
697697

698-
@pytest.mark.skipif(sys.version_info[:2] == (3, 12), reason="Skipped for Python 3.12")
698+
def test_nonimq_wsi_scalability (self):
699+
'''
700+
Test of consistency of scalable regular 2D feature calculation
701+
via the whole-slide workflow at
702+
varying number of threads.
703+
'''
704+
705+
path = str(pathlib.Path(__file__).parent.resolve())
706+
data_path = path + '/data/'
707+
nyx = nyxus.Nyxus (["*WHOLESLIDE*"])
708+
709+
p = { "n_feature_calc_threads": 1}
710+
nyx.set_params(**p)
711+
f1 = nyx.featurize_directory (data_path + 'int/', data_path + 'int/')
712+
s1 = f1.sum(numeric_only=True, axis=0)
713+
714+
p = { "n_feature_calc_threads": 2}
715+
nyx.set_params(**p)
716+
f2 = nyx.featurize_directory (data_path + 'int/', data_path + 'int/')
717+
s2 = f2.sum(numeric_only=True, axis=0)
718+
719+
p = { "n_feature_calc_threads": 4}
720+
nyx.set_params(**p)
721+
f4 = nyx.featurize_directory (data_path + 'int/', data_path + 'int/')
722+
s4 = f4.sum(numeric_only=True, axis=0)
723+
724+
assert s1.equals(s2) and s1.equals(s4)
725+
699726
def test_featureset_consistency (self):
700727
'''
701728
This test checks if 2D and image quality features are isolated

0 commit comments

Comments
 (0)