Skip to content

Commit

Permalink
fix: fix compatibility with protobuf python backend (#5222)
Browse files Browse the repository at this point in the history
  • Loading branch information
alaeddine-13 committed Sep 28, 2022
1 parent ad37bdd commit 3683fcc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions jina/serve/runtimes/gateway/http/models.py
Expand Up @@ -2,15 +2,17 @@
from datetime import datetime
from enum import Enum
from types import SimpleNamespace
from typing import Callable, Dict, List, Optional, Union
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Union

from docarray.document.pydantic_model import PydanticDocument, PydanticDocumentArray
from google.protobuf.descriptor import Descriptor, FieldDescriptor
from google.protobuf.pyext.cpp_message import GeneratedProtocolMessageType
from pydantic import BaseConfig, BaseModel, Field, create_model, root_validator

from jina.proto.jina_pb2 import DataRequestProto, JinaInfoProto, RouteProto, StatusProto

if TYPE_CHECKING:
from google.protobuf.pyext.cpp_message import GeneratedProtocolMessageType

PROTO_TO_PYDANTIC_MODELS = SimpleNamespace()
PROTOBUF_TO_PYTHON_TYPE = {
FieldDescriptor.TYPE_INT32: int,
Expand Down Expand Up @@ -97,7 +99,7 @@ def oneof_setter(cls, values):


def protobuf_to_pydantic_model(
protobuf_model: Union[Descriptor, GeneratedProtocolMessageType]
protobuf_model: Union[Descriptor, 'GeneratedProtocolMessageType']
) -> BaseModel:
"""
Converts Protobuf messages to Pydantic model for jsonschema creation/validattion
Expand Down

0 comments on commit 3683fcc

Please sign in to comment.