Commit 4b3223cf authored by Wout De Nolf's avatar Wout De Nolf Committed by Matias Guijarro

[writer] bug in getting URIs from lima files

parent b364b0c0
Pipeline #20374 failed with stages
in 51 seconds
......@@ -1597,12 +1597,12 @@ def getDefault(node, signal=True):
return default
def getDefaultUri(filename, signal=True):
def getDefaultUri(filename, signal=True, **kwargs):
"""
:param str filename:
:returns str: full uri to default data
"""
with File(filename) as f:
with File(filename, **kwargs) as f:
path = getDefault(f, signal=signal)
if path:
return filename + "::" + path
......
......@@ -611,24 +611,33 @@ class DatasetProxy(BaseProxy):
return tpl
def _get_external_datasets(self):
lst = []
self.logger.info("Retrieving HDF5 URI's ...")
filenames = set(list(zip(*self._external_datasets))[0])
uridict = {}
mon = FileSizeMonitor()
for filename, i in self._external_datasets:
for filename in sorted(filenames):
mon.filename = filename
while True:
try:
uri = nexus.getDefaultUri(filename)
uri = nexus.getDefaultUri(filename, enable_file_locking=True)
except (RuntimeError, OSError):
if not mon.is_growing():
raise
else:
if uri:
lst.append((uri, i))
self.logger.debug("Got URI from file {}".format(filename))
uridict[filename] = uri
break
sleep()
return lst
else:
if not mon.is_growing():
raise RuntimeError(
"Cannot get URI from file {}".format(filename)
)
sleep(0.1)
return [(uridict[filename], i) for filename, i in self._external_datasets]
def _get_external_raw(self, createkwargs):
self.logger.info("Retrieving external URI's ...")
mon = FileSizeMonitor()
for filename, i in self._external_raw:
mon.filename = filename
......@@ -642,7 +651,7 @@ class DatasetProxy(BaseProxy):
raise
else:
break
sleep()
sleep(0.1)
@property
def is_external(self):
......
......@@ -272,6 +272,10 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
# for subscan in self._enabled_subscans:
# self._ensure_same_length(subscan)
self.logger.info("Link external data (VDS or raw)")
for node in self._nodes:
self._ensure_dataset_existance(node)
self.logger.info("Save detector metadata")
skip = set()
for node in self._nodes:
......@@ -281,10 +285,6 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
for subscan in self._enabled_subscans:
self._fetch_subscan_metadata(subscan)
self.logger.info("Link external data (VDS or raw)")
for node in self._nodes:
self._ensure_dataset_existance(node)
for subscan in self._enabled_subscans:
self._finalize_subscan(subscan)
self._mark_done(subscan)
......
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