blissdata 2.2.0__tar.gz → 2.3.0__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 (104) hide show
  1. {blissdata-2.2.0/src/blissdata.egg-info → blissdata-2.3.0}/PKG-INFO +2 -3
  2. {blissdata-2.2.0 → blissdata-2.3.0}/pyproject.toml +2 -6
  3. blissdata-2.3.0/src/blissdata/__init__.py +4 -0
  4. blissdata-2.3.0/src/blissdata/deprecation.py +12 -0
  5. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/h5_scan_map.py +1 -1
  6. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/redis_hdf5.py +2 -2
  7. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/lima/client.py +2 -5
  8. blissdata-2.3.0/src/blissdata/redis_engine/encoding/json.py +11 -0
  9. blissdata-2.3.0/src/blissdata/redis_engine/encoding/numeric.py +11 -0
  10. blissdata-2.3.0/src/blissdata/redis_engine/event_stream.py +11 -0
  11. blissdata-2.3.0/src/blissdata/redis_engine/exceptions.py +12 -0
  12. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/redis_engine/memory_tracker.py +2 -4
  13. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/redis_engine/scan.py +4 -6
  14. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/redis_engine/store.py +1 -1
  15. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/scan.py +5 -1
  16. blissdata-2.2.0/src/blissdata/streams/base.py → blissdata-2.3.0/src/blissdata/streams/__init__.py +12 -157
  17. blissdata-2.3.0/src/blissdata/streams/base.py +39 -0
  18. blissdata-2.3.0/src/blissdata/streams/default.py +160 -0
  19. {blissdata-2.2.0/src/blissdata/redis_engine → blissdata-2.3.0/src/blissdata/streams}/event_stream.py +1 -1
  20. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/streams/hdf5_fallback/stream.py +3 -2
  21. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/streams/lima/stream.py +16 -6
  22. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/streams/scan_sequence/stream.py +3 -3
  23. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/conftest.py +1 -1
  24. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/h5api/test_redis_files.py +1 -1
  25. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/redis_engine/test_cursor.py +4 -3
  26. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/redis_engine/test_memory_tracker.py +2 -2
  27. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/redis_engine/test_scan.py +3 -6
  28. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/redis_engine/test_search.py +1 -1
  29. {blissdata-2.2.0/src/blissdata/tests/redis_engine → blissdata-2.3.0/src/blissdata/tests/streams}/encoding/test_json.py +1 -1
  30. {blissdata-2.2.0/src/blissdata/tests/redis_engine → blissdata-2.3.0/src/blissdata/tests/streams}/encoding/test_numeric.py +1 -1
  31. {blissdata-2.2.0/src/blissdata/tests/plugin_streams → blissdata-2.3.0/src/blissdata/tests/streams/plugins}/test_file_backed_stream.py +4 -4
  32. {blissdata-2.2.0/src/blissdata/tests/plugin_streams → blissdata-2.3.0/src/blissdata/tests/streams/plugins}/test_plugin_base.py +3 -4
  33. {blissdata-2.2.0/src/blissdata/tests/redis_engine → blissdata-2.3.0/src/blissdata/tests/streams}/test_event_stream.py +3 -3
  34. {blissdata-2.2.0 → blissdata-2.3.0/src/blissdata.egg-info}/PKG-INFO +2 -3
  35. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata.egg-info/SOURCES.txt +15 -11
  36. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata.egg-info/entry_points.txt +0 -1
  37. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata.egg-info/requires.txt +1 -2
  38. blissdata-2.2.0/src/blissdata/streams/lima2/__init__.py +0 -4
  39. blissdata-2.2.0/src/blissdata/streams/lima2/stream.py +0 -266
  40. blissdata-2.2.0/src/blissdata/tests/plugin_streams/test_lima2_stream.py +0 -168
  41. blissdata-2.2.0/src/blissdata/tests/redis_engine/encoding/__init__.py +0 -0
  42. {blissdata-2.2.0 → blissdata-2.3.0}/LICENSE +0 -0
  43. {blissdata-2.2.0 → blissdata-2.3.0}/README.md +0 -0
  44. {blissdata-2.2.0 → blissdata-2.3.0}/setup.cfg +0 -0
  45. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/beacon/__init__.py +0 -0
  46. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/beacon/_base.py +0 -0
  47. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/beacon/_utils.py +0 -0
  48. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/beacon/config.py +0 -0
  49. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/beacon/data.py +0 -0
  50. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/beacon/files.py +0 -0
  51. {blissdata-2.2.0/src/blissdata/redis_engine → blissdata-2.3.0/src/blissdata}/exceptions.py +0 -0
  52. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/__init__.py +0 -0
  53. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/abstract.py +0 -0
  54. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/dynamic_hdf5.py +0 -0
  55. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/file_arguments.py +0 -0
  56. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/static_hdf5.py +0 -0
  57. {blissdata-2.2.0/src/blissdata → blissdata-2.3.0/src/blissdata/h5api/utils}/__init__.py +0 -0
  58. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/utils/bliss.py +0 -0
  59. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/utils/hdf5.py +0 -0
  60. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/utils/hdf5_retry.py +0 -0
  61. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/utils/lima.py +0 -0
  62. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5api/utils/types.py +0 -0
  63. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5map/__init__.py +0 -0
  64. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5map/data_items.py +0 -0
  65. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/h5map/hdf5_items.py +0 -0
  66. {blissdata-2.2.0/src/blissdata/h5api/utils → blissdata-2.3.0/src/blissdata/lima}/__init__.py +0 -0
  67. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/lima/image_utils.py +0 -0
  68. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/py.typed +0 -0
  69. {blissdata-2.2.0/src/blissdata/lima → blissdata-2.3.0/src/blissdata/redis_engine}/__init__.py +0 -0
  70. {blissdata-2.2.0/src/blissdata/redis_engine → blissdata-2.3.0/src/blissdata/redis_engine/encoding}/__init__.py +0 -0
  71. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/redis_engine/identities.py +0 -0
  72. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/schemas/__init__.py +0 -0
  73. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/schemas/scan_info.py +0 -0
  74. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/schemas/scan_info_display.py +0 -0
  75. {blissdata-2.2.0/src/blissdata/redis_engine → blissdata-2.3.0/src/blissdata/streams}/encoding/__init__.py +0 -0
  76. {blissdata-2.2.0/src/blissdata/redis_engine → blissdata-2.3.0/src/blissdata/streams}/encoding/json.py +0 -0
  77. {blissdata-2.2.0/src/blissdata/redis_engine → blissdata-2.3.0/src/blissdata/streams}/encoding/numeric.py +0 -0
  78. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/streams/hdf5_fallback/__init__.py +0 -0
  79. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/streams/lima/__init__.py +0 -0
  80. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/streams/scan_sequence/__init__.py +0 -0
  81. {blissdata-2.2.0/src/blissdata/redis_engine → blissdata-2.3.0/src/blissdata/streams}/sink.py +0 -0
  82. {blissdata-2.2.0/src/blissdata/streams → blissdata-2.3.0/src/blissdata/tests}/__init__.py +0 -0
  83. {blissdata-2.2.0/src/blissdata/tests → blissdata-2.3.0/src/blissdata/tests/beacon}/__init__.py +0 -0
  84. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/beacon/test_config.py +0 -0
  85. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/beacon/test_data.py +0 -0
  86. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/beacon/test_files.py +0 -0
  87. {blissdata-2.2.0/src/blissdata/tests/beacon → blissdata-2.3.0/src/blissdata/tests/h5api}/__init__.py +0 -0
  88. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/h5api/scanner.py +0 -0
  89. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/h5api/test_dynamic_files.py +0 -0
  90. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/h5api/test_h5api_lima_utils.py +0 -0
  91. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/h5api/test_hdf5_handlers.py +0 -0
  92. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/h5api/test_static_files.py +0 -0
  93. {blissdata-2.2.0/src/blissdata/tests/h5api → blissdata-2.3.0/src/blissdata/tests/h5map}/__init__.py +0 -0
  94. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/h5map/test_data_items.py +0 -0
  95. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/h5map/test_hdf5_items.py +0 -0
  96. {blissdata-2.2.0/src/blissdata/tests/h5map → blissdata-2.3.0/src/blissdata/tests/lima}/__init__.py +0 -0
  97. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/lima/test_image_utils.py +0 -0
  98. {blissdata-2.2.0/src/blissdata/tests/lima → blissdata-2.3.0/src/blissdata/tests/redis_engine}/__init__.py +0 -0
  99. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/redis_engine/conftest.py +0 -0
  100. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata/tests/redis_engine/utils.py +0 -0
  101. {blissdata-2.2.0/src/blissdata/tests/plugin_streams → blissdata-2.3.0/src/blissdata/tests/streams/encoding}/__init__.py +0 -0
  102. {blissdata-2.2.0/src/blissdata/tests/redis_engine → blissdata-2.3.0/src/blissdata/tests/streams/plugins}/__init__.py +0 -0
  103. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata.egg-info/dependency_links.txt +0 -0
  104. {blissdata-2.2.0 → blissdata-2.3.0}/src/blissdata.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blissdata
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Bliss data streaming client
5
5
  Maintainer: BCU (ESRF)
