Skip to content

Commit b9f27f9

Browse files
dixonjoelJoel Dixon
andauthored
Update data.client and metadata.client package dependencies to the latest (#63)
* Update data.proto and fix mypy errors * Update to the latest versions of data.client and metadata.client * Fix a couple tests * Run poetry update to include renovate changes * Rename wrapper class fields to match .proto fields * Fix ni-python-styleguide error * Add error_information to TestResult * Add error_information to Step class * Add outcome field to Step class * Rename step_name to name and step_type to type in Step class - Updated __slots__, __init__ parameters, and field assignments - Updated from_protobuf and to_protobuf methods - Updated __eq__ method and docstring - Updated all test files to use new field names - Maintains compatibility with protobuf schema * Fix custom_metadata notebook * Update TestResult.test_result_name to name * Change condition_name to name and condition_type to type. * Rename alias_name, measurement_name, and measurement_notes. * Rename schema_id to id * Fix overview example with latest code changes * Fix some notebooks * Fix query notebooks * Fix voltage-regulator notebook * Fix mypy errors * Add notes to publish_measurement_batch * Update documentation for field name changes * Make start_date_time and end_date_time writable. * Update TestResult fields * Clear query_metadata outputs * Remove comment --------- Co-authored-by: Joel Dixon <[email protected]>
1 parent ea18553 commit b9f27f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+695
-895
lines changed

docs/reference/ni-data-store.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ A **TestResult** represents a complete test session or test execution run for a
1616
- `software_item_ids` (list of strings) - IDs of software used during testing
1717
- `hardware_item_ids` (list of strings) - IDs of hardware used during testing
1818
- `test_adapter_ids` (list of strings) - IDs of test adapters used
19-
- `test_result_name` (string) - Human-readable name for the test run
19+
- `name` (string) - Human-readable name for the test run
2020
- `start_date_time` (timestamp) - When the test execution started
2121
- `end_date_time` (timestamp) - When the test execution finished
2222
- `outcome` (enum) - Overall test result (PASSED, FAILED, INDETERMINATE, UNSPECIFIED)
2323
- `link` (string) - Optional link to additional resources
2424
- `extensions` (dict) - Custom key-value pairs for additional metadata
2525
- `schema_id` (string) - ID of the schema for extension validation
26+
- `error_information` (ErrorInformation) - Error details if test result failed
2627

2728
**Real-world example**: When you put a circuit board on a test station and run a complete validation sequence, that entire session becomes one TestResult. It includes metadata like who ran the test, when it was run, what test station was used, and links to all the measurements and steps that were performed.
2829

@@ -34,14 +35,16 @@ A **Step** represents an individual test procedure or operation within a larger
3435
- `parent_step_id` (string) - ID of parent step (for hierarchical steps)
3536
- `test_result_id` (string) - ID of the associated TestResult
3637
- `test_id` (string) - ID of the test definition/specification
37-
- `step_name` (string) - Human-readable name for the step
38-
- `step_type` (string) - Type/category of the step
38+
- `name` (string) - Human-readable name for the step
39+
- `type` (string) - Type/category of the step
3940
- `notes` (string) - Additional notes about the step
4041
- `start_date_time` (timestamp) - When the step started executing
4142
- `end_date_time` (timestamp) - When the step finished executing
43+
- `outcome` (enum) - Result of this step (PASSED, FAILED, INDETERMINATE, UNSPECIFIED)
4244
- `link` (string) - Optional link to additional resources
4345
- `extensions` (dict) - Custom key-value pairs for additional metadata
4446
- `schema_id` (string) - ID of the schema for extension validation
47+
- `error_information` (ErrorInformation) - Error details if step failed
4548

4649
**Real-world examples**:
4750
- "Measure DC Voltage on Pin 5"
@@ -64,9 +67,9 @@ A **PublishedMeasurement** represents actual measurement data captured during a
6467
- `software_item_ids` (list of strings) - Software used to capture this measurement
6568
- `hardware_item_ids` (list of strings) - Hardware used to capture this measurement
6669
- `test_adapter_ids` (list of strings) - Test adapters used to capture this measurement
67-
- `measurement_name` (string) - Name used to group related measurements
70+
- `name` (string) - Name used to group related measurements
6871
- `data_type` (string) - Type of data (e.g., "Scalar", "AnalogWaveform", "Spectrum")
69-
- `measurement_notes` (string) - Additional notes about the measurement
72+
- `notes` (string) - Additional notes about the measurement
7073
- `start_date_time` (timestamp) - When measurement capture started
7174
- `end_date_time` (timestamp) - When measurement capture finished
7275
- `outcome` (enum) - Result of this measurement (PASSED, FAILED, INDETERMINATE, UNSPECIFIED)
@@ -95,8 +98,8 @@ A **PublishedCondition** represents environmental or contextual information that
9598
**Fields:**
9699
- `moniker` (Moniker) - Data location identifier for retrieving the condition value
97100
- `id` (string) - Unique identifier for this condition
98-
- `condition_name` (string) - Name of the condition (e.g., "Temperature", "Supply Voltage")
99-
- `condition_type` (string) - Type/category of the condition (e.g., "Environment", "Input Parameter")
101+
- `name` (string) - Name of the condition (e.g., "Temperature", "Supply Voltage")
102+
- `type` (string) - Type/category of the condition (e.g., "Environment", "Input Parameter")
100103
- `step_id` (string) - ID of the associated Step
101104
- `test_result_id` (string) - ID of the associated TestResult
102105

docs/reference/ni-metadata-store.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ An **Operator** represents a person who performs tests or operates test equipmen
99

1010
**Fields:**
1111
- `id` (string) - The id of the operator
12-
- `operator_name` (string) - The name of the operator
12+
- `name` (string) - The name of the operator
1313
- `role` (string) - The role of the operator (e.g., "Test Engineer", "Lab Technician")
1414
- `link` (string) - URI to resource describing the operator
1515
- `extensions` (dict) - Custom key-value pairs for additional metadata
@@ -69,16 +69,17 @@ A **UUT Instance** represents an individual physical device with a unique serial
6969
- `id` (string) - The id of the UUT instance
7070
- `uut_id` (string) - The ID of the UUT associated with this instance (GUID or alias)
7171
- `serial_number` (string) - The serial number of the UUT instance
72-
- `asset_identifier` (string) - For tracking and inventory purposes
7372
- `manufacture_date` (string) - When the instance was manufactured
73+
- `firmware_version` (string) - Version of the firmware on the UUT instance
74+
- `hardware_version` (string) - Hardware version of the UUT instance
7475
- `link` (string) - URI to resource describing the UUT instance
7576
- `extensions` (dict) - Custom key-value pairs for additional metadata
7677
- `schema_id` (string) - ID of the schema for extension validation
7778

7879
**Real-world examples**:
79-
- UUT: "PowerSupply v2.1", Serial: "PS-2024-001" - First power supply unit built in 2024
80-
- UUT: "Audio Amplifier v1.3", Serial: "AMP-2024-456" - Specific amplifier with serial number
81-
- UUT: "RF Transceiver Gen3", Serial: "RF-X7G9-2024-789" - Individual transceiver unit
80+
- UUT: "PowerSupply v2.1", Serial: "PS-2024-001", FW: "1.2.3", HW: "Rev C" - First power supply unit built in 2024
81+
- UUT: "Audio Amplifier v1.3", Serial: "AMP-2024-456", FW: "2.0.1", HW: "Rev B" - Specific amplifier with serial number
82+
- UUT: "RF Transceiver Gen3", Serial: "RF-X7G9-2024-789", FW: "3.1.0", HW: "Rev A" - Individual transceiver unit
8283

8384
Each UUT instance tracks the test history for that specific physical device throughout its lifecycle.
8485

@@ -185,7 +186,7 @@ A **Test Adapter** represents a test fixture, mechanical setup, or interface use
185186
An **Extension Schema** defines the structure and validation rules for custom extension fields that can be added to any metadata entity.
186187

187188
**Fields:**
188-
- `schema_id` (string) - Unique identifier for the schema
189+
- `id` (string) - Unique identifier for the schema
189190
- `schema` (string) - The schema definition itself (JSON Schema format)
190191

191192
**Real-world examples**:
@@ -198,7 +199,7 @@ An **Extension Schema** defines the structure and validation rules for custom ex
198199
An **Alias** provides a human-readable name that points to any metadata entity. This creates a layer of abstraction that makes test code more maintainable and readable.
199200

200201
**Fields:**
201-
- `alias_name` (string) - The registered alias name for the metadata instance
202+
- `name` (string) - The registered alias name for the metadata instance
202203
- `target_type` (enum) - The type of the aliased metadata instance (see `AliasTargetType` enum)
203204
- `target_id` (string) - The unique identifier for the aliased metadata instance
204205

docs/reference/using-measurement-data-services.md

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ The typical measurement data workflow follows this sequence:
1414
2. [**Test Execution Phase**](#test-execution-phase) - Create test sessions and publish data
1515
3. [**Analysis Phase**](#analysis-phase) - Query and analyze results
1616

17+
## **Required Imports**
18+
19+
Before using the services, import the necessary classes and types:
20+
21+
```python
22+
from datetime import datetime
23+
from ni.datastore.data import DataStoreClient
24+
from ni.datastore.metadata import MetadataStoreClient
25+
from ni.datastore.data._types import TestResult, Step
26+
from ni.datastore.metadata._types import (
27+
Operator, TestStation, HardwareItem, SoftwareItem,
28+
Uut, UutInstance, TestDescription, Test, TestAdapter
29+
)
30+
from ni.measurements.data.v1.data_store_pb2 import Outcome
31+
from nitypes.scalar import Scalar
32+
from nitypes.vector import Vector
33+
from nitypes.waveform import AnalogWaveform
34+
```
35+
1736
## **Setup Phase**
1837

1938
Before running tests, establish the metadata foundation that describes your test environment and processes.
@@ -28,7 +47,7 @@ Register the people who will be running tests:
2847
```python
2948
# Create operators
3049
sarah = Operator(
31-
operator_name="Sarah Johnson",
50+
name="Sarah Johnson",
3251
role="Test Engineer",
3352
schema_id=schema_id,
3453
extensions={
@@ -39,7 +58,7 @@ sarah = Operator(
3958
sarah_id = metadata_store_client.create_operator(sarah)
4059

4160
mike_id = metadata_store_client.create_operator(Operator(
42-
operator_name="Mike Chen",
61+
name="Mike Chen",
4362
role="Senior Technician",
4463
schema_id=schema_id,
4564
extensions={
@@ -55,7 +74,7 @@ Define the physical locations where testing occurs:
5574
```python
5675
# Create test stations
5776
station_a1_id = metadata_store_client.create_test_station(TestStation(
58-
test_station_name="Station_A1",
77+
name="Station_A1",
5978
asset_identifier="STA-001",
6079
schema_id=schema_id,
6180
extensions={
@@ -65,7 +84,7 @@ station_a1_id = metadata_store_client.create_test_station(TestStation(
6584
))
6685

6786
rf_lab_id = metadata_store_client.create_test_station(TestStation(
68-
test_station_name="RF_Lab_Bench_1",
87+
name="RF_Lab_Bench_1",
6988
asset_identifier="RFL-001",
7089
schema_id=schema_id,
7190
extensions={
@@ -152,7 +171,7 @@ power_supply_uut = Uut(
152171
"efficiency": ">90%"
153172
}
154173
)
155-
power_supply_uut_id = metadata_store_client.create_uut(uut)
174+
power_supply_uut_id = metadata_store_client.create_uut(power_supply_uut)
156175
```
157176

158177
#### **UUT Instances (Physical Devices)**
@@ -179,7 +198,7 @@ Create test specifications and procedures:
179198
# Create comprehensive test suites
180199
power_test_desc_id = metadata_store_client.create_test_description(TestDescription(
181200
uut_id=power_supply_uut_id,
182-
test_description_name="Power Supply Validation Suite",
201+
name="Power Supply Validation Suite",
183202
schema_id=schema_id,
184203
extensions={
185204
"version": "v2.1",
@@ -192,7 +211,7 @@ power_test_desc_id = metadata_store_client.create_test_description(TestDescripti
192211
```python
193212
# Create specific test procedures
194213
voltage_test_id = metadata_store_client.create_test(Test(
195-
test_name="DC Voltage Accuracy Test",
214+
name="DC Voltage Accuracy Test",
196215
description="Measures DC voltage accuracy across 5V, 12V, and 24V outputs",
197216
schema_id=schema_id,
198217
extensions={
@@ -202,7 +221,7 @@ voltage_test_id = metadata_store_client.create_test(Test(
202221
))
203222

204223
load_test_id = metadata_store_client.create_test(Test(
205-
test_name="Load Regulation Test",
224+
name="Load Regulation Test",
206225
description="Tests voltage stability under varying load conditions",
207226
schema_id=schema_id,
208227
extensions={
@@ -258,7 +277,7 @@ metadata_store_client.create_alias(
258277
metadata_store_client.create_alias(
259278
alias_name="Current_PowerSupply_Design",
260279
alias_target=power_supply_uut
261-
))
280+
)
262281
```
263282

264283
---
@@ -280,7 +299,7 @@ test_result_id = data_store_client.create_test_result(TestResult(
280299
test_description_id=power_test_desc_id,
281300
software_item_ids=[python_id, nidaqmx_id, custom_app_id],
282301
hardware_item_ids=[dmm_id, scope_id], # or use aliases
283-
test_result_name="PowerSupply PS-2024-001456 Validation",
302+
name="PowerSupply PS-2024-001456 Validation",
284303
schema_id=schema_id,
285304
extensions={
286305
"test_operator_notes": "First production unit validation",
@@ -298,16 +317,16 @@ Organize measurements into logical **Steps**:
298317
voltage_step_id = data_store_client.create_step(Step(
299318
test_result_id=test_result_id,
300319
test_id=voltage_test_id,
301-
step_name="DC Voltage Accuracy Check",
302-
step_type="Measurement",
320+
name="DC Voltage Accuracy Check",
321+
type="Measurement",
303322
notes="Testing 5V, 12V, and 24V outputs under no load"
304323
))
305324

306325
load_step_id = data_store_client.create_step(Step(
307326
test_result_id=test_result_id,
308327
test_id=load_test_id,
309-
step_name="Load Regulation Test",
310-
step_type="Measurement",
328+
name="Load Regulation Test",
329+
type="Measurement",
311330
notes="Variable load from 0% to 100% rated current"
312331
))
313332
```
@@ -330,15 +349,15 @@ temperature = Scalar(value=23.5, units="DegC")
330349
data_store_client.publish_condition(
331350
condition_name="Temperature",
332351
type="Environment",
333-
value=temperature
352+
value=temperature,
334353
step_id=voltage_step_id
335354
)
336355

337356
humidity = Scalar(value=45.2, units="%RH")
338357
data_store_client.publish_condition(
339358
condition_name="Humidity",
340359
type="Environment",
341-
value=humidity
360+
value=humidity,
342361
step_id=voltage_step_id
343362
)
344363
```
@@ -483,10 +502,10 @@ Access the actual measured values:
483502
for measurement in measurements:
484503
if measurement.data_type == "type.googleapis.com/ni.protobuf.types.Vector":
485504
value = data_store_client.read_data(measurement, expected_type=Vector)
486-
print(f"{measurement.measurement_name}: {value}")
487-
else if measurement.data_type == "type.googleapis.com/ni.protobuf.types.DoubleAnalogWaveform":
488-
waveform = data_store_client.read_data(measurement, expected_type=DoubleAnalogWaveform)
489-
print(f"{measurement.measurement_name}: {len(waveform.samples)} samples")
505+
print(f"{measurement.name}: {value}")
506+
elif measurement.data_type == "type.googleapis.com/ni.protobuf.types.DoubleAnalogWaveform":
507+
waveform = data_store_client.read_data(measurement, expected_type=AnalogWaveform)
508+
print(f"{measurement.name}: {len(waveform.raw_data)} samples")
490509
```
491510

492511
### **4. Cross-Reference with Metadata**
@@ -526,14 +545,19 @@ for measurement in measurements:
526545
```python
527546
# Track performance over time for a UUT model
528547
uut_instances = metadata_store_client.query_uut_instances(
529-
f"$filter=UutId eq c26e0057-3732-47d5-9576-3e3487e6e5b9"
548+
f"$filter=UutId eq '{power_supply_uut_id}'"
530549
)
531550

532551
for instance in uut_instances:
533-
measurements = data_store_client.query_measurements(
534-
f"$filter=TestResultId eq {instance.uut_instance_id} and Name eq '5V Output Voltage'"
552+
# Get test results for this UUT instance
553+
test_results = data_store_client.query_test_results(
554+
f"$filter=UutInstanceId eq '{instance.id}'"
535555
)
536-
# Analyze voltage accuracy trends...
556+
for test_result in test_results:
557+
measurements = data_store_client.query_measurements(
558+
f"$filter=TestResultId eq '{test_result.id}' and Name eq '5V Output Voltage'"
559+
)
560+
# Analyze voltage accuracy trends...
537561
```
538562

539563
#### **Equipment Performance Analysis**

examples/notebooks/alias/alias.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"from ni.datastore.metadata import MetadataStoreClient, Operator\n",
2121
"\n",
2222
"metadata_store_client = MetadataStoreClient()\n",
23-
"operatorOne = Operator(operator_name=\"Jane Doe\")\n",
24-
"operatorTwo = Operator(operator_name=\"John Smith\")\n",
23+
"operatorOne = Operator(name=\"Jane Doe\")\n",
24+
"operatorTwo = Operator(name=\"John Smith\")\n",
2525
"\n",
2626
"metadata_store_client.create_operator(operatorOne)\n",
2727
"metadata_store_client.create_operator(operatorTwo)"
@@ -70,7 +70,7 @@
7070
"from ni.datastore.data import DataStoreClient, TestResult\n",
7171
"\n",
7272
"test_result = TestResult(\n",
73-
" test_result_name=\"Test Result with Operator Alias\",\n",
73+
" name=\"Test Result with Operator Alias\",\n",
7474
" operator_id=\"secondary_operator\"\n",
7575
")\n",
7676
"\n",
@@ -100,7 +100,7 @@
100100
"retrieved_operator_id = retrieved_session.operator_id\n",
101101
"operator_details = metadata_store_client.get_operator(retrieved_operator_id)\n",
102102
"\n",
103-
"print(f\"The name of the operator for the session: {operator_details.operator_name}\")"
103+
"print(f\"The name of the operator for the session: {operator_details.name}\")"
104104
]
105105
},
106106
{
@@ -217,7 +217,7 @@
217217
],
218218
"metadata": {
219219
"kernelspec": {
220-
"display_name": "ni-datastore-py3.11",
220+
"display_name": "ni-datastore-py3.14",
221221
"language": "python",
222222
"name": "python3"
223223
},
@@ -231,7 +231,7 @@
231231
"name": "python",
232232
"nbconvert_exporter": "python",
233233
"pygments_lexer": "ipython3",
234-
"version": "3.11.9"
234+
"version": "3.14.0"
235235
}
236236
},
237237
"nbformat": 4,

0 commit comments

Comments
 (0)