Commit 65898c57 authored by Pierre Paleo's avatar Pierre Paleo

Issue warning when using 'old' version of h5py/libhdf5

parent e9ef2241
Pipeline #37876 passed with stages
in 5 minutes and 38 seconds
__version__ = "2020.5.0-beta3"
__version__ = "2020.5.0-beta4"
__nabu_modules__ = [
"app",
"cuda",
......
......@@ -3,6 +3,7 @@ from ..resources.logger import LoggerOrPrint
from ..resources.utils import is_hdf5_extension
from ..utils import check_supported
from ..io.writer import Writers, NXProcessWriter
from ..io.utils import check_h5py_version # won't be necessary once h5py >= 3.0 required
#
# Decorators and callback mechanism
......@@ -97,6 +98,7 @@ class WriterConfigurator:
self._writer_exec_args.append(nx_info["process_name"])
self._writer_exec_kwargs["processing_index"] = nx_info["processing_index"]
self._writer_exec_kwargs["config"] = nx_info["config"]
check_h5py_version(self.logger)
else:
writer_kwargs["start_index"] = self.start_index
self.writer = writer_cls(*writer_args, **writer_kwargs)
......
import warnings
import numpy as np
from silx.io.url import DataUrl
from tomoscan.io import HDF5File
# won't be necessary once h5py >= 3.0 required
from h5py import version as h5py_version
from packaging.version import parse as parse_version
#
def get_compacted_dataslices(urls, subsampling=None):
"""
......@@ -128,3 +132,24 @@ def get_h5_str_value(dataset_ptr):
return data
else:
return bytes.decode(data)
# won't be necessary once h5py >= 3.0 required
def check_h5py_version(logger=None):
"""
(h5py, hdf5) < (3.0, 1.10.6) have many issues. For example:
- https://github.com/silx-kit/silx/issues/3277
- overwrite data using (2.10, 1.10.4) while the data was written with (3.0, 1.12)
"""
recommendations = [
("h5py", h5py_version.version, "3.0"),
("libhdf5", h5py_version.hdf5_version, "1.10.6")
]
for what, current_version, recommended_version in recommendations:
msg = str("You are using %s %s. Unexpected behaviors can be experienced. Bugs were fixed in more recent versions. Please consider upgrading to %s >= %s. The h5py wheels (.whl files) contain the hdf5 library (libhdf5), so you don't need administrator privileges or another python environment."
% (what, current_version, what, recommended_version)
)
if parse_version(current_version) < parse_version(recommended_version):
warnings.warn(msg)
if logger is not None:
logger.warning(msg)
......@@ -9,6 +9,8 @@ from silx.third_party.TiffIO import TiffIO
from .. import version
from ..misc.utils import rescale_data
from .config import export_dict_to_h5
from .utils import check_h5py_version # won't be necessary once h5py >= 3.0 required
try:
from glymur import Jp2k
__have_jp2k__ = True
......@@ -51,6 +53,7 @@ class NXProcessWriter(Writer):
self._set_entry(entry)
self._filemode = filemode
self.overwrite = overwrite
check_h5py_version()
def _set_entry(self, entry):
......
......@@ -58,7 +58,7 @@ def setup_package():
'pytest',
'numpy > 1.9.0',
'silx >= 0.12.0',
'distributed', # >= 2.10.0',
'distributed',
'dask_jobqueue',
'tomoscan >= 0.4.0',
'h5py',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment