3

例として 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 ファイルを生成するために必要なステップです。

ありがとう!

4

1 に答える 1

2

試す

protoc -I ./ --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` ./your.proto

protoc 3.0 (C++ および python プラグイン) がインストールされていることを確認し、まだインストールしていない場合は grpcio で pip インストールを実行してください。

于 2016-08-18T17:14:30.813 に答える