【发布时间】:2016-12-22 06:18:55
【问题描述】:
以 incepetion_inference.proto 为例,我尝试使用以下命令重新生成 inception_inference.pb2.py 文件:
protoc inception_inference.proto --python_out=./
将新生成的文件 inception_inference.pb2.py 与最初从编译生成的文件进行比较,除了许可证通知之外,它是相同的,并且底部包含:
import abc
import six
from grpc.beta import implementations as beta_implementations
from grpc.framework.common import cardinality
from grpc.framework.interfaces.face import utilities as face_utilities
class BetaInceptionServiceServicer(six.with_metaclass(abc.ABCMeta, object)):
"""<fill me in later!>"""
@abc.abstractmethod
def Classify(self, request, context):
raise NotImplementedError()
class BetaInceptionServiceStub(six.with_metaclass(abc.ABCMeta, object)):
"""The interface to which stubs will conform."""
@abc.abstractmethod
def Classify(self, request, timeout):
等等等等……
我猜 Bazel 构建系统的某些部分将其注入到 .pb2.py 文件中,但我找不到这是在哪里完成的。
有人知道如何正确地重新生成这个文件吗?显然,理解这是生成我自己的 .proto 文件的必要步骤。
谢谢!
【问题讨论】:
-
对于每个 proto 文件都有一个 proto_library BUILD 目标,正确的方法是 bazel 构建该目标
-
是的,在这种情况下: serving_proto_library( name = "inception_inference_proto", srcs = ["inception_inference.proto"], has_services = 1, cc_api_version = 2, cc_grpc_version = 1, ) 如上所述,重新生成不能开箱即用。
-
你试过
bazel build ...:inception_inference_proto吗?
标签: tensorflow protocol-buffers bazel tensorflow-serving