Hydrospheredata / hydro-profiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect Proto conversion

KineticCookie opened this issue · comments

commented

MessageToDict used for Proto -> Domain object conversion skips default values. That results in failed object creation.

Example test:

from profiler.domain.model import ModelSignature
from profiler.protobuf.monitoring_manager_pb2 import ModelSignature as protoMS, ModelField, TensorShape
from google.protobuf.json_format import MessageToDict

def test_proto_parser():
    proto = protoMS(
        inputs = [
            ModelField(
                name="test",
                shape=TensorShape(dims=[1]),
                dtype="DT_INVALID",
                profile="NONE"
            )
        ],
    )
    pd = MessageToDict(proto)
    print(pd)
    sig = ModelSignature.parse_obj(pd)
    print(sig)

Current result:

E   pydantic.error_wrappers.ValidationError: 2 validation errors for ModelSignature
E   inputs -> 0 -> dtype
E     field required (type=value_error.missing)
E   inputs -> 0 -> profile
E     field required (type=value_error.missing)

Expected: no errors

commented

Need to add including_default_value_fields=True arg to MessageToDict