ni_measurement_plugin_sdk_service.measurement.client_support

Support functions for the Measurement Plug-In Client.

Classes

ParameterMetadata

Class that represents the metadata of parameters.

Functions

create_file_descriptor(service_name, output_metadata, ...)

Creates two message types in one file descriptor proto.

deserialize_parameters(parameter_metadata_dict, ...[, ...])

Deserialize parameter bytes into separate parameter values.

serialize_parameters(parameter_metadata_dict, ...)

Serialize parameter values into a parameter byte string.

Module Contents

class ni_measurement_plugin_sdk_service.measurement.client_support.ParameterMetadata[source]

Bases: NamedTuple

Class that represents the metadata of parameters.

display_name: str

The display name of the parameter.

type: google.protobuf.type_pb2.Field.Kind.ValueType

The datatype of the parameter represented by the gRPC field enum.

repeated: bool

Indicates whether the parameter is a scalar or 1D array.

True for 1D array and false for scalar.

default_value: Any

The default value of the parameter.

annotations: dict[str, str]

Represents a set of annotations on the type.

message_type: str = ''

The gRPC full name of the message type.

Required when ‘type’ is Kind.TypeMessage. Ignored for any other ‘type’.

field_name: str = ''

display_name in snake_case format.

enum_type: SupportedEnumType | None = None

Enum type of parameter

static initialize(display_name, type, repeated, default_value, annotations, message_type='', enum_type=None)[source]

Initialize ParameterMetadata with field_name.

Parameters:
  • display_name (str)

  • type (google.protobuf.type_pb2.Field.Kind.ValueType)

  • repeated (bool)

  • default_value (Any)

  • annotations (dict[str, str])

  • message_type (str)

  • enum_type (SupportedEnumType | None)

Return type:

ParameterMetadata

ni_measurement_plugin_sdk_service.measurement.client_support.create_file_descriptor(service_name, output_metadata, input_metadata, pool)[source]

Creates two message types in one file descriptor proto.

Parameters:
Return type:

None

ni_measurement_plugin_sdk_service.measurement.client_support.deserialize_parameters(parameter_metadata_dict, parameter_bytes, message_name, *, convert_paths=True)[source]

Deserialize parameter bytes into separate parameter values.

Parameters:
  • parameter_metadata_dict (dict[int, ni_measurement_plugin_sdk_service._internal.parameter.metadata.ParameterMetadata]) – Parameter metadata by ID.

  • parameter_byte – Byte string to deserialize.

  • message_name (str) – gRPC message name (e.g. f”{service_class}.Outputs”).

  • convert_paths (bool) – Specifies whether to convert path parameters to pathlib.Path.

  • parameter_bytes (bytes)

Returns:

Deserialized parameter values, ordered by ID.

Return type:

collections.abc.Sequence[Any]

ni_measurement_plugin_sdk_service.measurement.client_support.serialize_parameters(parameter_metadata_dict, parameter_values, message_name)[source]

Serialize parameter values into a parameter byte string.

Parameters:
  • parameter_metadata_dict (dict[int, ni_measurement_plugin_sdk_service._internal.parameter.metadata.ParameterMetadata]) – Parameter metadata by ID.

  • parameter_values (collections.abc.Sequence[Any]) – Parameter values to serialize, ordered by ID.

  • message_name (str) – gRPC message name (e.g. f”{service_class}.Configurations”).

Returns:

Serialized byte string containing parameter values.

Return type:

bytes