Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions docs/reference/ni-data-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ A **TestResult** represents a complete test session or test execution run for a
- `software_item_ids` (list of strings) - IDs of software used during testing
- `hardware_item_ids` (list of strings) - IDs of hardware used during testing
- `test_adapter_ids` (list of strings) - IDs of test adapters used
- `test_result_name` (string) - Human-readable name for the test run
- `name` (string) - Human-readable name for the test run
- `start_date_time` (timestamp) - When the test execution started
- `end_date_time` (timestamp) - When the test execution finished
- `outcome` (enum) - Overall test result (PASSED, FAILED, INDETERMINATE, UNSPECIFIED)
- `link` (string) - Optional link to additional resources
- `extensions` (dict) - Custom key-value pairs for additional metadata
- `schema_id` (string) - ID of the schema for extension validation
- `error_information` (ErrorInformation) - Error details if test result failed

**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.

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

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

Expand Down
15 changes: 8 additions & 7 deletions docs/reference/ni-metadata-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ An **Operator** represents a person who performs tests or operates test equipmen

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

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

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

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

**Fields:**
- `schema_id` (string) - Unique identifier for the schema
- `id` (string) - Unique identifier for the schema
- `schema` (string) - The schema definition itself (JSON Schema format)

**Real-world examples**:
Expand All @@ -198,7 +199,7 @@ An **Extension Schema** defines the structure and validation rules for custom ex
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.

**Fields:**
- `alias_name` (string) - The registered alias name for the metadata instance
- `name` (string) - The registered alias name for the metadata instance
- `target_type` (enum) - The type of the aliased metadata instance (see `AliasTargetType` enum)
- `target_id` (string) - The unique identifier for the aliased metadata instance

