Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use dask threads when using nd2 to fetch tiles #1260

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

### Changes
- Minor code changes based on suggestions from ruff linting ([#1257](../../pull/1257))
- Reduce pyvips log level ([#1258](../../pull/1258))
- Reduce pyvips log level ([#1259](../../pull/1259))
- Don't use dask threads when using nd2 to fetch tiles ([#1260](../../pull/1260))

### Bug Fixes
- Guard against ICC profiles that won't parse ([#1245](../../pull/1245))
Expand Down
6 changes: 2 additions & 4 deletions sources/nd2/large_image_source_nd2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ def __init__(self, path, **kwargs):

self._largeImagePath = str(self._getLargeImagePath())

self._pixelInfo = {}

_lazyImport()
try:
self._nd2 = nd2.ND2File(self._largeImagePath, validate_frames=True)
Expand Down Expand Up @@ -205,7 +203,7 @@ def _validateArrayAccess(self):
axisSize = self._nd2.sizes[axis]
check[axisidx] = axisSize - 1
try:
self._nd2array[tuple(check)].compute()
self._nd2array[tuple(check)].compute(scheduler='single-threaded')
if axis not in {'X', 'Y', 'S'}:
count *= axisSize
continue
Expand All @@ -218,7 +216,7 @@ def _validateArrayAccess(self):
nextval = (minval + maxval) // 2
check[axisidx] = nextval
try:
self._nd2array[tuple(check)].compute()
self._nd2array[tuple(check)].compute(scheduler='single-threaded')
minval = nextval
except Exception:
maxval = nextval
Expand Down
2 changes: 1 addition & 1 deletion sources/tiff/large_image_source_tiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False,
exception=e, **kwargs)

def _getDirFromCache(self, dirnum, subdir=None):
if not hasattr(self, '_directoryCache'):
if not hasattr(self, '_directoryCache') or not hasattr(self, '_directoryCacheMaxSize'):
self._directoryCache = {}
self._directoryCacheMaxSize = max(20, self.levels * (2 + (
self.metadata.get('IndexRange', {}).get('IndexC', 1))))
Expand Down