dcnum 0.16.6__py3-none-any.whl → 0.16.7__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.
Potentially problematic release.
This version of dcnum might be problematic. Click here for more details.
- dcnum/_version.py +2 -2
- dcnum/feat/event_extractor_manager_thread.py +16 -0
- dcnum/logic/ctrl.py +1 -0
- dcnum/write/deque_writer_thread.py +5 -3
- dcnum/write/writer.py +6 -6
- {dcnum-0.16.6.dist-info → dcnum-0.16.7.dist-info}/METADATA +1 -1
- {dcnum-0.16.6.dist-info → dcnum-0.16.7.dist-info}/RECORD +10 -10
- {dcnum-0.16.6.dist-info → dcnum-0.16.7.dist-info}/LICENSE +0 -0
- {dcnum-0.16.6.dist-info → dcnum-0.16.7.dist-info}/WHEEL +0 -0
- {dcnum-0.16.6.dist-info → dcnum-0.16.7.dist-info}/top_level.txt +0 -0
dcnum/_version.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Feature computation: managing event extraction threads"""
|
|
2
|
+
import collections
|
|
2
3
|
import logging
|
|
3
4
|
import multiprocessing as mp
|
|
4
5
|
import threading
|
|
@@ -17,6 +18,7 @@ class EventExtractorManagerThread(threading.Thread):
|
|
|
17
18
|
labels_list: List,
|
|
18
19
|
fe_kwargs: Dict,
|
|
19
20
|
num_workers: int,
|
|
21
|
+
writer_dq: collections.deque,
|
|
20
22
|
debug: bool = False,
|
|
21
23
|
*args, **kwargs):
|
|
22
24
|
"""Manage event extraction threads or precesses
|
|
@@ -40,6 +42,9 @@ class EventExtractorManagerThread(threading.Thread):
|
|
|
40
42
|
:func:`.EventExtractor.get_init_kwargs` for more information.
|
|
41
43
|
num_workers:
|
|
42
44
|
Number of child threads or worker processes to use.
|
|
45
|
+
writer_dq:
|
|
46
|
+
The queue the writer uses. We monitor this queue. If it
|
|
47
|
+
fills up, we take a break.
|
|
43
48
|
debug:
|
|
44
49
|
Whether to run in debugging mode which means more log
|
|
45
50
|
messages and only one thread (`num_workers` has no effect).
|
|
@@ -66,6 +71,8 @@ class EventExtractorManagerThread(threading.Thread):
|
|
|
66
71
|
self.label_array = np.ctypeslib.as_array(
|
|
67
72
|
self.fe_kwargs["label_array"]).reshape(
|
|
68
73
|
self.data.image.chunk_shape)
|
|
74
|
+
#: Writer deque to monitor
|
|
75
|
+
self.writer_dq = writer_dq
|
|
69
76
|
#: Time counter for feature extraction
|
|
70
77
|
self.t_count = 0
|
|
71
78
|
#: Whether debugging is enabled
|
|
@@ -86,6 +93,15 @@ class EventExtractorManagerThread(threading.Thread):
|
|
|
86
93
|
chunks_processed = 0
|
|
87
94
|
frames_processed = 0
|
|
88
95
|
while True:
|
|
96
|
+
# If the writer_dq starts filling up, then this could lead to
|
|
97
|
+
# an oom-kill signal. Stall for the writer to prevent this.
|
|
98
|
+
ldq = len(self.writer_dq)
|
|
99
|
+
if ldq > 100:
|
|
100
|
+
stallsec = ldq / 100
|
|
101
|
+
self.logger.warning(
|
|
102
|
+
f"Stalling {stallsec:.1f}s for slow writer.")
|
|
103
|
+
time.sleep(stallsec)
|
|
104
|
+
|
|
89
105
|
cur_slot = 0
|
|
90
106
|
unavailable_slots = 0
|
|
91
107
|
# Check all slots for segmented labels
|
dcnum/logic/ctrl.py
CHANGED
|
@@ -41,11 +41,13 @@ class DequeWriterThread(threading.Thread):
|
|
|
41
41
|
|
|
42
42
|
def run(self):
|
|
43
43
|
while True:
|
|
44
|
+
ldq = len(self.dq)
|
|
44
45
|
if self.must_stop_loop:
|
|
45
46
|
break
|
|
46
|
-
elif
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
elif ldq:
|
|
48
|
+
for _ in range(ldq):
|
|
49
|
+
feat, data = self.dq.popleft()
|
|
50
|
+
self.writer.store_feature_chunk(feat=feat, data=data)
|
|
49
51
|
elif self.may_stop_loop:
|
|
50
52
|
break
|
|
51
53
|
else:
|
dcnum/write/writer.py
CHANGED
|
@@ -35,7 +35,7 @@ class HDF5Writer:
|
|
|
35
35
|
|
|
36
36
|
@staticmethod
|
|
37
37
|
def get_best_nd_chunks(item_shape, feat_dtype=np.float64):
|
|
38
|
-
"""Return best chunks for
|
|
38
|
+
"""Return best chunks for HDF5 datasets
|
|
39
39
|
|
|
40
40
|
Chunking has performance implications. It’s recommended to keep the
|
|
41
41
|
total size of dataset chunks between 10 KiB and 1 MiB. This number
|
|
@@ -44,6 +44,7 @@ class HDF5Writer:
|
|
|
44
44
|
"""
|
|
45
45
|
# set image feature chunk size to approximately 1MiB
|
|
46
46
|
num_bytes = 1024 ** 2
|
|
47
|
+
# Note that `np.prod(()) == 1`
|
|
47
48
|
event_size = np.prod(item_shape) * np.dtype(feat_dtype).itemsize
|
|
48
49
|
chunk_size = num_bytes / event_size
|
|
49
50
|
# Set minimum chunk size to 10 so that we can have at least some
|
|
@@ -53,12 +54,11 @@ class HDF5Writer:
|
|
|
53
54
|
|
|
54
55
|
def require_feature(self, feat, item_shape, feat_dtype, ds_kwds=None):
|
|
55
56
|
"""Create a new feature in the "events" group"""
|
|
56
|
-
|
|
57
|
-
if ds_kwds is None:
|
|
58
|
-
ds_kwds = {}
|
|
59
|
-
for key in self.ds_kwds:
|
|
60
|
-
ds_kwds.setdefault(key, self.ds_kwds[key])
|
|
61
57
|
if feat not in self.events:
|
|
58
|
+
if ds_kwds is None:
|
|
59
|
+
ds_kwds = {}
|
|
60
|
+
for key in self.ds_kwds:
|
|
61
|
+
ds_kwds.setdefault(key, self.ds_kwds[key])
|
|
62
62
|
dset = self.events.create_dataset(
|
|
63
63
|
feat,
|
|
64
64
|
shape=tuple([0] + list(item_shape)),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
dcnum/__init__.py,sha256=hcawIKS7utYiOyVhOAX9t7K3xYzP1b9862VV0b6qSrQ,74
|
|
2
|
-
dcnum/_version.py,sha256=
|
|
2
|
+
dcnum/_version.py,sha256=qnrnqIwaxxSmbCyOa5NQksqjVQLJBzYOk8VUPMYeuoY,413
|
|
3
3
|
dcnum/feat/__init__.py,sha256=JqlgzOgDJhoTk8WVYcIiKTWq9EAM16_jGivzOtN6JGo,325
|
|
4
|
-
dcnum/feat/event_extractor_manager_thread.py,sha256=
|
|
4
|
+
dcnum/feat/event_extractor_manager_thread.py,sha256=NSoey-h-STIAvadHWDbkhXsB6FZ_SkYnBbEC6JWkTQ0,7130
|
|
5
5
|
dcnum/feat/gate.py,sha256=ZTV2tkNqJBGmwemZrI0IAaPXTLgWO_5ZVxnpqr2G1cI,7464
|
|
6
6
|
dcnum/feat/queue_event_extractor.py,sha256=eacmcM_uHHW6GtqCCtDCZib9423TGvuqgxGKAxv0tgc,15686
|
|
7
7
|
dcnum/feat/feat_background/__init__.py,sha256=OTmMuazHNaSrZb2XW4cnJ6PlgJLbKrPbaidpEixYa0A,341
|
|
@@ -19,7 +19,7 @@ dcnum/feat/feat_texture/__init__.py,sha256=6StM9S540UVtdFFR3bHa7nfCTomeVdoo7Uy9C
|
|
|
19
19
|
dcnum/feat/feat_texture/common.py,sha256=COXHpXS-7DMouGu3WF83I76L02Sr7P9re4lxajh6g0E,439
|
|
20
20
|
dcnum/feat/feat_texture/tex_all.py,sha256=eGjjNfPpfZw7FA_VNFCIMiU38KD0qcGbxLciYy-tCiA,4097
|
|
21
21
|
dcnum/logic/__init__.py,sha256=7J3GrwJInNQbrLk61HRIV7X7p69TAIbMYpR34hh6u14,177
|
|
22
|
-
dcnum/logic/ctrl.py,sha256=
|
|
22
|
+
dcnum/logic/ctrl.py,sha256=Gd17hdEYTxvdXZkTqqul4WUCu5wf4Gf0f8LZJ9EX83k,26725
|
|
23
23
|
dcnum/logic/job.py,sha256=M0Q-Rfcm-zkTXTQc79W6YSNUjUlgmRPG0Ikbdn1aOpY,4608
|
|
24
24
|
dcnum/logic/json_encoder.py,sha256=dy44ArmdnxpUfxxONmKdIv-fde3aTXPjZDN0HPATaxs,467
|
|
25
25
|
dcnum/meta/__init__.py,sha256=cQT_HN5yDKzMnZM8CUyNmeA68OhE3ENO_rvFmgDj95c,40
|
|
@@ -35,11 +35,11 @@ dcnum/segm/segmenter_cpu.py,sha256=tCY105rVr9_0RIq2618qnF1ueHRj7UtuK_nUBoAg-nY,1
|
|
|
35
35
|
dcnum/segm/segmenter_gpu.py,sha256=tL2X5BN0jKmhC7wgfG0hygd-6UpG1ZCVuKe5OP1qde0,2133
|
|
36
36
|
dcnum/segm/segmenter_manager_thread.py,sha256=2znDaKedSueomcU1pbHtFmVcGoHzp--sf494VgJF_Tk,5342
|
|
37
37
|
dcnum/write/__init__.py,sha256=Cpn3LqL18hh8OScUnGp_AnNfpWPpKW-oAJZH6ot7aRA,241
|
|
38
|
-
dcnum/write/deque_writer_thread.py,sha256=
|
|
38
|
+
dcnum/write/deque_writer_thread.py,sha256=KpJ6po8JPlM696MITN-bhNnWQcy9E-qlhg9g-uzoPZg,1710
|
|
39
39
|
dcnum/write/queue_collector_thread.py,sha256=YQ6pvKNmCDf1C6HVx6gOA-q-FBoI6nkhOo-tAVYnyag,11906
|
|
40
|
-
dcnum/write/writer.py,sha256=
|
|
41
|
-
dcnum-0.16.
|
|
42
|
-
dcnum-0.16.
|
|
43
|
-
dcnum-0.16.
|
|
44
|
-
dcnum-0.16.
|
|
45
|
-
dcnum-0.16.
|
|
40
|
+
dcnum/write/writer.py,sha256=QGYNda102f2_12YWXu5WEBEQaTXhNnuQ20g-Dej-cek,10535
|
|
41
|
+
dcnum-0.16.7.dist-info/LICENSE,sha256=YRChA1C8A2E-amJbudwMcbTCZy_HzmeY0hMIvduh1MM,1089
|
|
42
|
+
dcnum-0.16.7.dist-info/METADATA,sha256=-FkRf9AUrKMuhTWwUp4SQnkYOKZ4KK4s6inH0Q2rZ4Q,2194
|
|
43
|
+
dcnum-0.16.7.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
44
|
+
dcnum-0.16.7.dist-info/top_level.txt,sha256=Hmh38rgG_MFTVDpUDGuO2HWTSq80P585Het4COQzFTg,6
|
|
45
|
+
dcnum-0.16.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|