6
6
  License-Expression: LGPL-3.0-or-later
@@ -26,8 +26,7 @@ Requires-Dist: silx>=1.1.0
26
26
  Provides-Extra: tango
27
27
  Requires-Dist: pytango>=9.3.1; extra == "tango"
28
28
  Provides-Extra: lima2
29
- Requires-Dist: blissdata[tango]; extra == "lima2"
30
- Requires-Dist: lima2-client~=4.0; extra == "lima2"
29
+ Requires-Dist: blissdata-lima2>=2.0; extra == "lima2"
31
30
  Provides-Extra: test
32
31
  Requires-Dist: gevent>=20.9.0; extra == "test"
33
32
  Requires-Dist: pytest>=7; extra == "test"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "blissdata"
3
- version = "2.2.0"
3
+ version = "2.3.0"
4
4
  description = "Bliss data streaming client"
5
5
  readme = "README.md"
6
6
  license = "LGPL-3.0-or-later"
@@ -32,10 +32,7 @@ Changes = "https://gitlab.esrf.fr/bliss/blissdata/-/blob/master/CHANGELOG.md"
32
32
 
33
33
  [project.optional-dependencies]
34
34
  tango = ["pytango>=9.3.1"]
35
- lima2 = [
36
- "blissdata[tango]",
37
- "lima2-client~=4.0"
38
- ]
35
+ lima2 = ["blissdata-lima2>=2.0"]
39
36
  test = [
40
37
  "gevent>=20.9.0",
41
38
  "pytest>=7",
@@ -62,7 +59,6 @@ memory_tracker = "blissdata.redis_engine.memory_tracker:cli"
62
59
  hdf5_fallback = "blissdata.streams.hdf5_fallback"
63
60
  scan_sequence = "blissdata.streams.scan_sequence"
64
61
  lima = "blissdata.streams.lima"
65
- lima2 = "blissdata.streams.lima2"
66
62
 
67
63
  [build-system]
68
64
  requires = ["setuptools"]
@@ -0,0 +1,4 @@
1
+ from .redis_engine.store import DataStore # noqa F401
2
+ from .redis_engine.scan import Scan, ScanState # noqa F401
3
+
4
+ __all__ = ["DataStore", "Scan", "ScanState"]
@@ -0,0 +1,12 @@
1
+ from warnings import warn
2
+
3
+
4
+ def warn_deprecated(old_name, new_name, removal_version=None):
5
+ msg = f"'{old_name}' is deprecated, use '{new_name}' instead."
6
+ if removal_version:
7
+ msg += f" It will be removed in version {removal_version}."
8
+ warn(
9
+ msg,
10
+ FutureWarning,
11
+ stacklevel=3,
12
+ )
@@ -2,7 +2,7 @@ import time
2
2
  import logging
3
3
  from collections.abc import Mapping
4
4
  from pathlib import PurePosixPath as Path
5
- from blissdata.redis_engine.scan import ScanState
5
+ from blissdata import ScanState
6
6
  from blissdata.h5map import HDF5ItemType, Group
7
7
 
8
8
  _logger = logging.getLogger(__name__)
@@ -7,9 +7,9 @@ from abc import ABC, abstractmethod
7
7
  from pathlib import PurePosixPath as Path
8
8
 
9
9
  import blissdata.h5map as h5m
10
+ from blissdata import DataStore
10
11
  from blissdata.beacon.data import BeaconData
11
- from blissdata.redis_engine.store import DataStore
12
- from blissdata.redis_engine.exceptions import EndOfStream, IndexNotYetThereError
12
+ from blissdata.exceptions import EndOfStream, IndexNotYetThereError
13
13
  from blissdata.h5api import abstract
14
14
  from blissdata.h5api.h5_scan_map import H5ScanMap
15
15
 
@@ -5,16 +5,13 @@
5
5
  # Copyright (c) Beamline Control Unit, ESRF
6
6
  # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
7
  import math
8
+ import logging
8
9
  import numpy as np
9
10
  from packaging.version import Version
10
11
  from functools import cached_property
11
- import logging
12
12
  from dataclasses import dataclass
13
13
 
14
- from blissdata.redis_engine.exceptions import (
15
- IndexNoMoreThereError,
16
- IndexNotYetThereError,
17
- )
14
+ from blissdata.exceptions import IndexNoMoreThereError, IndexNotYetThereError
18
15
  from . import image_utils
19
16
 
20
17
  try:
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # This file is part of the bliss project
4
+ #
5
+ # Copyright (c) Beamline Control Unit, ESRF
6
+ # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
+ from blissdata.deprecation import warn_deprecated
8
+
9
+ warn_deprecated(__name__, "blissdata.streams.encoding.json", "3")
10
+
11
+ from blissdata.streams.encoding.json import JsonStreamEncoder # noqa F401, E402
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # This file is part of the bliss project
4
+ #
5
+ # Copyright (c) Beamline Control Unit, ESRF
6
+ # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
+ from blissdata.deprecation import warn_deprecated
8
+
9
+ warn_deprecated(__name__, "blissdata.streams.encoding.numeric", "3")
10
+
11
+ from blissdata.streams.encoding.numeric import NumericStreamEncoder # noqa F401, E402
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # This file is part of the bliss project
4
+ #
5
+ # Copyright (c) Beamline Control Unit, ESRF
6
+ # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
+ from blissdata.deprecation import warn_deprecated
8
+
9
+ warn_deprecated(__name__, "blissdata.streams.event_stream", "3")
10
+
11
+ from blissdata.streams.event_stream import EventStream # noqa F401, E402
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # This file is part of the bliss project
4
+ #
5
+ # Copyright (c) Beamline Control Unit, ESRF
6
+ # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
+
8
+ from blissdata.deprecation import warn_deprecated
9
+
10
+ warn_deprecated(__name__, "blissdata.exceptions", "3")
11
+
12
+ from blissdata.exceptions import * # noqa F401, E402
@@ -13,10 +13,8 @@ import redis
13
13
  from datetime import timedelta
14
14
  from dataclasses import dataclass
15
15
 
16
- from .store import DataStore
17
- from .scan import Scan
18
- from .scan import ScanState
19
- from .exceptions import NoScanAvailable, ScanNotFoundError, ScanLoadError
16
+ from blissdata import DataStore, Scan, ScanState
17
+ from blissdata.exceptions import NoScanAvailable, ScanNotFoundError, ScanLoadError
20
18
 
21
19
 
22
20
  memory_tracking_stream = "_MEMORY_TRACKING_"
@@ -11,21 +11,19 @@ import math
11
11
  import logging
12
12
  import numpy as np
13
13
  from functools import wraps
14
-
15
14
  from pydantic import ValidationError
16
15
  from importlib.metadata import entry_points
17
16
 
18
- from .event_stream import EventStream
19
- from .exceptions import (
17
+ from blissdata.streams.event_stream import EventStream
18
+ from blissdata.exceptions import (
20
19
  UnauthorizeStateTransition,
21
20
  ScanNotFoundError,
22
21
  ScanValidationError,
23
22
  NoWritePermission,
24
23
  )
25
- from blissdata.streams.base import (
26
- BaseStream,
24
+ from blissdata.streams import BaseStream, StreamDefinition
25
+ from blissdata.streams.default import (
27
26
  Stream,
28
- StreamDefinition,
29
27
  BrokenStream,
30
28
  BrokenPluginStream,
31
29
  MissingPluginStream,
@@ -13,8 +13,8 @@ from redis.commands.search.query import Query
13
13
  from redis.commands.search.querystring import querystring, tags
14
14
  from redis_om import HashModel, JsonModel, Migrator
15
15
 
16
+ from blissdata.exceptions import NoScanAvailable, ScanNotFoundError
16
17
  from .scan import Scan, scan_creation_stream, ScanState
17
- from .exceptions import NoScanAvailable, ScanNotFoundError
18
18
  from .identities import ESRFIdentityModel
19
19
 
20
20
  _PROTOCOL_KEY = "_PROTOCOL_VERSION_"
@@ -4,4 +4,8 @@
4
4
  #
5
5
  # Copyright (c) Beamline Control Unit, ESRF
6
6
  # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
- from .redis_engine.scan import Scan # noqa: F401
7
+ from .deprecation import warn_deprecated
8
+
9
+ warn_deprecated(__name__, "blissdata", "3")
10
+
11
+ from . import Scan # noqa: F401, E402
@@ -4,21 +4,21 @@
4
4
  #
5
5
  # Copyright (c) Beamline Control Unit, ESRF
6
6
  # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
- import numpy as np
8
7
  from abc import ABC, abstractmethod
9
8
  from collections.abc import Mapping, Sequence
10
9
  from dataclasses import dataclass
11
- from blissdata.redis_engine.event_stream import EventStream
12
- from blissdata.redis_engine.exceptions import (
13
- EndOfStream,
14
- IndexNoMoreThereError,
15
- UnknownEncodingError,
16
- MissingPluginException,
17
- EmptyViewException,
18
- )
19
- from blissdata.redis_engine.encoding import StreamEncoder
20
- from blissdata.redis_engine.encoding.numeric import NumericStreamEncoder
21
- from blissdata.redis_engine.encoding.json import JsonStreamEncoder
10
+ from blissdata.exceptions import EndOfStream, EmptyViewException
11
+ from .encoding import StreamEncoder
12
+ from .event_stream import EventStream
13
+
14
+ __all__ = [
15
+ "BaseStream",
16
+ "BaseView",
17
+ "Cursor",
18
+ "CursorGroup",
19
+ "EventRange",
20
+ "StreamDefinition",
21
+ ]
22
22
 
23
23
 
24
24
  @dataclass(slots=True)
@@ -174,151 +174,6 @@ class BaseView(ABC):
174
174
  pass
175
175
 
176
176
 
177
- class View(BaseView):
178
- def __init__(self, event_range: EventRange):
179
- self._events = event_range
180
-
181
- @property
182
- def index(self) -> int:
183
- return self._events.index
184
-
185
- def __len__(self) -> int:
186
- return len(self._events)
187
-
188
- def __iter__(self):
189
- yield from self.get_data()
190
-
191
- def get_data(self, start=None, stop=None):
192
- trimmed_range = range(len(self))[start:stop]
193
- offset = self._events.nb_expired
194
- data_start = trimmed_range.start - offset
195
- data_stop = trimmed_range.stop - offset
196
- if data_start < 0:
197
- raise IndexNoMoreThereError
198
- else:
199
- return self._events.data[data_start:data_stop]
200
-
201
-
202
- class Stream(BaseStream):
203
- def __init__(self, event_stream):
204
- super().__init__(event_stream)
205
- if event_stream.encoding["type"] == "numeric":
206
- self._kind = "array"
207
- elif event_stream.encoding["type"] == "json":
208
- self._kind = "json"
209
- else:
210
- raise UnknownEncodingError(
211
- f"Unknow stream encoding {event_stream.encoding}"
212
- )
213
-
214
- @staticmethod
215
- def make_definition(name, dtype, shape=None, info={}) -> StreamDefinition:
216
- if dtype == "json":
217
- if shape is None:
218
- return StreamDefinition(name, info, JsonStreamEncoder())
219
- else:
220
- raise ValueError("JSON stream cannot have shape")
221
- else:
222
- if shape is None:
223
- shape = ()
224
- info = info.copy()
225
- info["dtype"] = np.dtype(dtype).name
226
- info["shape"] = shape
227
- return StreamDefinition(name, info, NumericStreamEncoder(dtype, shape))
228
-
229
- @property
230
- def kind(self):
231
- return self._kind
232
-
233
- @property
234
- def plugin(self):
235
- None
236
-
237
- @property
238
- def dtype(self):
239
- return self.event_stream.dtype
240
-
241
- @property
242
- def shape(self):
243
- return self.event_stream.shape
244
-
245
- def __len__(self):
246
- return len(self._event_stream)
247
-
248
- def __getitem__(self, key):
249
- return self._event_stream[key]
250
-
251
- def _need_last_only(self, last_only):
252
- return last_only
253
-
254
- def _build_view_from_events(self, index, events: EventRange, last_only):
255
- # NOTE event_range is never empty
256
- return View(events)
257
-
258
-
259
- class BrokenStream(BaseStream):
260
- def __init__(self, event_stream, plugin_name, exception, kind):
261
- self._event_stream = event_stream
262
- self._plugin_name = plugin_name
263
- self._exception = exception
264
- self._kind = kind
265
-
266
- @property
267
- def kind(self):
268
- self._kind
269
-
270
- @staticmethod
271
- def make_definition(*args, **kwargs) -> StreamDefinition:
272
- raise NotImplementedError
273
-
274
- @property
275
- def plugin(self):
276
- return self._plugin_name
277
-
278
- @property
279
- def dtype(self):
280
- raise self._exception
281
-
282
- @property
283
- def shape(self):
284
- raise self._exception
285
-
286
- def __len__(self):
287
- raise self._exception
288
-
289
- def __getitem__(self, key):
290
- raise self._exception
291
-
292
- def _need_last_only(self, last_only):
293
- raise self._exception
294
-
295
- def _build_view_from_events(
296
- self, hl_index: int, events: EventRange, last_only: bool
297
- ):
298
- raise self._exception
299
-
300
-
301
- class BrokenPluginStream(BrokenStream):
302
- """A stream class instanciated in place of a plugin, if it can't be
303
- instantiated. A warning is issued, but the scan object is not affected,
304
- ensuring memory tracker robustness against plugins."""
305
-
306
- def __init__(self, event_stream, plugin_name, exception):
307
- super().__init__(event_stream, plugin_name, exception, "broken_plugin")
308
-
309
-
310
- class MissingPluginStream(BrokenStream):
311
- """A stream class instanciated in place of a plugin if not installed."""
312
-
313
- def __init__(self, event_stream, plugin_name):
314
- super().__init__(
315
- event_stream,
316
- plugin_name,
317
- MissingPluginException(event_stream.name, plugin_name),
318
- "missing_plugin",
319
- )
320
-
321
-
322
177
  class Cursor:
323
178
  def __init__(self, stream):
324
179
  # low level stream (multiplexable events from redis)
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # This file is part of the bliss project
4
+ #
5
+ # Copyright (c) Beamline Control Unit, ESRF
6
+ # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
+ from . import (
8
+ BaseStream,
9
+ BaseView,
10
+ Cursor,
11
+ CursorGroup,
12
+ EventRange,
13
+ StreamDefinition,
14
+ )
15
+ from .default import (
16
+ View,
17
+ Stream,
18
+ BrokenStream,
19
+ BrokenPluginStream,
20
+ MissingPluginStream,
21
+ )
22
+
23
+ from blissdata.deprecation import warn_deprecated
24
+
25
+ warn_deprecated(__name__, "blissdata.streams' and 'blissdata.streams.default", "3")
26
+
27
+ __all__ = [
28
+ "BaseStream",
29
+ "BaseView",
30
+ "Cursor",
31
+ "CursorGroup",
32
+ "EventRange",
33
+ "StreamDefinition",
34
+ "View",
35
+ "Stream",
36
+ "BrokenStream",
37
+ "BrokenPluginStream",
38
+ "MissingPluginStream",
39
+ ]
@@ -0,0 +1,160 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # This file is part of the bliss project
4
+ #
5
+ # Copyright (c) Beamline Control Unit, ESRF
6
+ # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
+ import numpy as np
8
+ from blissdata.exceptions import (
9
+ IndexNoMoreThereError,
10
+ UnknownEncodingError,
11
+ MissingPluginException,
12
+ )
13
+ from . import EventRange, StreamDefinition, BaseStream, BaseView
14
+ from .encoding.numeric import NumericStreamEncoder
15
+ from .encoding.json import JsonStreamEncoder
16
+
17
+
18
+ class View(BaseView):
19
+ def __init__(self, event_range: EventRange):
20
+ self._events = event_range
21
+
22
+ @property
23
+ def index(self) -> int:
24
+ return self._events.index
25
+
26
+ def __len__(self) -> int:
27
+ return len(self._events)
28
+
29
+ def __iter__(self):
30
+ yield from self.get_data()
31
+
32
+ def get_data(self, start=None, stop=None):
33
+ trimmed_range = range(len(self))[start:stop]
34
+ offset = self._events.nb_expired
35
+ data_start = trimmed_range.start - offset
36
+ data_stop = trimmed_range.stop - offset
37
+ if data_start < 0:
38
+ raise IndexNoMoreThereError
39
+ else:
40
+ return self._events.data[data_start:data_stop]
41
+
42
+
43
+ class Stream(BaseStream):
44
+ def __init__(self, event_stream):
45
+ super().__init__(event_stream)
46
+ if event_stream.encoding["type"] == "numeric":
47
+ self._kind = "array"
48
+ elif event_stream.encoding["type"] == "json":
49
+ self._kind = "json"
50
+ else:
51
+ raise UnknownEncodingError(
52
+ f"Unknow stream encoding {event_stream.encoding}"
53
+ )
54
+
55
+ @staticmethod
56
+ def make_definition(name, dtype, shape=None, info={}) -> StreamDefinition:
57
+ if dtype == "json":
58
+ if shape is None:
59
+ return StreamDefinition(name, info, JsonStreamEncoder())
60
+ else:
61
+ raise ValueError("JSON stream cannot have shape")
62
+ else:
63
+ if shape is None:
64
+ shape = ()
65
+ info = info.copy()
66
+ info["dtype"] = np.dtype(dtype).name
67
+ info["shape"] = shape
68
+ return StreamDefinition(name, info, NumericStreamEncoder(dtype, shape))
69
+
70
+ @property
71
+ def kind(self):
72
+ return self._kind
73
+
74
+ @property
75
+ def plugin(self):
76
+ None
77
+
78
+ @property
79
+ def dtype(self):
80
+ return self.event_stream.dtype
81
+
82
+ @property
83
+ def shape(self):
84
+ return self.event_stream.shape
85
+
86
+ def __len__(self):
87
+ return len(self._event_stream)
88
+
89
+ def __getitem__(self, key):
90
+ return self._event_stream[key]
91
+
92
+ def _need_last_only(self, last_only):
93
+ return last_only
94
+
95
+ def _build_view_from_events(self, index, events: EventRange, last_only):
96
+ # NOTE event_range is never empty
97
+ return View(events)
98
+
99
+
100
+ class BrokenStream(BaseStream):
101
+ def __init__(self, event_stream, plugin_name, exception, kind):
102
+ self._event_stream = event_stream
103
+ self._plugin_name = plugin_name
104
+ self._exception = exception
105
+ self._kind = kind
106
+
107
+ @property
108
+ def kind(self):
109
+ self._kind
110
+
111
+ @staticmethod
112
+ def make_definition(*args, **kwargs) -> StreamDefinition:
113
+ raise NotImplementedError
114
+
115
+ @property
116
+ def plugin(self):
117
+ return self._plugin_name
118
+
119
+ @property
120
+ def dtype(self):
121
+ raise self._exception
122
+
123
+ @property
124
+ def shape(self):
125
+ raise self._exception
126
+
127
+ def __len__(self):
128
+ raise self._exception
129
+
130
+ def __getitem__(self, key):
131
+ raise self._exception
132
+
133
+ def _need_last_only(self, last_only):
134
+ raise self._exception
135
+
136
+ def _build_view_from_events(
137
+ self, hl_index: int, events: EventRange, last_only: bool
138
+ ):
139
+ raise self._exception
140
+
141
+
142
+ class BrokenPluginStream(BrokenStream):
143
+ """A stream class instanciated in place of a plugin, if it can't be
144
+ instantiated. A warning is issued, but the scan object is not affected,
145
+ ensuring memory tracker robustness against plugins."""
146
+
147
+ def __init__(self, event_stream, plugin_name, exception):
148
+ super().__init__(event_stream, plugin_name, exception, "broken_plugin")
149
+
150
+
151
+ class MissingPluginStream(BrokenStream):
152
+ """A stream class instanciated in place of a plugin if not installed."""
153
+
154
+ def __init__(self, event_stream, plugin_name):
155
+ super().__init__(
156
+ event_stream,
157
+ plugin_name,
158
+ MissingPluginException(event_stream.name, plugin_name),
159
+ "missing_plugin",
160
+ )
@@ -12,7 +12,7 @@ from dataclasses import dataclass
12
12
  from .encoding import EncodedBatch
13
13
  from .encoding.json import JsonStreamEncoder
14
14
  from .encoding.numeric import NumericStreamEncoder
15
- from .exceptions import (
15
+ from blissdata.exceptions import (
16
16
  IndexNoMoreThereError,
17
17
  IndexNotYetThereError,
18
18
  IndexWontBeThereError,
@@ -7,8 +7,9 @@
7
7
  import numpy as np
8
8
 
9
9
  from blissdata.h5api import dynamic_hdf5
10
- from blissdata.redis_engine.exceptions import IndexNoMoreThereError
11
- from blissdata.streams.base import Stream, StreamDefinition, BaseView, EventRange
10
+ from blissdata.exceptions import IndexNoMoreThereError
11
+ from blissdata.streams import BaseView, EventRange, StreamDefinition
12
+ from blissdata.streams.default import Stream
12
13
 
13
14
 
14
15
  class Hdf5BackedView(BaseView):
@@ -4,25 +4,27 @@
4
4
  #
5
5
  # Copyright (c) Beamline Control Unit, ESRF
6
6
  # Distributed under the GNU LGPLv3. See LICENSE for more info.
7
+ from abc import ABC, abstractmethod
7
8
  import numpy as np
8
9
  from numpy.typing import DTypeLike
9
10
  from collections.abc import Sequence
10
- from blissdata.streams.base import (
11
- Stream,
11
+ from blissdata.streams import (
12
12
  BaseStream,
13
13
  BaseView,
14
14
  StreamDefinition,
15
15
  EventRange,
16
16
  )
17
+ from blissdata.streams.default import Stream
18
+ from blissdata.streams.encoding.json import JsonStreamEncoder
17
19
  from blissdata.lima.client import LimaClient, ImageReference
18
- from blissdata.redis_engine.encoding.json import JsonStreamEncoder
19
- from blissdata.redis_engine.exceptions import (
20
+ from blissdata.exceptions import (
20
21
  EndOfStream,
21
22
  IndexWontBeThereError,
22
23
  IndexNotYetThereError,
23
24
  IndexNoMoreThereError,
24
25
  EmptyViewException,
25
26
  )
27
+ from blissdata.lima.image_utils import ImageData
26
28
 
27
29
 
28
30
  class LimaView(BaseView):
@@ -50,7 +52,15 @@ class LimaView(BaseView):
50
52
  )
51
53
 
52
54
 
53
- class LimaStream(BaseStream):
55
+ class LimaDirectAccess(ABC):
56
+ """Provides access to images directly from the backend (bypassing the blissdata stream)."""
57
+
58
+ @abstractmethod
59
+ def get_last_live_image(self) -> ImageData:
60
+ """Access the most up to date frame directly from the backend."""
61
+
62
+
63
+ class LimaStream(BaseStream, LimaDirectAccess):
54
64
  """Same API as a Stream but with a lima client inside to dereference events into images.
55
65
  Will support any Lima version as long as there is a client for it."""
56
66
 
@@ -218,5 +228,5 @@ class LimaStream(BaseStream):
218
228
  else:
219
229
  raise IndexNoMoreThereError
220
230
 
221
- def get_last_live_image(self):
231
+ def get_last_live_image(self) -> ImageData:
222
232
  return self._client.get_last_live_image()