Commit 8d138e66 authored by payno's avatar payno
Browse files

overwrite get_data

parent f4e71e86
Pipeline #34755 failed with stages
in 4 minutes
......@@ -40,7 +40,7 @@ from silx.io.url import DataUrl
from silx.utils.enum import Enum as _Enum
from tomoscan.utils import docstring
from tomoscan.io import HDF5File
from silx.io.utils import get_data
from tomoscan.esrf.utils import get_data
from ..unitsystem import metricsystem
from .utils import get_compacted_dataslices
import typing
......
......@@ -37,7 +37,7 @@ from tomoscan.esrf.mock import MockEDF
from tomoscan.esrf.edfscan import EDFTomoScan
from tomoscan.scanbase import TomoScanBase
from tomoscan.scanfactory import ScanFactory
from silx.io.utils import get_data
from tomoscan.esrf.utils import get_data
from silx.io.url import DataUrl
import collections
import json
......@@ -253,13 +253,7 @@ class TestOriDarksFlats(unittest.TestCase):
darks = self.scan.get_darks_url(prefix="darkend", scan_path=self.scan.path)
self.assertEqual(len(darks), 10)
# check one random url
url = DataUrl(
file_path=self._dark_file_name,
data_slice=[
4,
],
scheme="fabio",
)
url = DataUrl(file_path=self._dark_file_name, data_slice=[4], scheme="fabio")
self.assertTrue(url in darks.values())
......
......@@ -35,7 +35,7 @@ import tempfile
from tomoscan.test.utils import UtilsTest
from tomoscan.esrf.hdf5scan import HDF5TomoScan, ImageKey, Frame
from ...unitsystem import metricsystem
from silx.io.utils import get_data
from tomoscan.esrf.utils import get_data
import numpy
......
......@@ -33,6 +33,8 @@ import fabio
from silx.io.url import DataUrl
from typing import Union
import numpy
from silx.io.utils import get_data as silx_get_data
from tomoscan.io import HDF5File
def get_parameters_frm_par_or_info(file_: str) -> dict:
......@@ -86,13 +88,7 @@ def extract_urls_from_edf(
with fabio.open(file_) as fabio_file:
n_frames = fabio_file.nframes
for i_frame in range(n_frames):
res[index] = DataUrl(
scheme="fabio",
file_path=file_,
data_slice=[
i_frame,
],
)
res[index] = DataUrl(scheme="fabio", file_path=file_, data_slice=[i_frame])
index += 1
return res
......@@ -172,3 +168,9 @@ def get_compacted_dataslices(urls):
)
)
return res
def get_data(url):
"""Safe get data using the swmr mode"""
with HDF5File(url.file_path(), mode="r", swmr=True):
return silx_get_data(url)
......@@ -37,7 +37,7 @@ from collections import OrderedDict
from .unitsystem.metricsystem import MetricSystem
from silx.utils.enum import Enum as _Enum
from silx.io.url import DataUrl
from silx.io.utils import get_data
from tomoscan.esrf.utils import get_data
import silx.io.utils
from math import ceil
from .progress import Progress
......
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