Add Support for Batch Publishing Non-Scalar Measurement Values#133
Add Support for Batch Publishing Non-Scalar Measurement Values#133hunter-ni wants to merge 23 commits into
Conversation
…entBatchRequest with non-scalar measurement values.
…tchRequest with values.
… types of (single) Vector and simple Iterables of primitive types.
…MeasurementBatchRequest.
…ement data as a batch
…asurementBatch test names
There was a problem hiding this comment.
Pull request overview
This pull request extends the NI DataStore Python client’s batch publishing support to include non-scalar measurement value types (e.g., AnalogWaveform, Vector, XYData) in addition to the existing scalar batch support, aligning the client with updated service API capabilities.
Changes:
- Updated gRPC request population logic to accept
Iterables of supported non-scalar measurement types and map them into the appropriatePublishMeasurementBatchRequestfields. - Added extensive unit and acceptance tests validating successful conversions/publishing and error handling for heterogeneous/unsupported iterables.
- Added a notebook example demonstrating batch publishing for both scalar and non-scalar measurements (and conditions).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/data/test_publish_measurement.py | Updates an assertion to match the new unsupported-iterable error message format. |
| tests/unit/data/test_grpc_conversion.py | Adds unit tests covering batch conversion for multiple non-scalar types and error cases. |
| tests/acceptance/test_publish_measurement_batch_and_read_data.py | Adds acceptance tests for batch publishing/read-back of non-scalar values (e.g., AnalogWaveform, per-iteration Vector). |
| src/ni/datastore/data/_grpc_conversion.py | Implements iterable-of-non-scalar handling for publish_measurement_batch request construction. |
| pyproject.toml | Bumps ni-measurements-data-v1-client minimum prerelease version to pick up new API support. |
| poetry.lock | Updates locked dependency versions consistent with the updated client/proto requirements. |
| examples/notebooks/publish/publish_batch.ipynb | New notebook documenting and exercising scalar + non-scalar batch publishing flows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert vector == expected_vector | ||
|
|
||
|
|
||
| def test___publish_batch_double_analog_waveforms___read_measurement_value_returns_each_analog_waveform( |
There was a problem hiding this comment.
do we want any tests for spectrum or XY data?
There was a problem hiding this comment.
My initial inclination was to have more exhaustive coverage at the level of test_grpc_conversion.py and then just have representative acceptance-level tests for a couple of selected non-scalar types. We can see if others feel strongly on this one way or the other.
| values_iterator = iter(values) | ||
| try: | ||
| vector = Vector(values) | ||
| first_value = next(values_iterator) |
There was a problem hiding this comment.
This is a really long if / elif block. At a minimum, maybe we could split up the contents of the if blocks into small helper methods. Better is probably some kind of a strategy to produce the data to publish. I'll be out after today, so feel free to discuss with others or override this, but as is, it's pretty unreadable.
dixonjoel
left a comment
There was a problem hiding this comment.
Approved with a suggestion for code cleanup. I'm not doing 'Request Changes' since I'll be out on vacation as of tomorrow, so I'll trust you to address those.
What does this Pull Request accomplish?
This set of changes updates the MDS Python API to support the batch publishing of non-scalar measurement values (e.g.,
AnalogWaveform). This is in addition to the pre-existing support for batch publishing scalar measurement values.This reflects the addition of this support to the service API itself in ni/ni-apis#161.
Implementation
_grpc_conversion.pyto handle anIterableof the various supported non-scalar data types being supplied as thevaluesobject being passed intopublish_measurement_batch.Iterableis consistent with our existing support of anIterableoffloat,int,str, andboolbeing supplied for batch publishing scalar values.Why should this Pull Request be merged?
This PR should be submitted to maintain feature support/consistency between the MDS Python API and the
DataStoreServiceitself.What testing has been done?
PublishMeasurementBatchRequestappropriately from batched, non-scalar values supplied topublish_measurement_batchIterables and unsupported types being suppliedpublish_measurement_batch(in addition topublish_condition_batch).