From 6a18f32b6d93abd38a869e8a6e93cdccb28e25d9 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 31 Dec 2024 09:58:53 -0500 Subject: [PATCH] Suppress a warning about nd2 files that we can't do anything about Specifically, the dask module probably duplicates the ND2File object and the deletes the object without explicitly closing it. --- CHANGELOG.md | 4 ++++ sources/nd2/large_image_source_nd2/__init__.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81dcdabe8..d80c27c60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ - Add more color palettes ([#1746](../../pull/1746)) - Improve the list of extensions the bioformats source reports ([#1748](../../pull/1748)) +### Changes + +- Suppress a warning about nd2 files that we can't do anything about ([#1749](../../pull/1749)) + ## 1.30.5 ### Improvements diff --git a/sources/nd2/large_image_source_nd2/__init__.py b/sources/nd2/large_image_source_nd2/__init__.py index 0434c5754..243e89ea7 100644 --- a/sources/nd2/large_image_source_nd2/__init__.py +++ b/sources/nd2/large_image_source_nd2/__init__.py @@ -17,6 +17,7 @@ import math import os import threading +import warnings from importlib.metadata import PackageNotFoundError from importlib.metadata import version as _importlib_version @@ -49,6 +50,9 @@ def _lazyImport(): except ImportError: msg = 'nd2 module not found.' raise TileSourceError(msg) + # the dask module emits a warning about an open handle even those we + # close file handles properly. Suppress them + warnings.filterwarnings('ignore', category=UserWarning, module='.*dask.*') def namedtupleToDict(obj):