Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions docs/reference/using-measurement-data-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,13 @@ Start each test session by creating a **TestResult**:
```python
# Create a test result for this test session
test_result_id = data_store_client.create_test_result(TestResult(
name="PowerSupply PS-2024-001456 Validation",
uut_instance_id=uut_instance_id,
operator_id=sarah_id, # or use alias: "Lead_Test_Engineer"
test_station_id=station_a1_id,
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
name="PowerSupply PS-2024-001456 Validation",
schema_id=schema_id,
extension={
"test_operator_notes": "First production unit validation",
Expand All @@ -302,17 +302,17 @@ Organize measurements into logical **Steps**:
```python
# Create test steps within the test result
voltage_step_id = data_store_client.create_step(Step(
name="DC Voltage Accuracy Check",
test_result_id=test_result_id,
test_id=voltage_test_id,
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(
name="Load Regulation Test",
test_result_id=test_result_id,
test_id=load_test_id,
name="Load Regulation Test",
type="Measurement",
notes="Variable load from 0% to 100% rated current"
))
Expand Down
10 changes: 5 additions & 5 deletions examples/notebooks/query/publish_sample_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@
"\n",
"# Use aliases instead of IDs for better readability and maintenance\n",
"power_test_result = TestResult(\n",
" name=\"Power Supply Test v2.1\",\n",
" uut_instance_id=ALIAS_UUT_INSTANCE_PS1,\n",
" operator_id=ALIAS_OPERATOR_ALEX,\n",
" test_station_id=ALIAS_STATION_A1,\n",
" software_item_ids=[ALIAS_SOFTWARE_PYTHON],\n",
" hardware_item_ids=[ALIAS_DMM, ALIAS_SCOPE],\n",
" name=\"Power Supply Test v2.1\"\n",
")\n",
"ps_test_result_id = data_store_client.create_test_result(power_test_result)\n",
"\n",
Expand Down Expand Up @@ -337,12 +337,12 @@
"# Scenario 2: Audio Amplifier Test\n",
"print(\"\\n📋 Creating Audio Amplifier test...\")\n",
"amplifier_test_result = TestResult(\n",
" name=\"Audio Amplifier Test v1.3\",\n",
" uut_instance_id=ALIAS_UUT_INSTANCE_AMP1,\n",
" operator_id=ALIAS_OPERATOR_JORDAN,\n",
" test_station_id=ALIAS_STATION_B2,\n",
" software_item_ids=[ALIAS_SOFTWARE_PYTHON],\n",
" hardware_item_ids=[ALIAS_DMM, ALIAS_SCOPE],\n",
" name=\"Audio Amplifier Test v1.3\"\n",
")\n",
"amp_test_result_id = data_store_client.create_test_result(amplifier_test_result)\n",
"\n",
Expand Down Expand Up @@ -422,12 +422,12 @@
"# Scenario 3: Additional Power Supply Test (second unit)\n",
"print(\"\\n📋 Creating second Power Supply test...\")\n",
"power_test_2 = TestResult(\n",
" name=\"Power Supply Test v2.1\",\n",
" uut_instance_id=ALIAS_UUT_INSTANCE_PS2, # Second power supply unit\n",
" operator_id=ALIAS_OPERATOR_TAYLOR,\n",
" test_station_id=ALIAS_STATION_C3,\n",
" software_item_ids=[ALIAS_SOFTWARE_PYTHON],\n",
" hardware_item_ids=[ALIAS_DMM, ALIAS_SCOPE],\n",
" name=\"Power Supply Test v2.1\"\n",
")\n",
"ps_test_2_result_id = data_store_client.create_test_result(power_test_2)\n",
"\n",
Expand Down Expand Up @@ -535,7 +535,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "ni-datastore-py3.10",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -549,7 +549,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.11.7"
Comment thread
mjohanse-emr marked this conversation as resolved.
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"\n",
"data_store_client = DataStoreClient()\n",
"test_result = TestResult(\n",
" name=\"voltage regulator waveforms\",\n",
" uut_instance_id=uut_instance_id,\n",
" operator_id=ALIAS_JAMES_BOWERY,\n",
" test_station_id=ALIAS_TEST_STATION_12,\n",
Expand All @@ -119,7 +120,6 @@
" ALIAS_SOFTWARE_ITEM_PYTHON_3_12,\n",
" ],\n",
" hardware_item_ids=[ALIAS_HARDWARE_ITEM_PXIe_5171],\n",
" name=\"voltage regulator waveforms\",\n",
")\n",
"test_result_id = data_store_client.create_test_result(test_result)\n"
]
Expand Down Expand Up @@ -296,7 +296,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "ni-datastore-py3.10",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -310,7 +310,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.11.7"
Comment thread
mjohanse-emr marked this conversation as resolved.
}
},
"nbformat": 4,
Expand Down
34 changes: 17 additions & 17 deletions src/ni/datastore/data/_types/_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class Step:
"""

__slots__ = (
"name",
"id",
"parent_step_id",
"test_result_id",
"test_id",
"name",
"step_type",
"notes",
"start_date_time",
Expand All @@ -52,12 +52,12 @@ def extension(self) -> MutableMapping[str, str]:

def __init__(
self,
name: str,
*,
id: str = "",
parent_step_id: str = "",
test_result_id: str = "",
test_id: str = "",
name: str = "",
step_type: str = "",
notes: str = "",
start_date_time: ht.datetime | None = None,
Expand All @@ -71,28 +71,28 @@ def __init__(
"""Initialize a Step instance.

