Commit 9d9b4eff authored by payno's avatar payno
Browse files

[h5_to_nx] set HDF5_USE_FILE_LOCKING environment variable to prevent corruption

parent bba086ac
Pipeline #31784 passed with stage
in 25 seconds
......@@ -134,6 +134,7 @@ def edf_to_nx(scan: EDFTomoScan, output_file: str, file_extension: str,
DARK_ACCUM_FACT = True
with h5py.File(fileout_h5, "w") as h5d:
os.environ["HDF5_USE_FILE_LOCKING"] = "TRUE"
proj_urls = scan.get_proj_urls(scan=scan.path)
for dark_to_find in file_keys.dark_names:
......@@ -536,6 +537,7 @@ def h5_to_nx(input_file_path: str, output_file: str, single_file:bool,
res = []
with h5py.File(input_file_path, 'r') as h5d:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
groups = list(h5d.keys())
groups.sort(key=float)
# step 1: deduce acquisitions
......@@ -606,6 +608,7 @@ def h5_to_nx(input_file_path: str, output_file: str, single_file:bool,
if single_file is False:
_logger.info('create link in %s' % output_file)
with h5py.File(output_file, 'a') as master_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "TRUE"
mf_entry = 'entry' + str(i_acquisition).zfill(4)
link_file = os.path.relpath(en_output_file, os.path.dirname(output_file))
master_file[mf_entry] = h5py.ExternalLink(link_file,
......@@ -635,6 +638,7 @@ def get_bliss_tomo_entries(input_file_path, scan_titles):
"""Util function. Used by tomwer for example"""
with h5py.File(input_file_path, 'r') as h5d:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
acquisitions = []
for group_name in h5d.keys():
......@@ -799,6 +803,7 @@ class _Acquisition:
# first retrieve the data and create some virtual dataset.
self._preprocess_frames(input_file_path)
with h5py.File(output_file, 'a') as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "TRUE"
entry = h5_file.require_group(data_path)
entry.attrs["NX_class"] = u"NXentry"
entry.attrs["definition"] = u"NXtomo"
......
Supports Markdown
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