Skip to content

Commit

Permalink
Merge pull request #994 from girder/nd2-dask-threads
Browse files Browse the repository at this point in the history
Don't use dask threads when using nd2 to fetch tiles
  • Loading branch information
manthey authored Nov 18, 2022
2 parents a87b813 + 4109fe1 commit d9ac2f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Improvements
- Better control dtype on multi sources ([#993](../../pull/993))
- Don't use dask threads when using nd2 to fetch tiles ([#994](../../pull/994))

### Bug Fixes
- Use open.read rather than download to access files in Girder ([#989](../../pull/989))
Expand Down
5 changes: 3 additions & 2 deletions sources/nd2/large_image_source_nd2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self, path, **kwargs):
raise TileSourceFileNotFoundError(self._largeImagePath) from None
raise TileSourceError('File cannot be opened via nd2reader.')
# We use dask to allow lazy reading of large images
self._nd2array = self._nd2.to_dask(copy=False)
self._nd2array = self._nd2.to_dask(copy=False, wrapper=False) # ##DWM::
arrayOrder = list(self._nd2.sizes)
# Reorder this so that it is XY (P), T, Z, C, Y, X, S (or at least end
# in Y, X[, S]).
Expand Down Expand Up @@ -260,7 +260,8 @@ def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False, **kwargs):
tileframe = tileframe[fp // fc]
fp = fp % fc
with self._tileLock:
tile = tileframe[y0:y1:step, x0:x1:step].compute().copy()
# Have dask use single-threaded since we are using a lock anyway.
tile = tileframe[y0:y1:step, x0:x1:step].compute(scheduler='single-threaded').copy()
return self._outputTile(tile, TILE_FORMAT_NUMPY, x, y, z,
pilImageAllowed, numpyAllowed, **kwargs)

Expand Down

0 comments on commit d9ac2f0

Please sign in to comment.