以 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 文件的必要步骤。
谢谢!