-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced internal encoders with message encoder calling public API (#767
) * Serialized all scalar data types for message_serializer with all tests passing. * Added array data types to message_serializer * Added enums and sub functions to message_serializer * Added messages and refactored message_serializer * Modified message_serializer to pass all the tests * Switched current serializer with message_serializer and removed sub functions calling it * Replaced test_message_serialzier with test_serializer * Fixed 'Mypy statis analysis' in message_serializer * Changed file names corresponding to it's functionality * Fixed naming issue * Changed 'test_serializer' to 'test_decoder' * Implemented encoder to reuse message types, renamed and reorder files * Fixed docstrings and reordered encoder. * [DRAFT] Message decoder (#780) Implemented decoder and moved helper functions to serialization_strategy. * Creates 2 messages per service, renamed message/fields, and reordered helper functions. * Deleted serialization_strategy with default_value * Deleted test_serializer * Deleted _message.py * Fixed type errors in test encoder/decoder and docstring * Renamed and cleaned helper functions, added initalize() in metadata. * Fixed sytleguide and type assignment. * Pass enum type in initialize() and moved it in ParameterMetadata * Changed EnumType to Enum * Changed isinstance() to type() in _create_enum_type_class * Add correct type hint to enum_type passing in initialize() and added helper functions for enums
- Loading branch information
1 parent
822eb37
commit aa99a84
Showing
16 changed files
with
778 additions
and
971 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/service/ni_measurement_plugin_sdk_service/_internal/parameter/_get_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Any | ||
|
||
from google.protobuf.descriptor_pb2 import FieldDescriptorProto | ||
from google.protobuf.type_pb2 import Field | ||
|
||
_TYPE_DEFAULT_MAPPING = { | ||
Field.TYPE_FLOAT: float(), | ||
Field.TYPE_DOUBLE: float(), | ||
Field.TYPE_INT32: int(), | ||
Field.TYPE_INT64: int(), | ||
Field.TYPE_UINT32: int(), | ||
Field.TYPE_UINT64: int(), | ||
Field.TYPE_BOOL: bool(), | ||
Field.TYPE_STRING: str(), | ||
Field.TYPE_ENUM: int(), | ||
} | ||
|
||
TYPE_FIELD_MAPPING = { | ||
Field.TYPE_FLOAT: FieldDescriptorProto.TYPE_FLOAT, | ||
Field.TYPE_DOUBLE: FieldDescriptorProto.TYPE_DOUBLE, | ||
Field.TYPE_INT32: FieldDescriptorProto.TYPE_INT32, | ||
Field.TYPE_INT64: FieldDescriptorProto.TYPE_INT64, | ||
Field.TYPE_UINT32: FieldDescriptorProto.TYPE_UINT32, | ||
Field.TYPE_UINT64: FieldDescriptorProto.TYPE_UINT64, | ||
Field.TYPE_BOOL: FieldDescriptorProto.TYPE_BOOL, | ||
Field.TYPE_STRING: FieldDescriptorProto.TYPE_STRING, | ||
Field.TYPE_ENUM: FieldDescriptorProto.TYPE_ENUM, | ||
Field.TYPE_MESSAGE: FieldDescriptorProto.TYPE_MESSAGE, | ||
} | ||
|
||
|
||
def get_type_default(type: Field.Kind.ValueType, repeated: bool) -> Any: | ||
"""Get the default value for the give type.""" | ||
if repeated: | ||
return list() | ||
return _TYPE_DEFAULT_MAPPING.get(type) |
180 changes: 0 additions & 180 deletions
180
packages/service/ni_measurement_plugin_sdk_service/_internal/parameter/_message.py
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
packages/service/ni_measurement_plugin_sdk_service/_internal/parameter/_serializer_types.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.