ni.datastore 0.1.0.dev6__tar.gz → 2.0.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 (39) hide show
  1. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/PKG-INFO +10 -10
  2. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/README.md +2 -3
  3. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/pyproject.toml +17 -10
  4. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/__init__.py +0 -3
  5. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/_data_store_client.py +95 -96
  6. ni_datastore-2.0.0/src/ni/datastore/data/_grpc_conversion.py +373 -0
  7. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/_types/_published_condition.py +2 -15
  8. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/_types/_published_measurement.py +8 -18
  9. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/_types/_step.py +23 -22
  10. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/_types/_test_result.py +25 -24
  11. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_metadata_store_client.py +13 -12
  12. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_alias.py +1 -1
  13. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_hardware_item.py +4 -3
  14. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_metadata_items.py +4 -3
  15. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_operator.py +4 -3
  16. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_software_item.py +4 -3
  17. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_test.py +4 -3
  18. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_test_adapter.py +4 -3
  19. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_test_description.py +4 -3
  20. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_test_station.py +4 -3
  21. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_uut.py +4 -3
  22. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_uut_instance.py +4 -3
  23. ni_datastore-0.1.0.dev6/src/ni/datastore/data/_grpc_conversion.py +0 -262
  24. ni_datastore-0.1.0.dev6/src/ni/datastore/data/_types/_moniker.py +0 -69
  25. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/LICENSE +0 -0
  26. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/__init__.py +0 -0
  27. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/_types/__init__.py +0 -0
  28. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/_types/_error_information.py +0 -0
  29. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/_types/_outcome.py +0 -0
  30. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/_types/py.typed +0 -0
  31. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/data/py.typed +0 -0
  32. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/__init__.py +0 -0
  33. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_grpc_conversion.py +0 -0
  34. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/__init__.py +0 -0
  35. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_alias_target_type.py +0 -0
  36. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/_extension_schema.py +0 -0
  37. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/_types/py.typed +0 -0
  38. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/metadata/py.typed +0 -0
  39. {ni_datastore-0.1.0.dev6 → ni_datastore-2.0.0}/src/ni/datastore/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ni.datastore
3
- Version: 0.1.0.dev6
3
+ Version: 2.0.0
4
4
  Summary: APIs for publishing and retrieving data from NI Measurement Data Services
5
5
  License: MIT
6
6
  Keywords: datastore
@@ -9,7 +9,7 @@ Author-email: opensource@ni.com
9
9
  Maintainer: Johann Scholtz
10
10
  Maintainer-email: johann.scholtz@emerson.com
11
11
  Requires-Python: >=3.10,<4.0
12
- Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: Intended Audience :: Manufacturing
15
15
  Classifier: Intended Audience :: Science/Research
@@ -23,12 +23,13 @@ Classifier: Programming Language :: Python :: 3.12
23
23
  Classifier: Programming Language :: Python :: 3.13
24
24
  Classifier: Programming Language :: Python :: 3.14
25
25
  Classifier: Programming Language :: Python :: Implementation :: CPython
26
- Requires-Dist: hightime (>=0.3.0.dev0)
27
- Requires-Dist: ni-datamonikers-v1-client (>=0.1.0.dev1)
28
- Requires-Dist: ni-measurements-data-v1-client (>=0.2.0.dev4)
29
- Requires-Dist: ni-measurements-metadata-v1-client (>=0.2.0.dev2)
30
- Requires-Dist: ni-protobuf-types (>=1.0.1.dev0)
26
+ Requires-Dist: hightime (>=1.0.0)
27
+ Requires-Dist: ni-measurements-data-v1-client (>=1.1.0)
28
+ Requires-Dist: ni-measurements-metadata-v1-client (>=1.0.0)
29
+ Requires-Dist: ni-protobuf-types (>=1.2.0)
31
30
  Requires-Dist: protobuf (>=4.21)
