Open johnduva opened 3 years ago
This is the full error:
Downloading: 100%|██████████| 1/1 [00:00<00:00, 7.74it/s]
Downloading: 44it [00:01, 27.36it/s]
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-42-94e94b5c1366> in <module>
1 # get image and center point
2 ngl_sess = NeuroglancerSession(mip = mip, url = dir, url_segments=dir_segments)
----> 3 img, bbox, vox = ngl_sess.pull_voxel(2, v_id, radius)
4 print(f"\n\nDownloaded volume is of shape {img.shape}, with total intensity {sum(sum(sum(img)))}.")
~/Desktop/Git/brainlit/brainlit/utils/session.py in pull_voxel(self, seg_id, v_id, radius)
210 shape = [radius] * 3
211 bounds = Bbox(np.subtract(seed[:3], shape), np.add(np.add(seed[3:], shape), 1))
--> 212 img = self.pull_bounds_img(bounds)
213 # img = self.cv.download(bounds, mip=self.mip)
214 vox_in_img = voxel - np.array(bounds.to_list()[:3])
~/Desktop/Git/brainlit/brainlit/utils/session.py in pull_bounds_img(self, bounds)
314 check_iterable_type(bounds, (int, np.integer))
315 check_iterable_nonnegative(bounds)
--> 316 img = self.cv.download(Bbox(bounds[:3], bounds[3:]), mip=self.mip)
317 return np.squeeze(np.array(img))
318
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/frontends/precomputed.py in download(self, bbox, mip, parallel, segids, preserve_zeros)
555 parallel = self.parallel
556
--> 557 img = self.image.download(bbox, mip, parallel=parallel)
558
559 if segids is None:
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/datasource/precomputed/image/__init__.py in download(self, bbox, mip, parallel, location, retain, use_shared_memory, use_file, order)
123 )
124 else:
--> 125 return rx.download(
126 bbox, mip,
127 meta=self.meta,
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/datasource/precomputed/image/rx.py in download(requested_bbox, mip, meta, cache, fill_missing, progress, parallel, location, retain, use_shared_memory, use_file, compress, order, green)
133 shade(renderbuffer, requested_bbox, img3d, bbox)
134
--> 135 download_chunks_threaded(
136 meta, cache, mip, cloudpaths,
137 fn=process, fill_missing=fill_missing,
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/datasource/precomputed/image/rx.py in download_chunks_threaded(meta, cache, mip, cloudpaths, fn, fill_missing, progress, compress_cache, green)
284 downloads = itertools.chain( local_downloads, remote_downloads )
285
--> 286 schedule_jobs(
287 fns=downloads,
288 concurrency=DEFAULT_THREADS,
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/scheduler.py in schedule_jobs(fns, concurrency, progress, total, green)
70 return schedule_green_jobs(fns, concurrency, progress, total)
71
---> 72 return schedule_threaded_jobs(fns, concurrency, progress, total)
73
74
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/scheduler.py in schedule_threaded_jobs(fns, concurrency, progress, total)
17 with ThreadedQueue(n_threads=concurrency, progress=progress) as tq:
18 for fn in fns:
---> 19 tq.put(wrap(fn))
20
21 def schedule_green_jobs(
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/threaded_queue.py in __exit__(self, exception_type, exception_value, traceback)
256 def __exit__(self, exception_type, exception_value, traceback):
257 self.wait(progress=self.with_progress)
--> 258 self.kill_threads()
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/threaded_queue.py in kill_threads(self)
96 """Kill all threads."""
97 self._terminate.set()
---> 98 while self.are_threads_alive():
99 time.sleep(0.001)
100 self._threads = ()
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/threaded_queue.py in are_threads_alive(self)
91 def are_threads_alive(self):
92 """Returns: boolean indicating if any threads are alive"""
---> 93 return any(map(lambda t: t.isAlive(), self._threads))
94
95 def kill_threads(self):
~/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/cloudvolume/threaded_queue.py in <lambda>(t)
91 def are_threads_alive(self):
92 """Returns: boolean indicating if any threads are alive"""
---> 93 return any(map(lambda t: t.isAlive(), self._threads))
94
95 def kill_threads(self):
AttributeError: 'Thread' object has no attribute 'isAlive'
@bvarjavand I solved this: turns out threading.Thread
's method isAlive()
was renamed to is_alive()
since Python 3.9.0. I've updated my own version of threaded_queue.py
but I'm not sure how you want to handle it because obviously not everyone is using Python 3.9. I'll keep this Issue open for now as a reminder in case you want to update the code.
Can we use sys.version or sys.version_info to do that? https://docs.python.org/3/library/sys.html#sys.version
That's what I would recommend.
This seems to have been fixed in https://github.com/seung-lab/cloud-volume/commit/9e7195e410d201c98a03e3335874c8650143ec9e
@tirkarthi is it strange that they don't check what the user's version is though? wouldn't that fail for someone who has <3.9?
Stale issue message
The command:
img, bbox, vox = ngl_sess.pull_voxel(2, v_id, radius)
generates the error:>>AttributeError: 'Thread' object has no attribute 'isAlive'
This has error has never occurred until this week. Bijan hasn't seen this either but suggested to try using cloudvolume directly, or to modify the existing
pull_voxel()
code. I'm not sure exactly how this should be done and I'm wondering why this would be needed all of a sudden when we've never needed it before.