Args:
id: Unique identifier for the step.
parent_step_id: ID of the parent step if this is a nested step.
test_result_id: ID of the test result this step belongs to.
test_id: ID of the test associated with this step.
name: Human-readable name of the step.
step_type: Type or category of the step.
notes: Additional notes or comments about the step.
start_date_time: The start date and time of the step execution.
end_date_time: The end date and time of the step execution.
link: Optional link to external resources for this step.
extension: Additional extension attributes as key-value pairs.
schema_id: ID of the extension schema for validating extensions.
error_information: Error or exception information in case of
id (optional): Unique identifier for the step.
parent_step_id (optional): ID of the parent step if this is a nested step.
test_result_id (optional): ID of the test result this step belongs to.
test_id (optional): ID of the test associated with this step.
step_type (optional): Type or category of the step.
notes (optional): Additional notes or comments about the step.
start_date_time (optional): The start date and time of the step execution.
end_date_time (optional): The end date and time of the step execution.
link (optional): Optional link to external resources for this step.
extension (optional): Additional extension attributes as key-value pairs.
schema_id (optional): ID of the extension schema for validating extensions.
error_information (optional): Error or exception information in case of
step failure.
outcome: The outcome of the step (PASSED, FAILED,
outcome (optional): The outcome of the step (PASSED, FAILED,
INDETERMINATE, or UNSPECIFIED).
"""
self.name = name
self.id = id
self.parent_step_id = parent_step_id
self.test_result_id = test_result_id
self.test_id = test_id
self.name = name
self.step_type = step_type
self.notes = notes
self.start_date_time = start_date_time
Expand All @@ -107,11 +107,11 @@ def __init__(
def from_protobuf(step_proto: StepProto) -> "Step":
"""Create a Step instance from a protobuf Step message."""
step = Step(
name=step_proto.name,
id=step_proto.id,
parent_step_id=step_proto.parent_step_id,
test_result_id=step_proto.test_result_id,
test_id=step_proto.test_id,
name=step_proto.name,
step_type=step_proto.step_type,
notes=step_proto.notes,
start_date_time=(
Expand Down
38 changes: 19 additions & 19 deletions src/ni/datastore/data/_types/_test_result.py
Comment thread
mjohanse-emr marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class TestResult:
"""

__slots__ = (
"name",
"id",
"uut_instance_id",
"operator_id",
Expand All @@ -37,7 +38,6 @@ class TestResult:
"_software_item_ids",
"_hardware_item_ids",
"_test_adapter_ids",
"name",
"start_date_time",
"end_date_time",
"outcome",
Expand Down Expand Up @@ -69,6 +69,7 @@ def extension(self) -> MutableMapping[str, str]:

def __init__(
self,
name: str,
*,
id: str = "",
uut_instance_id: str = "",
Expand All @@ -78,7 +79,6 @@ def __init__(
software_item_ids: Iterable[str] | None = None,
hardware_item_ids: Iterable[str] | None = None,
test_adapter_ids: Iterable[str] | None = None,
name: str = "",
start_date_time: ht.datetime | None = None,
end_date_time: ht.datetime | None = None,
outcome: Outcome = Outcome.UNSPECIFIED,
Expand All @@ -90,25 +90,26 @@ def __init__(
"""Initialize a TestResult instance.

Args:
id: Unique identifier for the test result.
uut_instance_id: ID of the UUT instance that was tested.
operator_id: ID of the operator who ran the test.
test_station_id: ID of the test station used.
test_description_id: ID of the test description that was executed.
software_item_ids: IDs of software items used in the test.
hardware_item_ids: IDs of hardware items used in the test.
test_adapter_ids: IDs of test adapters used in the test.
name: Human-readable name for the test result.
start_date_time: The start date and time of the test execution.
end_date_time: The end date and time of the test execution.
outcome: The outcome of the test execution (PASSED, FAILED,
id (optional): Unique identifier for the test result.
uut_instance_id (optional): ID of the UUT instance that was tested.
operator_id (optional): ID of the operator who ran the test.
test_station_id (optional): ID of the test station used.
test_description_id (optional): ID of the test description that was executed.
software_item_ids (optional): IDs of software items used in the test.
hardware_item_ids (optional): IDs of hardware items used in the test.
test_adapter_ids (optional): IDs of test adapters used in the test.
start_date_time (optional): The start date and time of the test execution.
end_date_time (optional): The end date and time of the test execution.
outcome (optional): The outcome of the test execution (PASSED, FAILED,
INDETERMINATE, or UNSPECIFIED).
link: Optional link to external resources for this test result.
extension: Additional extension attributes as key-value pairs.
schema_id: ID of the extension schema for validating extensions.
error_information: Error or exception information in case of
link (optional): Optional link to external resources for this test result.
extension (optional): Additional extension attributes as key-value pairs.
schema_id (optional): ID of the extension schema for validating extensions.
error_information (optional): Error or exception information in case of
test result failure.
"""
self.name = name
self.id = id
self.uut_instance_id = uut_instance_id
self.operator_id = operator_id
Expand All @@ -123,7 +124,6 @@ def __init__(
self._test_adapter_ids: MutableSequence[str] = (
list(test_adapter_ids) if test_adapter_ids is not None else []
)
self.name = name
self.start_date_time = start_date_time
self.end_date_time = end_date_time
self.outcome = outcome
Expand All @@ -136,6 +136,7 @@ def __init__(
def from_protobuf(test_result_proto: TestResultProto) -> "TestResult":
"""Create a TestResult instance from a protobuf TestResult message."""
test_result = TestResult(
name=test_result_proto.name,
id=test_result_proto.id,
uut_instance_id=test_result_proto.uut_instance_id,
operator_id=test_result_proto.operator_id,
Expand All @@ -144,7 +145,6 @@ def from_protobuf(test_result_proto: TestResultProto) -> "TestResult":
software_item_ids=test_result_proto.software_item_ids,
hardware_item_ids=test_result_proto.hardware_item_ids,
test_adapter_ids=test_result_proto.test_adapter_ids,
name=test_result_proto.name,
start_date_time=(
hightime_datetime_from_protobuf(test_result_proto.start_date_time)
if test_result_proto.HasField("start_date_time")
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/test_publish_with_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ def test___waveform_with_all_metadata___publish___query_read_returns_correct_dat
# Metadata: TestResult
test_result_name = "sample test result"
test_result = TestResult(
name=test_result_name,
uut_instance_id=uut_instance_id,
operator_id=operator_id,
test_station_id=test_station_id,
test_description_id=test_description_id,
software_item_ids=software_item_ids,
hardware_item_ids=hardware_item_ids,
test_adapter_ids=test_adapter_ids,
name=test_result_name,
link="Test Result Link",
extension={"tr1": "one", "tr2": "two"},
schema_id=schema_id,
Expand All @@ -169,10 +169,10 @@ def test___waveform_with_all_metadata___publish___query_read_returns_correct_dat
# Data: Step
parent_step = Step(name="Parent Step")
step = Step(
name="Step Name",
parent_step_id=parent_step.id,
test_result_id=test_result_id,
test_id=test_id,
name="Step Name",
step_type="Step Type",
notes="Step Notes",
link="Step Link",
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/data/test_create_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def test___create_step___calls_data_store_service_client(
mocked_data_store_service_client: NonCallableMock,
) -> None:
step = Step(
name="step_name",
id="step_id",
parent_step_id="parent_step_id",
test_result_id="test_result",
test_id="test_id",
name="step_name",
step_type="step_type",
notes="step_notes",
)
Expand All @@ -47,6 +47,7 @@ def test___create_test_result___calls_data_store_service_client(
mocked_data_store_service_client: NonCallableMock,
) -> None:
test_result = TestResult(
name="test_result_name",
id="test_result_id",
uut_instance_id="uut_instance_id",
operator_id="operator_id",
Expand All @@ -55,7 +56,6 @@ def test___create_test_result___calls_data_store_service_client(
software_item_ids=[],
hardware_item_ids=[],
test_adapter_ids=[],
name="test_result_name",
)
expected_response = CreateTestResultResponse(test_result_id="response_id")
mocked_data_store_service_client.create_test_result.return_value = expected_response
Expand Down