31
+ Project-URL: Documentation, https://datastorepython.readthedocs.io/en/latest/
32
+ Project-URL: Repository, https://github.com/ni/datastore-python
32
33
  Description-Content-Type: text/markdown
33
34
 
34
35
  # Table of Contents
@@ -43,8 +44,7 @@ Description-Content-Type: text/markdown
43
44
  # Measurement Data Services API for Python
44
45
 
45
46
  `datastore-python` contains Python code for writing to and reading from
46
- [NI Measurement Data Services](https://github.com/ni/datastore-service).
47
- It will include examples of how to use the Python API.
47
+ NI Measurement Data Store. It will include examples of how to use the Python API.
48
48
 
49
49
  # About
50
50
 
@@ -65,7 +65,7 @@ NI created and supports this package.
65
65
  ## Installation
66
66
 
67
67
  As a prerequisite to using the `ni.datastore` module, you must install Measurement Data Services
68
- Software 2026 Q1 or later on your system. You can download and install this software using
68
+ Software 2026 Q3 or later on your system. You can download and install this software using
69
69
  [NI Package Manager](https://www.ni.com/en/support/downloads/software-products/download.package-manager.html).
70
70
 
71
71
  You can directly install the `ni.datastore` package using `pip` or by listing it as a
@@ -10,8 +10,7 @@
10
10
  # Measurement Data Services API for Python
11
11
 
12
12
  `datastore-python` contains Python code for writing to and reading from
13
- [NI Measurement Data Services](https://github.com/ni/datastore-service).
14
- It will include examples of how to use the Python API.
13
+ NI Measurement Data Store. It will include examples of how to use the Python API.
15
14
 
16
15
  # About
17
16
 
@@ -32,7 +31,7 @@ NI created and supports this package.
32
31
  ## Installation
33
32
 
34
33
  As a prerequisite to using the `ni.datastore` module, you must install Measurement Data Services
35
- Software 2026 Q1 or later on your system. You can download and install this software using
34
+ Software 2026 Q3 or later on your system. You can download and install this software using
36
35
  [NI Package Manager](https://www.ni.com/en/support/downloads/software-products/download.package-manager.html).
37
36
 
38
37
  You can directly install the `ni.datastore` package using `pip` or by listing it as a
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ni.datastore"
3
- version = "0.1.0.dev6"
3
+ version = "2.0.0"
4
4
  license = "MIT"
5
5
  description = "APIs for publishing and retrieving data from NI Measurement Data Services"
6
6
  authors = [{name = "NI", email = "opensource@ni.com"}]
@@ -9,10 +9,9 @@ maintainers = [
9
9
  {name = "Joel Dixon", email = "joel.dixon@emerson.com"}
10
10
  ]
11
11
  readme = "README.md"
12
- repository = "https://github.com/ni/datastore-python"
13
12
  keywords = ["datastore"]
14
13
  classifiers = [
15
- "Development Status :: 3 - Alpha",
14
+ "Development Status :: 5 - Production/Stable",
16
15
  "Intended Audience :: Developers",
17
16
  "Intended Audience :: Manufacturing",
18
17
  "Intended Audience :: Science/Research",
@@ -30,6 +29,10 @@ classifiers = [
30
29
  dynamic = ["dependencies"]
31
30
  requires-python = '>=3.10,<4.0'
32
31
 
32
+ [project.urls]
33
+ repository = "https://github.com/ni/datastore-python"
34
+ documentation = "https://datastorepython.readthedocs.io/en/latest/"
35
+
33
36
  [tool.poetry]
34
37
  packages = [{include = "ni", from = "src"}]
35
38
  requires-poetry = '>=2.1,<3.0'
@@ -37,11 +40,10 @@ requires-poetry = '>=2.1,<3.0'
37
40
  [tool.poetry.dependencies]
38
41
  python = "^3.10"
39
42
  protobuf = {version=">=4.21"}
40
- ni-datamonikers-v1-client = { version = ">=0.1.0.dev1", allow-prereleases = true }
41
- ni-measurements-data-v1-client = { version = ">=0.2.0.dev4", allow-prereleases = true }
42
- ni-measurements-metadata-v1-client = { version = ">=0.2.0.dev2", allow-prereleases = true }
43
- ni-protobuf-types = { version = ">=1.0.1.dev0", allow-prereleases = true }
44
- hightime = { version = ">=0.3.0.dev0", allow-prereleases = true }
43
+ ni-measurements-data-v1-client = { version = ">=1.1.0", allow-prereleases = true }
44
+ ni-measurements-metadata-v1-client = { version = ">=1.0.0" }
45
+ ni-protobuf-types = { version = ">=1.2.0", allow-prereleases = true }
46
+ hightime = { version = ">=1.0.0" }
45
47
 
46
48
  [tool.poetry.group.dev.dependencies]
47
49
  types-grpcio = ">=1.0"
@@ -51,6 +53,7 @@ plotly = ">=5.0"
51
53
  nbformat = ">=4.2.0"
52
54
  ipython = ">=7.0"
53
55
  jupyter = ">=1.0"
56
+ datastore-utilities = { path = "./utilities", develop = true }
54
57
 
55
58
  [tool.poetry.group.lint.dependencies]
56
59
  bandit = { version = ">=1.7", extras = ["toml"] }
@@ -89,7 +92,7 @@ skips = [
89
92
  ]
90
93
 
91
94
  [tool.ni-python-styleguide]
92
- extend_exclude = "docs,examples"
95
+ extend_exclude = "docs,examples,utilities"
93
96
 
94
97
  [tool.black]
95
98
  extend-exclude = 'docs/|examples/|_pb2(_grpc)?\.(py|pyi)$'
@@ -101,7 +104,7 @@ files = "."
101
104
  namespace_packages = true
102
105
  strict = true
103
106
  explicit_package_bases = true
104
- exclude = ["docs", "examples"]
107
+ exclude = ["docs", "examples", "utilities"]
105
108
 
106
109
  [tool.pyright]
107
110
  include = ["src/", "tests/"]
@@ -110,3 +113,7 @@ exclude = ["**/*_pb2_grpc.py", "**/*_pb2_grpc.pyi", "**/*_pb2.py", "**/*_pb2.pyi
110
113
  [tool.pytest.ini_options]
111
114
  addopts = "--doctest-modules --doctest-plus --strict-markers"
112
115
  testpaths = ["tests"]
116
+ norecursedirs = [".venv"]
117
+ filterwarnings = [
118
+ "ignore:cannot collect test class.*because it has a __init__ constructor:pytest.PytestCollectionWarning",
119
+ ]
@@ -2,7 +2,6 @@
2
2
 
3
3
  from ni.datastore.data._data_store_client import DataStoreClient
4
4
  from ni.datastore.data._types._error_information import ErrorInformation
5
- from ni.datastore.data._types._moniker import Moniker
6
5
  from ni.datastore.data._types._outcome import Outcome
7
6
  from ni.datastore.data._types._published_condition import PublishedCondition
8
7
  from ni.datastore.data._types._published_measurement import PublishedMeasurement
@@ -12,7 +11,6 @@ from ni.datastore.data._types._test_result import TestResult
12
11
  __all__ = [
13
12
  "DataStoreClient",
14
13
  "ErrorInformation",
15
- "Moniker",
16
14
  "Outcome",
17
15
  "PublishedCondition",
18
16
  "PublishedMeasurement",
@@ -23,7 +21,6 @@ __all__ = [
23
21
  # Hide that it was not defined in this top-level package
24
22
  DataStoreClient.__module__ = __name__
25
23
  ErrorInformation.__module__ = __name__
26
- Moniker.__module__ = __name__
27
24
  Outcome.__module__ = __name__
28
25
  PublishedCondition.__module__ = __name__
29
26
  PublishedMeasurement.__module__ = __name__
@@ -7,27 +7,10 @@ import sys
7
7
  from collections.abc import Iterable, Sequence
8
8
  from threading import Lock
9
9
  from types import TracebackType
10
- from typing import TYPE_CHECKING, Type, TypeVar, overload
11
- from urllib.parse import urlparse
10
+ from typing import overload, Type, TYPE_CHECKING, TypeVar
12
11
 
13
12
  import hightime as ht
14
13
  from grpc import Channel
15
- from ni.datamonikers.v1.client import MonikerClient
16
- from ni.datastore.data._grpc_conversion import (
17
- get_publish_measurement_timestamp,
18
- populate_publish_condition_batch_request_values,
19
- populate_publish_condition_request_value,
20
- populate_publish_measurement_batch_request_values,
21
- populate_publish_measurement_request_value,
22
- unpack_and_convert_from_protobuf_any,
23
- )
24
- from ni.datastore.data._types._error_information import ErrorInformation
25
- from ni.datastore.data._types._moniker import Moniker
26
- from ni.datastore.data._types._outcome import Outcome
27
- from ni.datastore.data._types._published_condition import PublishedCondition
28
- from ni.datastore.data._types._published_measurement import PublishedMeasurement
29
- from ni.datastore.data._types._step import Step
30
- from ni.datastore.data._types._test_result import TestResult
31
14
  from ni.measurementlink.discovery.v1.client import DiscoveryClient
32
15
  from ni.measurements.data.v1.client import DataStoreClient as DataStoreServiceClient
33
16
  from ni.measurements.data.v1.data_store_service_pb2 import (
@@ -45,12 +28,30 @@ from ni.measurements.data.v1.data_store_service_pb2 import (
45
28
  QueryMeasurementsRequest,
46
29
  QueryStepsRequest,
47
30
  QueryTestResultsRequest,
31
+ ReadConditionValueRequest,
32
+ ReadMeasurementValueRequest,
48
33
  )
49
34
  from ni.protobuf.types.precision_timestamp_conversion import (
50
35
  hightime_datetime_to_protobuf,
51
36
  )
52
37
  from ni_grpc_extensions.channelpool import GrpcChannelPool
53
38
 
39
+ from ni.datastore.data._grpc_conversion import (
40
+ convert_measurement_timestamp_to_protobuf,
41
+ convert_read_condition_response_from_protobuf,
42
+ convert_read_measurement_response_from_protobuf,
43
+ populate_publish_condition_batch_request_values,
44
+ populate_publish_condition_request_value,
45
+ populate_publish_measurement_batch_request_values,
46
+ populate_publish_measurement_request_value,
47
+ )
48
+ from ni.datastore.data._types._error_information import ErrorInformation
49
+ from ni.datastore.data._types._outcome import Outcome
50
+ from ni.datastore.data._types._published_condition import PublishedCondition
51
+ from ni.datastore.data._types._published_measurement import PublishedMeasurement
52
+ from ni.datastore.data._types._step import Step
53
+ from ni.datastore.data._types._test_result import TestResult
54
+
54
55
  if TYPE_CHECKING:
55
56
  if sys.version_info >= (3, 11):
56
57
  from typing import Self
@@ -72,8 +73,6 @@ class DataStoreClient:
72
73
  "_grpc_channel_pool",
73
74
  "_data_store_client",
74
75
  "_data_store_client_lock",
75
- "_moniker_clients_by_service_location",
76
- "_moniker_clients_lock",
77
76
  )
78
77
 
79
78
  _DATA_STORE_CLIENT_CLOSED_ERROR = (
@@ -86,9 +85,7 @@ class DataStoreClient:
86
85
  _grpc_channel: Channel | None
87
86
  _grpc_channel_pool: GrpcChannelPool | None
88
87
  _data_store_client: DataStoreServiceClient | None
89
- _moniker_clients_by_service_location: dict[str, MonikerClient]
90
88
  _data_store_client_lock: Lock
91
- _moniker_clients_lock: Lock
92
89
 
93
90
  def __init__(
94
91
  self,
@@ -102,9 +99,7 @@ class DataStoreClient:
102
99
  discovery_client: An optional discovery client (recommended).
103
100
 
104
101
  grpc_channel: An optional data store gRPC channel. Providing this channel will bypass
105
- discovery service resolution of the data store. (Note: Reading data from a moniker
106
- will still always use a channel corresponding to the service location specified by
107
- that moniker.)
102
+ discovery service resolution of the data store.
108
103
 
109
104
  grpc_channel_pool: An optional gRPC channel pool (recommended).
110
105
  """
@@ -113,10 +108,8 @@ class DataStoreClient:
113
108
  self._grpc_channel_pool = grpc_channel_pool
114
109
 
115
110
  self._data_store_client = None
116
- self._moniker_clients_by_service_location = {}
117
111
 
118
112
  self._data_store_client_lock = Lock()
119
- self._moniker_clients_lock = Lock()
120
113
 
121
114
  self._closed = False
122
115
 
@@ -142,11 +135,6 @@ class DataStoreClient:
142
135
  self._data_store_client.close()
143
136
  self._data_store_client = None
144
137
 
145
- with self._moniker_clients_lock:
146
- for _, moniker_client in self._moniker_clients_by_service_location.items():
147
- moniker_client.close()
148
- self._moniker_clients_by_service_location.clear()
149
-
150
138
  def publish_condition(
151
139
  self,
152
140
  name: str,
@@ -250,8 +238,8 @@ class DataStoreClient:
250
238
  step_id: The ID of the step associated with this measurement. This
251
239
  value is expected to be a parsable GUID.
252
240
 
253
- timestamp: The timestamp of the measurement. If None, the current
254
- time will be used.
241
+ timestamp: The timestamp of the measurement. If None, no timestamp
242
+ will be specified.
255
243
 
256
244
  outcome: The outcome of the measurement (PASSED, FAILED,
257
245
  INDETERMINATE, or UNSPECIFIED).
@@ -287,11 +275,9 @@ class DataStoreClient:
287
275
  test_adapter_ids=test_adapter_ids,
288
276
  software_item_ids=software_item_ids,
289
277
  notes=notes,
278
+ timestamp=convert_measurement_timestamp_to_protobuf(timestamp),
290
279
  )
291
280
  populate_publish_measurement_request_value(publish_request, value)
292
- publish_request.timestamp.CopyFrom(
293
- get_publish_measurement_timestamp(publish_request, timestamp)
294
- )
295
281
  publish_response = self._get_data_store_client().publish_measurement(publish_request)
296
282
  return publish_response.measurement_id
297
283
 
@@ -308,7 +294,7 @@ class DataStoreClient:
308
294
  software_item_ids: Iterable[str] = tuple(),
309
295
  notes: str = "",
310
296
  ) -> Sequence[str]:
311
- """Publish multiple scalar measurements at once for parametric sweeps.
297
+ """Publish multiple measurements at once for parametric sweeps.
312
298
 
313
299
  Args:
314
300
  name: The name used for associating/grouping
@@ -316,7 +302,7 @@ class DataStoreClient:
316
302
  iterations. For example, "Temperature" can be used for
317
303
  associating temperature readings across multiple iterations.
318
304
 
319
- values: The values of the (scalar) measurement being published
305
+ values: The values of the measurement being published
320
306
  across N iterations.
321
307
 
322
308
  step_id: The ID of the step associated with this measurement. This
@@ -352,10 +338,9 @@ class DataStoreClient:
352
338
  notes: Any notes to be associated with the published measurements.
353
339
 
354
340
  Returns:
355
- Sequence[str]: The ids of the published measurement ids.
356
- NOTE: Using a Sequence is for future flexibility.
357
- This sequence will currently always have a single measurement id
358
- returned.
341
+ Sequence[str]: The IDs of the corresponding PublishedMeasurements. A single
342
+ ID will be returned when publishing scalar measurement values.
343
+ N IDs will be returned when publishing (N) non-scalar measurement values.
359
344
  """
360
345
  publish_request = PublishMeasurementBatchRequest(
361
346
  name=name,
@@ -375,30 +360,72 @@ class DataStoreClient:
375
360
  return publish_response.measurement_ids
376
361
 
377
362
  @overload
378
- def read_data(
363
+ def read_condition_value(
379
364
  self,
380
- moniker_source: Moniker | PublishedMeasurement | PublishedCondition,
365
+ read_source: PublishedCondition,
381
366
  expected_type: Type[TRead],
382
367
  ) -> TRead: ...
383
368
 
384
369
  @overload
385
- def read_data(
370
+ def read_condition_value(
386
371
  self,
387
- moniker_source: Moniker | PublishedMeasurement | PublishedCondition,
372
+ read_source: PublishedCondition,
388
373
  ) -> object: ...
389
374
 
390
- def read_data(
375
+ def read_condition_value(
391
376
  self,
392
- moniker_source: Moniker | PublishedMeasurement | PublishedCondition,
377
+ read_source: PublishedCondition,
393
378
  expected_type: Type[TRead] | None = None,
394
379
  ) -> TRead | object:
395
380
  """Read data published to the data store.
396
381
 
397
382
  Args:
398
- moniker_source: The source from which to read data. Can be:
399
- - A Moniker (wrapper type) directly
400
- - A PublishedMeasurement (uses its moniker)
401
- - A PublishedCondition (uses its moniker)
383
+ read_source: The source from which to read data (PublishedCondition).
384
+
385
+ expected_type: Optional type to validate the returned data against.
386
+ If provided, a TypeError will be raised if the actual data type
387
+ doesn't match.
388
+
389
+ Returns:
390
+ The data retrieved from the data store. The return type depends on
391
+ what was originally published:
392
+ - Scalar conditions return as Vectors
393
+ - Other types are returned as originally published
394
+ If expected_type is specified, the return value is guaranteed to be
395
+ of that type.
396
+
397
+ Raises:
398
+ TypeError: If expected_type is provided and the actual data type
399
+ doesn't match.
400
+ """
401
+ read_value = self._read_condition(read_source)
402
+ if expected_type is not None and not isinstance(read_value, expected_type):
403
+ raise TypeError(f"Expected type {expected_type}, got {type(read_value)}")
404
+
405
+ return read_value
406
+
407
+ @overload
408
+ def read_measurement_value(
409
+ self,
410
+ read_source: PublishedMeasurement,
411
+ expected_type: Type[TRead],
412
+ ) -> TRead: ...
413
+
414
+ @overload
415
+ def read_measurement_value(
416
+ self,
417
+ read_source: PublishedMeasurement,
418
+ ) -> object: ...
419
+
420
+ def read_measurement_value(
421
+ self,
422
+ read_source: PublishedMeasurement,
423
+ expected_type: Type[TRead] | None = None,
424
+ ) -> TRead | object:
425
+ """Read data published to the data store.
426
+
427
+ Args:
428
+ read_source: The source from which to read data (PublishedMeasurement).
402
429
 
403
430
  expected_type: Optional type to validate the returned data against.
404
431
  If provided, a TypeError will be raised if the actual data type
@@ -413,33 +440,14 @@ class DataStoreClient:
413
440
  of that type.
414
441
 
415
442
  Raises:
416
- ValueError: If the moniker_source doesn't have a valid moniker.
417
443
  TypeError: If expected_type is provided and the actual data type
418
444
  doesn't match.
419
445
  """
420
- from ni.datamonikers.v1.data_moniker_pb2 import Moniker as MonikerProto
421
-
422
- moniker_proto: MonikerProto
423
-
424
- if isinstance(moniker_source, Moniker):
425
- moniker_proto = moniker_source.to_protobuf()
426
- elif isinstance(moniker_source, PublishedMeasurement):
427
- if moniker_source.moniker is None:
428
- raise ValueError("PublishedMeasurement must have a Moniker to read data")
429
- moniker_proto = moniker_source.moniker.to_protobuf()
430
- elif isinstance(moniker_source, PublishedCondition):
431
- if moniker_source.moniker is None:
432
- raise ValueError("PublishedCondition must have a Moniker to read data")
433
- moniker_proto = moniker_source.moniker.to_protobuf()
434
- else:
435
- raise TypeError(f"Unsupported moniker_source type: {type(moniker_source)}")
436
-
437
- moniker_client = self._get_moniker_client(moniker_proto.service_location)
438
- read_result = moniker_client.read_from_moniker(moniker_proto)
439
- converted_data = unpack_and_convert_from_protobuf_any(read_result.value)
440
- if expected_type is not None and not isinstance(converted_data, expected_type):
441
- raise TypeError(f"Expected type {expected_type}, got {type(converted_data)}")
442
- return converted_data
446
+ read_value = self._read_measurement(read_source)
447
+ if expected_type is not None and not isinstance(read_value, expected_type):
448
+ raise TypeError(f"Expected type {expected_type}, got {type(read_value)}")
449
+
450
+ return read_value
443
451
 
444
452
  def create_step(self, step: Step) -> str:
445
453
  """Create a new step in the data store.
@@ -540,7 +548,7 @@ class DataStoreClient:
540
548
 
541
549
  Returns:
542
550
  Sequence[PublishedCondition]: The list of matching conditions. Each
543
- item contains a moniker for retrieving the condition
551
+ item contains an id for retrieving the condition
544
552
  measurements, as well as the metadata associated with the
545
553
  condition.
546
554
  """
@@ -563,7 +571,7 @@ class DataStoreClient:
563
571
 
564
572
  Returns:
565
573
  Sequence[PublishedMeasurement]: The list of matching measurements.
566
- Each item contains a moniker for retrieving the measurement, as
574
+ Each item contains an id for retrieving the measurement, as
567
575
  well as the metadata associated with the measurement.
568
576
  """
569
577
  query_request = QueryMeasurementsRequest(odata_query=odata_query)
@@ -629,21 +637,12 @@ class DataStoreClient:
629
637
  grpc_channel_pool=self._grpc_channel_pool,
630
638
  )
631
639
 
632
- def _get_moniker_client(self, service_location: str) -> MonikerClient:
633
- if self._closed:
634
- raise RuntimeError(self._DATA_STORE_CLIENT_CLOSED_ERROR)
640
+ def _read_measurement(self, published_measurement: PublishedMeasurement) -> object:
641
+ request = ReadMeasurementValueRequest(measurement_id=published_measurement.id)
642
+ response = self._get_data_store_client().read_measurement_value(request)
643
+ return convert_read_measurement_response_from_protobuf(response)
635
644
 
636
- parsed_service_location = urlparse(service_location).netloc
637
- if parsed_service_location not in self._moniker_clients_by_service_location:
638
- with self._moniker_clients_lock:
639
- if parsed_service_location not in self._moniker_clients_by_service_location:
640
- self._moniker_clients_by_service_location[parsed_service_location] = (
641
- self._instantiate_moniker_client(parsed_service_location)
642
- )
643
- return self._moniker_clients_by_service_location[parsed_service_location]
644
-
645
- def _instantiate_moniker_client(self, parsed_service_location: str) -> MonikerClient:
646
- return MonikerClient(
647
- service_location=parsed_service_location,
648
- grpc_channel_pool=self._grpc_channel_pool,
649
- )
645
+ def _read_condition(self, published_condition: PublishedCondition) -> object:
646
+ request = ReadConditionValueRequest(condition_id=published_condition.id)
647
+ response = self._get_data_store_client().read_condition_value(request)
648
+ return convert_read_condition_response_from_protobuf(response)