ni.datastore.data ================= .. py:module:: ni.datastore.data .. autoapi-nested-parse:: Public API for accessing the NI Data Store. Classes ------- .. autoapisummary:: ni.datastore.data.DataStoreClient ni.datastore.data.ErrorInformation ni.datastore.data.Moniker ni.datastore.data.Outcome ni.datastore.data.PublishedCondition ni.datastore.data.PublishedMeasurement ni.datastore.data.Step ni.datastore.data.TestResult Package Contents ---------------- .. py:class:: DataStoreClient(discovery_client = None, grpc_channel = None, grpc_channel_pool = None) Data store client for publishing and reading data. Initialize the DataStoreClient. :param discovery_client: An optional discovery client (recommended). :param grpc_channel: An optional data store gRPC channel. Providing this channel will bypass discovery service resolution of the data store. (Note: Reading data from a moniker will still always use a channel corresponding to the service location specified by that moniker.) :param grpc_channel_pool: An optional gRPC channel pool (recommended). .. py:attribute:: __slots__ :value: ('_closed', '_discovery_client', '_grpc_channel', '_grpc_channel_pool', '_data_store_client',... .. py:method:: __enter__() Enter the runtime context of the data store client. .. py:method:: __exit__(exc_type, exc_val, traceback) Exit the runtime context of the data store client. .. py:method:: close() Close the data store client and clean up resources that it owns. .. py:method:: publish_condition(name, condition_type, value, step_id) Publish a condition value to the data store. :param name: An identifier describing the condition value. For example, "Voltage" or "Temperature". :param condition_type: The type of this condition. For example, "Upper Limit", "Environment", or "Setup". :param value: The single value for this condition to publish on the test step. This should be a scalar value that can be converted to the appropriate protobuf scalar type. :param step_id: The ID of the step associated with this condition. This value is expected to be a parsable GUID. :returns: The condition id - the unique ID of the condition for referencing in queries :rtype: str .. py:method:: publish_condition_batch(name, condition_type, values, step_id) Publish a batch of N values for a condition to the data store. :param name: An identifier describing the condition values. For example, "Voltage" or "Temperature". :param condition_type: The type of this condition. For example, "Upper Limit", "Environment", or "Setup". :param values: The values for this condition across all publishes on the test step. This should be a Vector of N values. :param step_id: The ID of the step associated with this batch of condition values. This value is expected to be a parsable GUID. :returns: The condition id - the unique ID of the condition for referencing in queries :rtype: str .. py:method:: publish_measurement(name, value, step_id, timestamp = None, outcome = Outcome.UNSPECIFIED, error_information = None, hardware_item_ids = tuple(), test_adapter_ids = tuple(), software_item_ids = tuple(), notes = '') Publish a single measurement value associated with a test step. :param name: The name used for associating/grouping conceptually alike measurements across multiple publish iterations. For example, "Temperature" can be used for associating temperature readings across multiple iterations. :param value: The value of the measurement being published. Supported types: - Scalar: Single float, int, str or boolean - Vector: Array of float, int, str or boolean values - DoubleAnalogWaveform: Analog waveform with double precision - DoubleXYData: XY coordinate data with double precision - I16AnalogWaveform: Analog waveform with 16-bit integer precision - DoubleComplexWaveform: Complex waveform with double precision - I16ComplexWaveform: Complex waveform with 16-bit integer precision - DoubleSpectrum: Frequency spectrum data with double precision - DigitalWaveform: Digital waveform data :param step_id: The ID of the step associated with this measurement. This value is expected to be a parsable GUID. :param timestamp: The timestamp of the measurement. If None, the current time will be used. :param outcome: The outcome of the measurement (PASSED, FAILED, INDETERMINATE, or UNSPECIFIED). :param error_information: Error or exception information in case of measurement failure. :param hardware_item_ids: The IDs of the hardware items associated with this measurement. These values are expected to be parsable GUIDs or aliases. :param test_adapter_ids: The IDs of the test adapters associated with this measurement. These values are expected to be parsable GUIDs or aliases. :param software_item_ids: The IDs of the software items associated with this measurement. These values are expected to be parsable GUIDs or aliases. :param notes: Any notes to be associated with the captured measurement. :returns: The published measurement id. :rtype: str .. py:method:: publish_measurement_batch(name, values, step_id, timestamps = tuple(), outcomes = tuple(), error_information = tuple(), hardware_item_ids = tuple(), test_adapter_ids = tuple(), software_item_ids = tuple(), notes = '') Publish multiple scalar measurements at once for parametric sweeps. :param name: The name used for associating/grouping conceptually alike measurements across multiple publish iterations. For example, "Temperature" can be used for associating temperature readings across multiple iterations. :param values: The values of the (scalar) measurement being published across N iterations. :param step_id: The ID of the step associated with this measurement. This value is expected to be a parsable GUID. :param timestamps: The timestamps corresponding to the N iterations of batched measurement being published. Can be empty (no timestamp info), single value (applied to all), or N values (one per measurement). :param outcomes: The outcomes corresponding to the N iterations of batched measurement being published. Can be empty (no outcome info), single value (applied to all), or N values (one per measurement). :param error_information: The error information corresponding to the N iterations of batched measurement being published. Can be empty (no error info), single value (applied to all), or N values (one per measurement). :param hardware_item_ids: The IDs of the hardware items associated with this measurement. These values are expected to be parsable GUIDs or aliases. :param test_adapter_ids: The IDs of the test adapters associated with this measurement. These values are expected to be parsable GUIDs or aliases. :param software_item_ids: The IDs of the software items associated with this measurement. These values are expected to be parsable GUIDs or aliases. :param notes: Any notes to be associated with the published measurements. :returns: The ids of the published measurement ids. NOTE: Using a Sequence is for future flexibility. This sequence will currently always have a single measurement id returned. :rtype: Sequence[str] .. py:method:: read_data(moniker_source: ni.datastore.data._types._moniker.Moniker | ni.datastore.data._types._published_measurement.PublishedMeasurement | ni.datastore.data._types._published_condition.PublishedCondition, expected_type: Type[TRead]) -> TRead read_data(moniker_source: ni.datastore.data._types._moniker.Moniker | ni.datastore.data._types._published_measurement.PublishedMeasurement | ni.datastore.data._types._published_condition.PublishedCondition) -> object Read data published to the data store. :param moniker_source: The source from which to read data. Can be: - A Moniker (wrapper type) directly - A PublishedMeasurement (uses its moniker) - A PublishedCondition (uses its moniker) :param expected_type: Optional type to validate the returned data against. If provided, a TypeError will be raised if the actual data type doesn't match. :returns: The data retrieved from the data store. The return type depends on what was originally published: - Scalar measurements return as Vectors - Other types are returned as originally published If expected_type is specified, the return value is guaranteed to be of that type. :raises ValueError: If the moniker_source doesn't have a valid moniker. :raises TypeError: If expected_type is provided and the actual data type doesn't match. .. py:method:: create_step(step) Create a new step in the data store. A step is owned by a test result and is a logical grouping of published measurements and conditions. All measurements and conditions must be associated with a step. :param step: The metadata of the step to be created. :returns: The identifier of the created step. :rtype: str .. py:method:: get_step(step_id) Get the step associated with the given identifier. :param step_id: The identifier of the desired step. :returns: The metadata of the requested step. :rtype: Step .. py:method:: get_measurement(measurement_id) Get the measurement associated with the given identifier. :param measurement_id: The identifier of the desired measurement. :returns: The metadata of the requested measurement. :rtype: PublishedMeasurement .. py:method:: get_condition(condition_id) Get the condition associated with the given identifier. :param condition_id: The identifier of the desired condition. :returns: The metadata of the requested condition. :rtype: PublishedCondition .. py:method:: create_test_result(test_result) Create a test result object for publishing measurements. Once a test result is created, you can publish an arbitrary number of measurements and conditions to a step which is owned by the test result. :param test_result: The metadata of the test result to be created. :returns: The test result ID. Generated if not specified in the request. :rtype: str .. py:method:: get_test_result(test_result_id) Get the test result associated with the given identifier. :param test_result_id: The ID of the desired test result. This value is expected to be a parsable GUID. :returns: The TestResult object that corresponds to the requested ID. :rtype: TestResult .. py:method:: query_conditions(odata_query = '') Query conditions using OData query syntax. :param odata_query: An OData query string. Example: "$filter=name eq 'Value'". An empty string will return all conditions. $expand, $count, and $select are not supported. For more information, see https://learn.microsoft.com/en-us/odata/concepts/ queryoptions-overview. :returns: The list of matching conditions. Each item contains a moniker for retrieving the condition measurements, as well as the metadata associated with the condition. :rtype: Sequence[PublishedCondition] .. py:method:: query_measurements(odata_query = '') Query measurements using OData query syntax. :param odata_query: An OData query string. Example: "$filter=name eq 'Value'". An empty string will return all measurements. $expand, $count, and $select are not supported. For more information, see https://learn.microsoft.com/en-us/odata/ concepts/queryoptions-overview. :returns: The list of matching measurements. Each item contains a moniker for retrieving the measurement, as well as the metadata associated with the measurement. :rtype: Sequence[PublishedMeasurement] .. py:method:: query_test_results(odata_query = '') Query test results using OData query syntax. :param odata_query: An OData query string. Example: "$filter=name eq 'Value'". An empty string will return all test results. $expand, $count, and $select are not supported. For more information, see https://learn.microsoft.com/en-us/odata/ concepts/queryoptions-overview. :returns: The list of matching test results. Each item contains the metadata associated with the test result, including test result ID, name, timestamps, and other properties. :rtype: Sequence[TestResult] .. py:method:: query_steps(odata_query = '') Query for steps matching the given OData query. :param odata_query: An OData query string. Example: "$filter=name eq 'Value'". An empty string will return all steps. $expand, $count, and $select are not supported. For more information, see https://learn.microsoft.com/en-us/odata/concepts/ queryoptions-overview. :returns: The list of steps that match the query. :rtype: Sequence[Step] .. py:class:: ErrorInformation(*, error_code = 0, message = '', source = '') Represents error or exception information in case of measurement failure. An ErrorInformation contains an error code, descriptive message, and source information to help identify and diagnose issues during measurement execution. Initialize an ErrorInformation instance. :param error_code: The numeric error code associated with the error. :param message: A descriptive message explaining the error. :param source: The source or location where the error occurred. .. py:attribute:: __slots__ :value: ('error_code', 'message', 'source') .. py:attribute:: error_code :value: 0 .. py:attribute:: message :value: '' .. py:attribute:: source :value: '' .. py:method:: from_protobuf(error_information_proto) :staticmethod: Create an ErrorInformation instance from a protobuf ErrorInformation message. .. py:method:: to_protobuf() Convert this ErrorInformation instance to a protobuf ErrorInformation message. .. py:method:: __eq__(other) Determine equality. .. py:method:: __str__() Return a string representation of the ErrorInformation. .. py:class:: Moniker(*, service_location = '', data_source = '', data_instance = 0) Represents a data moniker for retrieving published data. A moniker provides the necessary information to locate and retrieve data from the data store, including the service location, data source, and data instance identifiers. Initialize a Moniker instance. :param service_location: The location of the service that stores the data. :param data_source: The identifier for the data source. :param data_instance: The instance number of the data. .. py:attribute:: __slots__ :value: ('service_location', 'data_source', 'data_instance') .. py:attribute:: service_location :value: '' .. py:attribute:: data_source :value: '' .. py:attribute:: data_instance :value: 0 .. py:method:: from_protobuf(moniker_proto) :staticmethod: Create a Moniker instance from a protobuf Moniker message. .. py:method:: to_protobuf() Convert this Moniker instance to a protobuf Moniker message. .. py:method:: __eq__(other) Determine equality. .. py:method:: __str__() Return a string representation of the Moniker. .. py:class:: Outcome Bases: :py:obj:`enum.IntEnum` Represents the outcome of a measurement or test operation. The Outcome enum indicates whether a measurement or test passed, failed, or had an indeterminate result. Initialize self. See help(type(self)) for accurate signature. .. py:attribute:: UNSPECIFIED The outcome is not specified or unknown. .. py:attribute:: PASSED The measurement or test passed successfully. .. py:attribute:: FAILED The measurement or test failed. .. py:attribute:: INDETERMINATE The measurement or test result is indeterminate or inconclusive. .. py:method:: from_protobuf(outcome_proto) :classmethod: Create an Outcome instance from a protobuf Outcome value. :param outcome_proto: The protobuf Outcome value. :returns: The corresponding Outcome enum value. :raises ValueError: If the protobuf value doesn't correspond to a known Outcome. .. py:method:: to_protobuf() Convert this Outcome instance to a protobuf Outcome value. :returns: The corresponding protobuf Outcome value. .. py:class:: PublishedCondition(*, moniker = None, id = '', name = '', condition_type = '', step_id = '', test_result_id = '') Represents a condition that has been published to the data store. A published condition contains metadata about a condition value that was published, including a moniker for data retrieval and associated metadata like condition name, type, and associated step/test result IDs. Initialize a PublishedCondition instance. :param moniker: The moniker of the condition that this value is associated with. This moniker returns a Vector when read. :param id: The unique identifier of the condition. This can be used to reference and find the condition in the data store. :param name: The name of the condition. :param condition_type: The type of the condition. For example, "Setup" or "Environment". :param step_id: The ID of the step with which this condition is associated. :param test_result_id: The ID of the test result with which this condition is associated. .. py:attribute:: __slots__ :value: ('moniker', 'id', 'name', 'condition_type', 'step_id', 'test_result_id') .. py:attribute:: moniker :value: None .. py:attribute:: id :value: '' .. py:attribute:: name :value: '' .. py:attribute:: condition_type :value: '' .. py:attribute:: step_id :value: '' .. py:attribute:: test_result_id :value: '' .. py:method:: from_protobuf(published_condition_proto) :staticmethod: Create a PublishedCondition instance from a protobuf PublishedCondition message. .. py:method:: to_protobuf() Convert this PublishedCondition instance to a protobuf PublishedCondition message. .. py:method:: __eq__(other) Determine equality. .. py:method:: __str__() Return a string representation of the PublishedCondition. .. py:class:: PublishedMeasurement(*, moniker = None, published_conditions = None, id = '', test_result_id = '', step_id = '', software_item_ids = None, hardware_item_ids = None, test_adapter_ids = None, name = '', value_type = '', notes = '', start_date_time = None, end_date_time = None, outcome = Outcome.UNSPECIFIED, parametric_index = 0, error_information = None) Represents a measurement that has been published to the data store. A published measurement contains the measurement data and the associated metadata (name, type, timestamps, outcome, hardware, software, and test adapter IDs). Initialize a PublishedMeasurement instance. :param moniker: The moniker of the measurement that this value is associated with. :param published_conditions: The published conditions associated with this measurement from the test step. :param id: The unique identifier of the measurement. This can be used to reference and find the measurement in the data store. :param test_result_id: The ID of the test result with which this measurement is associated. :param step_id: The ID of the step with which this measurement is associated. :param software_item_ids: The IDs of the software items associated with this measurement. :param hardware_item_ids: The IDs of the hardware items associated with this measurement. :param test_adapter_ids: The IDs of the test adapters associated with this measurement. :param name: The name of the measurement. :param value_type: The data type of the measurement value. :param notes: Additional notes or comments about the measurement. :param start_date_time: The start timestamp of the measurement. :param end_date_time: The end timestamp of the measurement. :param outcome: The outcome of the measurement (PASSED, FAILED, INDETERMINATE, or UNSPECIFIED). :param parametric_index: The index of this measurement in a parametric sweep operation. :param error_information: Error or exception information in case of measurement failure. .. py:attribute:: __slots__ :value: ('moniker', '_published_conditions', 'id', 'test_result_id', 'step_id', '_software_item_ids',... .. py:property:: published_conditions :type: MutableSequence[ni.datastore.data._types._published_condition.PublishedCondition] The published conditions associated with the published measurement. .. py:property:: software_item_ids :type: MutableSequence[str] The software item IDs associated with the published measurement. .. py:property:: hardware_item_ids :type: MutableSequence[str] The hardware item IDs associated with the published measurement. .. py:property:: test_adapter_ids :type: MutableSequence[str] The test adapter IDs associated with the published measurement. .. py:attribute:: moniker :value: None .. py:attribute:: id :value: '' .. py:attribute:: test_result_id :value: '' .. py:attribute:: step_id :value: '' .. py:attribute:: name :value: '' .. py:attribute:: value_type :value: '' .. py:attribute:: notes :value: '' .. py:attribute:: start_date_time :value: None .. py:attribute:: end_date_time :value: None .. py:attribute:: outcome .. py:attribute:: parametric_index :value: 0 .. py:attribute:: error_information :value: None .. py:method:: from_protobuf(published_measurement_proto) :staticmethod: Create a PublishedMeasurement instance from a protobuf PublishedMeasurement message. .. py:method:: to_protobuf() Convert this PublishedMeasurement instance to a protobuf PublishedMeasurement message. .. py:method:: __eq__(other) Determine equality. .. py:method:: __str__() Return a string representation of the PublishedMeasurement. .. py:class:: Step(*, id = '', parent_step_id = '', test_result_id = '', test_id = '', name = '', step_type = '', notes = '', start_date_time = None, end_date_time = None, link = '', extension = None, schema_id = '', error_information = None, outcome = Outcome.UNSPECIFIED) Information about a step into which measurements and conditions are published. Represents a hierarchical execution step within a test result that can contain measurements and conditions. Steps are linked to a test result and can be organized into hierarchical structures using parent_step_id. Each step has test execution time, metadata, and optional extensions for custom metadata. Initialize a Step instance. :param id: Unique identifier for the step. :param parent_step_id: ID of the parent step if this is a nested step. :param test_result_id: ID of the test result this step belongs to. :param test_id: ID of the test associated with this step. :param name: Human-readable name of the step. :param step_type: Type or category of the step. :param notes: Additional notes or comments about the step. :param start_date_time: The start date and time of the step execution. :param end_date_time: The end date and time of the step execution. :param link: Optional link to external resources for this step. :param extension: Additional extension attributes as key-value pairs. :param schema_id: ID of the extension schema for validating extensions. :param error_information: Error or exception information in case of step failure. :param outcome: The outcome of the step (PASSED, FAILED, INDETERMINATE, or UNSPECIFIED). .. py:attribute:: __slots__ :value: ('id', 'parent_step_id', 'test_result_id', 'test_id', 'name', 'step_type', 'notes',... .. py:property:: extension :type: MutableMapping[str, str] The extension of the step. .. py:attribute:: id :value: '' .. py:attribute:: parent_step_id :value: '' .. py:attribute:: test_result_id :value: '' .. py:attribute:: test_id :value: '' .. py:attribute:: name :value: '' .. py:attribute:: step_type :value: '' .. py:attribute:: notes :value: '' .. py:attribute:: start_date_time :value: None .. py:attribute:: end_date_time :value: None .. py:attribute:: link :value: '' .. py:attribute:: schema_id :value: '' .. py:attribute:: error_information :value: None .. py:attribute:: outcome .. py:method:: from_protobuf(step_proto) :staticmethod: Create a Step instance from a protobuf Step message. .. py:method:: to_protobuf() Convert this Step to a protobuf Step message. .. py:method:: __eq__(other) Determine equality. .. py:method:: __str__() Return a string representation of the Step. .. py:class:: TestResult(*, id = '', uut_instance_id = '', operator_id = '', test_station_id = '', test_description_id = '', software_item_ids = None, hardware_item_ids = None, test_adapter_ids = None, name = '', start_date_time = None, end_date_time = None, outcome = Outcome.UNSPECIFIED, link = '', extension = None, schema_id = '', error_information = None) Information about a test result. Represents the results of executing a test sequence, including metadata about the execution environment (UUT, operator, test station), test execution time, outcome, and associations with hardware/software components and test adapters. Each step which references measurement data and conditions is associated with a test result. Initialize a TestResult instance. :param id: Unique identifier for the test result. :param uut_instance_id: ID of the UUT instance that was tested. :param operator_id: ID of the operator who ran the test. :param test_station_id: ID of the test station used. :param test_description_id: ID of the test description that was executed. :param software_item_ids: IDs of software items used in the test. :param hardware_item_ids: IDs of hardware items used in the test. :param test_adapter_ids: IDs of test adapters used in the test. :param name: Human-readable name for the test result. :param start_date_time: The start date and time of the test execution. :param end_date_time: The end date and time of the test execution. :param outcome: The outcome of the test execution (PASSED, FAILED, INDETERMINATE, or UNSPECIFIED). :param link: Optional link to external resources for this test result. :param extension: Additional extension attributes as key-value pairs. :param schema_id: ID of the extension schema for validating extensions. :param error_information: Error or exception information in case of test result failure. .. py:attribute:: __slots__ :value: ('id', 'uut_instance_id', 'operator_id', 'test_station_id', 'test_description_id',... .. py:property:: software_item_ids :type: MutableSequence[str] The software item IDs associated with the test result. .. py:property:: hardware_item_ids :type: MutableSequence[str] The hardware item IDs associated with the test result. .. py:property:: test_adapter_ids :type: MutableSequence[str] The test adapter IDs associated with the test result. .. py:property:: extension :type: MutableMapping[str, str] The extension of the test result. .. py:attribute:: id :value: '' .. py:attribute:: uut_instance_id :value: '' .. py:attribute:: operator_id :value: '' .. py:attribute:: test_station_id :value: '' .. py:attribute:: test_description_id :value: '' .. py:attribute:: name :value: '' .. py:attribute:: start_date_time :value: None .. py:attribute:: end_date_time :value: None .. py:attribute:: outcome .. py:attribute:: link :value: '' .. py:attribute:: schema_id :value: '' .. py:attribute:: error_information :value: None .. py:method:: from_protobuf(test_result_proto) :staticmethod: Create a TestResult instance from a protobuf TestResult message. .. py:method:: to_protobuf() Convert this TestResult to a protobuf TestResult message. .. py:method:: __eq__(other) Determine equality. .. py:method:: __str__() Return a string representation of the TestResult.