ewoksdata 2.0.2__tar.gz → 2.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {ewoksdata-2.0.2/src/ewoksdata.egg-info → ewoksdata-2.0.3}/PKG-INFO +1 -1
  2. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/pyproject.toml +1 -1
  3. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/bliss.py +39 -8
  4. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/tests/test_data_bliss.py +4 -0
  5. {ewoksdata-2.0.2 → ewoksdata-2.0.3/src/ewoksdata.egg-info}/PKG-INFO +1 -1
  6. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/LICENSE.md +0 -0
  7. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/README.md +0 -0
  8. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/setup.cfg +0 -0
  9. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/__init__.py +0 -0
  10. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/__init__.py +0 -0
  11. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/blissdata/__init__.py +0 -0
  12. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/blissdata/blissdatav0.py +0 -0
  13. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/blissdata/blissdatav1.py +0 -0
  14. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/blissdata/blissdatav2.py +0 -0
  15. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/contextiterator.py +0 -0
  16. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/hdf5/__init__.py +0 -0
  17. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/hdf5/config.py +0 -0
  18. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/hdf5/dataset_writer.py +0 -0
  19. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/hdf5/types.py +0 -0
  20. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/nexus.py +0 -0
  21. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/url.py +0 -0
  22. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/data/utils.py +0 -0
  23. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/tests/__init__.py +0 -0
  24. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/tests/conftest.py +0 -0
  25. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/tests/data/__init__.py +0 -0
  26. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/tests/data/bliss_scans.py +0 -0
  27. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/tests/test_contextiterator.py +0 -0
  28. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/tests/test_data_hdf5.py +0 -0
  29. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/tests/test_data_nexus.py +0 -0
  30. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata/tests/test_dataset_writer.py +0 -0
  31. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata.egg-info/SOURCES.txt +0 -0
  32. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata.egg-info/dependency_links.txt +0 -0
  33. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata.egg-info/requires.txt +0 -0
  34. {ewoksdata-2.0.2 → ewoksdata-2.0.3}/src/ewoksdata.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ewoksdata
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Ewoks tasks for data access
5
5
  Author-email: ESRF <dau-pydev@esrf.fr>
6
6
  License: # MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ewoksdata"
7
- version = "2.0.2"
7
+ version = "2.0.3"
8
8
  authors = [{ name = "ESRF", email = "dau-pydev@esrf.fr" }]
9
9
  description = "Ewoks tasks for data access"
10
10
  readme = { file = "README.md", content-type = "text/markdown" }
@@ -41,23 +41,49 @@ logger = logging.getLogger(__name__)
41
41
 
42
42
  def get_data(
43
43
  data: Union[str, DataUrl, ArrayLike, Number],
44
+ retry_timeout: Optional[float] = None,
45
+ retry_period: Optional[float] = None,
44
46
  **hdf5_options: Any,
45
47
  ) -> Union[numpy.ndarray, Number, Sequence]:
46
48
  """
47
- Return a NumPy array or a scalar from *data*.
48
-
49
- :param data: Either a data-URL, an array-like object or a scalar number.
50
- :param **hdf5_options: Additional options forwarded to :class:`silx.io.h5py_utils.File`.
51
- :return: The requested data.
49
+ Retrieve numerical data from a data source and return it as a NumPy array or scalar.
50
+
51
+ This function accepts various data representations, including data URLs,
52
+ array-like objects, and scalar numbers. The data source may not be
53
+ immediately available so a retry mechanism is used.
54
+
55
+ :param data: The input data source. May be:
56
+ - A string or :class:`DataUrl` referencing a dataset (e.g., HDF5),
57
+ - An array-like object convertible to a NumPy array,
58
+ - A scalar numerical value.
59
+ :param retry_timeout: Maximum time in seconds to wait for the data to become
60
+ available. If ``None`` (default), no timeout is applied.
61
+ :param retry_period: Interval in seconds between availability checks when
62
+ retrying. If ``None`` (default), a period of 0.1 seconds is used.
63
+ :param hdf5_options: Additional keyword arguments forwarded to
64
+ :class:`silx.io.h5py_utils.File` when opening HDF5 resources.
65
+
66
+ :returns: The resolved data. Array-like inputs are returned as NumPy arrays,
67
+ while scalar inputs are returned as numbers.
68
+
69
+ :raises TimeoutError: If the data does not become available within ``retry_timeout``.
70
+ :raises ValueError: If the input type is unsupported or the data cannot be resolved.
52
71
  """
53
72
  if isinstance(data, (str, DataUrl)):
54
73
  data_url = url.as_dataurl(data)
55
74
  filename, h5path, idx = url.h5dataset_url_parse(data_url)
56
75
 
57
- _wait_for_file(filename, **hdf5_options)
76
+ _wait_for_file(filename, retry_timeout=retry_timeout, retry_period=retry_period)
58
77
 
59
- if h5py.is_hdf5(filename):
60
- return _get_hdf5_data(filename, h5path, idx=idx, **hdf5_options)
78
+ if _is_hdf5_filename(filename):
79
+ return _get_hdf5_data(
80
+ filename,
81
+ h5path,
82
+ idx=idx,
83
+ retry_timeout=retry_timeout,
84
+ retry_period=retry_period,
85
+ **hdf5_options,
86
+ )
61
87
 
62
88
  if not data_url.scheme():
63
89
  for scheme in ("fabio", "silx"):
@@ -97,6 +123,11 @@ def _wait_for_file(
97
123
  time.sleep(retry_period)
98
124
 
99
125
 
126
+ def _is_hdf5_filename(filename: str) -> bool:
127
+ _, ext = os.path.splitext(filename)
128
+ return ext in (".h5", ".hdf5", ".nx", ".nxs", ".nexus")
129
+
130
+
100
131
  def get_image(
101
132
  data: Union[str, DataUrl, ArrayLike, Number], **hdf5_options: Any
102
133
  ) -> numpy.ndarray:
@@ -31,6 +31,10 @@ def test_get_data_hdf5(tmpdir):
31
31
  with pytest.raises(TimeoutError):
32
32
  _ = bliss.get_data(f"{filename_non_existing}?path=/img", retry_timeout=0)
33
33
 
34
+ filename_non_existing = str(tmpdir / "data_non_existing.edf")
35
+ with pytest.raises(TimeoutError):
36
+ _ = bliss.get_data(filename_non_existing, retry_timeout=0)
37
+
34
38
 
35
39
  @pytest.mark.parametrize("lima_names", [(), ("p3",), ("p3", "p4")])
36
40
  @pytest.mark.parametrize("counter_names", [(), ("diode1",), ("diode1", "diode2")])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ewoksdata
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Ewoks tasks for data access
5
5
  Author-email: ESRF <dau-pydev@esrf.fr>
6
6
  License: # MIT License
File without changes
File without changes
File without changes