Commit 6c0147c8 authored by payno's avatar payno
Browse files

Merge branch 'fix_relpath' into '0.3'

Fix relpath

See merge request !32
parents e3a60a0f fae83788
Pipeline #36087 passed with stage
in 20 seconds
......@@ -804,10 +804,12 @@ class _Acquisition:
"""
_logger.info('write data of %s to %s' % (self.initialization_entry.name,
output_file + '::/' + data_path))
# in order to have relative links output_file and data_path should be
# relative
self.set_plugins(plugins)
# first retrieve the data and create some virtual dataset.
self._preprocess_frames(input_file_path)
self._preprocess_frames(input_file_path, output_file=output_file)
with HDF5File(output_file, 'a') as h5_file:
entry = h5_file.require_group(data_path)
entry.attrs["NX_class"] = u"NXentry"
......@@ -819,7 +821,7 @@ class _Acquisition:
self._write_sample(entry)
self._write_plugins_output(entry)
def _preprocess_frames(self, input_file_path):
def _preprocess_frames(self, input_file_path, output_file):
"""parse all frames of the different steps and retrieve data,
image_key..."""
# TODO: make sure those are ordered or use the 'scan_numbers' ?
......@@ -837,7 +839,15 @@ class _Acquisition:
_virtual_sources_len = []
# list of data virtual source for the virtual dataset
_acq_expo_time = []
# work on absolute path. The conversion to relative path and
# then to absolute path is a trick in case there is some 'mounted'
# directory exposed differently. Like '/mnt/multipath-shares/tmp_14_days'
input_file_path = os.path.abspath(os.path.relpath(input_file_path, os.getcwd()))
output_file = os.path.abspath(os.path.relpath(output_file, os.getcwd()))
input_file_path = os.path.realpath(input_file_path)
output_file = os.path.realpath(output_file)
for entry in self._registered_entries:
type_ = _get_entry_type(entry, self._scan_titles)
if type_ is AcquisitionStep.INITIALIZATION:
......@@ -906,7 +916,9 @@ class _Acquisition:
_image_key_control.extend([image_key_control.value] * n_frame)
_image_key.extend([image_key.value] * n_frame)
# create virtual source (getting ready for writing)
v_source = h5py.VirtualSource(input_file_path,
rel_input = os.path.relpath(input_file_path,
os.path.dirname(output_file))
v_source = h5py.VirtualSource(rel_input,
data_dataset.name, shape=shape)
_virtual_sources.append(v_source)
_virtual_sources_len.append(n_frame)
......
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