Commit ee14be01 authored by payno's avatar payno
Browse files

set `HDF5_USE_FILE_LOCKING` when read a file

parent 765872b2
Pipeline #31769 passed with stages
in 3 minutes and 19 seconds
......@@ -232,6 +232,7 @@ class HDF5TomoScan(TomoScanBase):
raise ValueError('given file path should be a file')
with h5py.File(file_path, 'r', swmr=True) as h5f:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
for root_node in h5f.keys():
node = h5f[root_node]
if HDF5TomoScan.node_is_nxtomo(node) is True:
......@@ -406,6 +407,7 @@ class HDF5TomoScan(TomoScanBase):
if self._rotation_angles is None:
self._check_hdf5scan_validity()
with h5py.File(self.master_file, 'r', swmr=True) as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
_rotation_angles = h5_file[self._entry][self._ROTATION_ANGLE_PATH][()]
# cast in float
self._rotation_angles = tuple([float(angle) for angle in _rotation_angles])
......@@ -416,6 +418,7 @@ class HDF5TomoScan(TomoScanBase):
if self._entry and self._image_keys is None:
self._check_hdf5scan_validity()
with h5py.File(self.master_file, 'r', swmr=True) as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
self._image_keys = h5_file[self._entry][self._IMG_KEY_PATH][()]
return self._image_keys
......@@ -424,6 +427,7 @@ class HDF5TomoScan(TomoScanBase):
if self._entry and self._image_keys_control is None:
self._check_hdf5scan_validity()
with h5py.File(self.master_file, 'r', swmr=True) as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
if self._IMG_KEY_CONTROL_PATH in h5_file[self._entry]:
self._image_keys_control = h5_file[self._entry][self._IMG_KEY_CONTROL_PATH][()]
else:
......@@ -497,6 +501,7 @@ class HDF5TomoScan(TomoScanBase):
def _get_x_y_pixel_values(self):
"""read x and y pixel values"""
with h5py.File(self.master_file, 'r', swmr=True) as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
x_pixel_dataset = h5_file[self._entry][self._X_PIXEL_SIZE_PATH]
_x_pixel_size = self._get_value(x_pixel_dataset, default_unit='meter')
y_pixel_dataset = h5_file[self._entry][self._Y_PIXEL_SIZE_PATH]
......@@ -505,6 +510,7 @@ class HDF5TomoScan(TomoScanBase):
def _get_x_y_magnified_pixel_values(self):
with h5py.File(self.master_file, 'r', swmr=True) as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
x_m_pixel_dataset = h5_file[self._entry][self._X_PIXEL_MAG_SIZE_PATH]
_x_m_pixel_size = self._get_value(x_m_pixel_dataset, default_unit='meter')
y_m_pixel_dataset = h5_file[self._entry][self._Y_PIXEL_MAG_SIZE_PATH]
......@@ -513,6 +519,7 @@ class HDF5TomoScan(TomoScanBase):
def _get_fov(self):
with h5py.File(self.master_file, 'r', swmr=True, libver='latest') as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
if self._FOV_PATH in h5_file[self._entry]:
fov = h5_file[self._entry][self._FOV_PATH][()]
return _FOV.from_value(fov)
......@@ -556,6 +563,7 @@ class HDF5TomoScan(TomoScanBase):
os.path.exists(self.master_file)):
self._check_hdf5scan_validity()
with h5py.File(self.master_file, 'r', swmr=True) as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
distance_dataset = h5_file[self._entry][self._DISTANCE_PATH]
self._distance = self._get_value(distance_dataset, default_unit='m')
return self._distance
......@@ -577,6 +585,7 @@ class HDF5TomoScan(TomoScanBase):
os.path.exists(self.master_file)):
self._check_hdf5scan_validity()
with h5py.File(self.master_file, 'r', swmr=True) as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
energy_dataset = h5_file[self._entry][self._ENERGY_PATH]
self._energy = self._get_value(energy_dataset, default_unit='keV')
return self._energy
......@@ -685,6 +694,7 @@ class HDF5TomoScan(TomoScanBase):
if self.entry is None:
raise ValueError('No entry provided')
with h5py.File(self.master_file, 'r', swmr=True) as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
if self._entry not in h5_file:
raise ValueError('Given entry %s is not in the master '
'file %s' % (self._entry, self.master_file))
......
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