dcnum 0.16.6__py3-none-any.whl → 0.16.8__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 CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.16.6'
16
- __version_tuple__ = version_tuple = (0, 16, 6)
15
+ __version__ = version = '0.16.8'
16
+ __version_tuple__ = version_tuple = (0, 16, 8)
@@ -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
@@ -124,21 +124,23 @@ class DCNumJobRunner(threading.Thread):
124
124
  self.logger = logging.getLogger(f"dcnum.Runner-{self.pphash[:2]}")
125
125
 
126
126
  # Sanity checks
127
- for os_env in [
128
- "OMP_NUM_THREADS",
129
- "MKL_NUM_THREADS",
130
- "NUMEXPR_NUM_THREADS",
131
- "NUMBA_NUM_THREADS"]:
127
+ for os_env in ["MKL_NUM_THREADS", "NUMBA_NUM_THREADS",
128
+ "NUMEXPR_NUM_THREADS", "NUMPY_NUM_THREADS",
129
+ "OPENBLAS_NUM_THREADS", "OMP_NUM_THREADS",
130
+ "VECLIB_MAXIMUM_THREADS"]:
132
131
  # You should disable multithreading for all major tools that
133
132
  # use dcnum.logic. We don't want multithreading, because dcnum
134
133
  # uses linear code and relies on multiprocessing for
135
134
  # parallelization. This has to be done before importing numpy
136
135
  # or any other library affected. In your scripts, you can use:
137
136
  #
138
- # os.environ.setdefault("OMP_NUM_THREADS", "1")
139
137
  # os.environ.setdefault("MKL_NUM_THREADS", "1")
140
- # os.environ.setdefault("NUMEXPR_NUM_THREADS", "1")
141
138
  # os.environ.setdefault("NUMBA_NUM_THREADS", "1")
139
+ # os.environ.setdefault("NUMEXPR_NUM_THREADS", "1")
140
+ # os.environ.setdefault("NUMPY_NUM_THREADS", "1")
141
+ # os.environ.setdefault("OPENBLAS_NUM_THREADS", "1")
142
+ # os.environ.setdefault("OMP_NUM_THREADS", "1")
143
+ # os.environ.setdefault("VECLIB_MAXIMUM_THREADS", "1")
142
144
  #
143
145
  val_act = os.environ.get(os_env)
144
146
  if val_act != "1":
@@ -515,7 +517,7 @@ class DCNumJobRunner(threading.Thread):
515
517
  num_segmenters = 1
516
518
  num_extractors = max(1, num_extractors)
517
519
  num_segmenters = max(1, num_segmenters)
518
- self.job["segmenter_kwargs"]["num_workers"] = num_segmenters
520
+ self.job.kwargs["segmenter_kwargs"]["num_workers"] = num_segmenters
519
521
 
520
522
  slot_chunks = mp_spawn.Array("i", num_slots)
521
523
  slot_states = mp_spawn.Array("u", num_slots)
@@ -546,6 +548,7 @@ class DCNumJobRunner(threading.Thread):
546
548
  fe_kwargs=fe_kwargs,
547
549
  num_workers=num_extractors,
548
550
  labels_list=thr_segm.labels_list,
551
+ writer_dq=writer_dq,
549
552
  debug=self.job["debug"])
550
553
  thr_feat.start()
551
554
 
@@ -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 len(self.dq):
47
- feat, data = self.dq.popleft()
48
- self.writer.store_feature_chunk(feat=feat, data=data)
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 image data
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcnum
3
- Version: 0.16.6
3
+ Version: 0.16.8
4
4
  Summary: numerics toolbox for imaging deformability cytometry
5
5
  Author: Maximilian Schlögel, Paul Müller
6
6
  Maintainer-email: Paul Müller <dev@craban.de>
@@ -1,7 +1,7 @@
1
1
  dcnum/__init__.py,sha256=hcawIKS7utYiOyVhOAX9t7K3xYzP1b9862VV0b6qSrQ,74
2
- dcnum/_version.py,sha256=h39u2Mo-S3RRIMlrfW8TU54mTZkmYuu69tEf5q1_V18,413
2
+ dcnum/_version.py,sha256=9RDap9Epg0PWfAHpF1CbM0Nbp6dRrQKcwV8RmgVyzJs,413
3
3
  dcnum/feat/__init__.py,sha256=JqlgzOgDJhoTk8WVYcIiKTWq9EAM16_jGivzOtN6JGo,325
4
- dcnum/feat/event_extractor_manager_thread.py,sha256=re0McYaWv6h-unLj2B0OhfQtWs-prqIazC8vbDUDQ30,6480
4
+ dcnum/feat/event_extractor_manager_thread.py,sha256=Ocid_t1awH6pOmurCmKYkC51XsXB0-DoN3fzjFDgE4c,7129
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=a_qroJPyr-UV2M8EZTnYKP4kGnMETvFjBgVyShhVkuw,26692
22
+ dcnum/logic/ctrl.py,sha256=7m1HL_kO62d8Kt_o4gX3bhxbI4pwOhv3HWHRmbCaMp0,27022
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=R4x3p-HZUls3upCBX3vV1VqSdSmaiHdrAswMJj_tVpk,1643
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=Hr37OSDJGUpJJ4OufJHYYBanE26GiNwUPOMAt-5Yc2Y,10478
41
- dcnum-0.16.6.dist-info/LICENSE,sha256=YRChA1C8A2E-amJbudwMcbTCZy_HzmeY0hMIvduh1MM,1089
42
- dcnum-0.16.6.dist-info/METADATA,sha256=6f6l1RRqcNyxACqTQpg494d_Oxozd14iC29eO60-WfU,2194
43
- dcnum-0.16.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
44
- dcnum-0.16.6.dist-info/top_level.txt,sha256=Hmh38rgG_MFTVDpUDGuO2HWTSq80P585Het4COQzFTg,6
45
- dcnum-0.16.6.dist-info/RECORD,,
40
+ dcnum/write/writer.py,sha256=QGYNda102f2_12YWXu5WEBEQaTXhNnuQ20g-Dej-cek,10535
41
+ dcnum-0.16.8.dist-info/LICENSE,sha256=YRChA1C8A2E-amJbudwMcbTCZy_HzmeY0hMIvduh1MM,1089
42
+ dcnum-0.16.8.dist-info/METADATA,sha256=OwayeBlT5wdvffELr7znBmnKvlS52I7sdeP8bOB10lo,2194
43
+ dcnum-0.16.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
44
+ dcnum-0.16.8.dist-info/top_level.txt,sha256=Hmh38rgG_MFTVDpUDGuO2HWTSq80P585Het4COQzFTg,6
45
+ dcnum-0.16.8.dist-info/RECORD,,
File without changes