Expand Down
72 changes: 48 additions & 24 deletions docs/reference/using-measurement-data-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ The typical measurement data workflow follows this sequence:
2. [**Test Execution Phase**](#test-execution-phase) - Create test sessions and publish data
3. [**Analysis Phase**](#analysis-phase) - Query and analyze results

## **Required Imports**

Before using the services, import the necessary classes and types:

```python
from datetime import datetime
from ni.datastore.data import DataStoreClient
from ni.datastore.metadata import MetadataStoreClient
from ni.datastore.data._types import TestResult, Step
from ni.datastore.metadata._types import (
Operator, TestStation, HardwareItem, SoftwareItem,
Uut, UutInstance, TestDescription, Test, TestAdapter
)
from ni.measurements.data.v1.data_store_pb2 import Outcome
from nitypes.scalar import Scalar
from nitypes.vector import Vector
from nitypes.waveform import AnalogWaveform
```

## **Setup Phase**

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

mike_id = metadata_store_client.create_operator(Operator(
operator_name="Mike Chen",
name="Mike Chen",
role="Senior Technician",
schema_id=schema_id,
extensions={
Expand All @@ -55,7 +74,7 @@ Define the physical locations where testing occurs:
```python
# Create test stations
station_a1_id = metadata_store_client.create_test_station(TestStation(
test_station_name="Station_A1",
name="Station_A1",
asset_identifier="STA-001",
schema_id=schema_id,
extensions={
Expand All @@ -65,7 +84,7 @@ station_a1_id = metadata_store_client.create_test_station(TestStation(
))

rf_lab_id = metadata_store_client.create_test_station(TestStation(
test_station_name="RF_Lab_Bench_1",
name="RF_Lab_Bench_1",
asset_identifier="RFL-001",
schema_id=schema_id,
extensions={
Expand Down Expand Up @@ -152,7 +171,7 @@ power_supply_uut = Uut(
"efficiency": ">90%"
}
)
power_supply_uut_id = metadata_store_client.create_uut(uut)
power_supply_uut_id = metadata_store_client.create_uut(power_supply_uut)
```

#### **UUT Instances (Physical Devices)**
Expand All @@ -179,7 +198,7 @@ Create test specifications and procedures:
# Create comprehensive test suites
power_test_desc_id = metadata_store_client.create_test_description(TestDescription(
uut_id=power_supply_uut_id,
test_description_name="Power Supply Validation Suite",
name="Power Supply Validation Suite",
schema_id=schema_id,
extensions={
"version": "v2.1",
Expand All @@ -192,7 +211,7 @@ power_test_desc_id = metadata_store_client.create_test_description(TestDescripti
```python
# Create specific test procedures
voltage_test_id = metadata_store_client.create_test(Test(
test_name="DC Voltage Accuracy Test",
name="DC Voltage Accuracy Test",
description="Measures DC voltage accuracy across 5V, 12V, and 24V outputs",
schema_id=schema_id,
extensions={
Expand All @@ -202,7 +221,7 @@ voltage_test_id = metadata_store_client.create_test(Test(
))

load_test_id = metadata_store_client.create_test(Test(
test_name="Load Regulation Test",
name="Load Regulation Test",
description="Tests voltage stability under varying load conditions",
schema_id=schema_id,
extensions={
Expand Down Expand Up @@ -258,7 +277,7 @@ metadata_store_client.create_alias(
metadata_store_client.create_alias(
alias_name="Current_PowerSupply_Design",
alias_target=power_supply_uut
))
)
```

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

load_step_id = data_store_client.create_step(Step(
test_result_id=test_result_id,
test_id=load_test_id,
step_name="Load Regulation Test",
step_type="Measurement",
name="Load Regulation Test",
type="Measurement",
notes="Variable load from 0% to 100% rated current"
))
```
Expand All @@ -330,15 +349,15 @@ temperature = Scalar(value=23.5, units="DegC")
data_store_client.publish_condition(
condition_name="Temperature",
type="Environment",
value=temperature
value=temperature,
step_id=voltage_step_id
)

humidity = Scalar(value=45.2, units="%RH")
data_store_client.publish_condition(
condition_name="Humidity",
type="Environment",
value=humidity
value=humidity,
step_id=voltage_step_id
)
```
Expand Down Expand Up @@ -483,10 +502,10 @@ Access the actual measured values:
for measurement in measurements:
if measurement.data_type == "type.googleapis.com/ni.protobuf.types.Vector":
value = data_store_client.read_data(measurement, expected_type=Vector)
print(f"{measurement.measurement_name}: {value}")
else if measurement.data_type == "type.googleapis.com/ni.protobuf.types.DoubleAnalogWaveform":
waveform = data_store_client.read_data(measurement, expected_type=DoubleAnalogWaveform)
print(f"{measurement.measurement_name}: {len(waveform.samples)} samples")
print(f"{measurement.name}: {value}")
elif measurement.data_type == "type.googleapis.com/ni.protobuf.types.DoubleAnalogWaveform":
waveform = data_store_client.read_data(measurement, expected_type=AnalogWaveform)
print(f"{measurement.name}: {len(waveform.raw_data)} samples")
```

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

for instance in uut_instances:
measurements = data_store_client.query_measurements(
f"$filter=TestResultId eq {instance.uut_instance_id} and Name eq '5V Output Voltage'"
# Get test results for this UUT instance
test_results = data_store_client.query_test_results(
f"$filter=UutInstanceId eq '{instance.id}'"
)
# Analyze voltage accuracy trends...
for test_result in test_results:
measurements = data_store_client.query_measurements(
f"$filter=TestResultId eq '{test_result.id}' and Name eq '5V Output Voltage'"
)
# Analyze voltage accuracy trends...
```

#### **Equipment Performance Analysis**
Expand Down
12 changes: 6 additions & 6 deletions examples/notebooks/alias/alias.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"from ni.datastore.metadata import MetadataStoreClient, Operator\n",
"\n",
"metadata_store_client = MetadataStoreClient()\n",
"operatorOne = Operator(operator_name=\"Jane Doe\")\n",
"operatorTwo = Operator(operator_name=\"John Smith\")\n",
"operatorOne = Operator(name=\"Jane Doe\")\n",
"operatorTwo = Operator(name=\"John Smith\")\n",
"\n",
"metadata_store_client.create_operator(operatorOne)\n",
"metadata_store_client.create_operator(operatorTwo)"
Expand Down Expand Up @@ -70,7 +70,7 @@
"from ni.datastore.data import DataStoreClient, TestResult\n",
"\n",
"test_result = TestResult(\n",
" test_result_name=\"Test Result with Operator Alias\",\n",
" name=\"Test Result with Operator Alias\",\n",
" operator_id=\"secondary_operator\"\n",
")\n",
"\n",
Expand Down Expand Up @@ -100,7 +100,7 @@
"retrieved_operator_id = retrieved_session.operator_id\n",
"operator_details = metadata_store_client.get_operator(retrieved_operator_id)\n",
"\n",
"print(f\"The name of the operator for the session: {operator_details.operator_name}\")"
"print(f\"The name of the operator for the session: {operator_details.name}\")"
]
},
{
Expand Down Expand Up @@ -217,7 +217,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "ni-datastore-py3.11",
"display_name": "ni-datastore-py3.14",
"language": "python",
"name": "python3"
},
Expand All @@ -231,7 +231,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.14.0"
}
},
"nbformat": 4,
Expand Down
Loading