Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Code Generator bug #12907

Closed
abaldeva opened this issue Oct 9, 2017 · 3 comments
Closed

Python Code Generator bug #12907

abaldeva opened this issue Oct 9, 2017 · 3 comments

Comments

@abaldeva
Copy link

abaldeva commented Oct 9, 2017

What version of gRPC and what language are you using?

1.4.2 - python

What operating system (Linux, Windows, …) and version?

Windows 10.

What did you do?

Invoked following command line
E:\work\experimental\grpc-example\bin\protoc.exe --proto_path=. --proto_path=E:\work\experimental\protobuf\3.3.2/src --grpc_out=E:\work\experimental\grpc-example\build\pc64\grpc-example\flattened/gen/python --plugin=protoc-gen-grpc=E:\work\experimental\grpc-example/bin/grpc_python_plugin.exe component\greeter\greeterslave_grpcservice.proto

What did you expect to see?

Generate python service code

What did you see instead?

Error - component/greeter/greeterslave_grpcservice_pb2.py: Tried to insert into file that doesn't exist.

Note: The error goes away if I add
--python_out=E:\work\experimental\grpc-example\build\pc64\grpc-example\flattened/gen/python to the above command line.

I call this a bug because none of the other languages (I tested C++, C#, Ruby, JS, PHP) need --python_out arg when running grpc code generator plugin and I found no documentation reference that calls python as an exception.

Thanks.

@nathanielmanistaatgoogle
Copy link
Member

In our upcoming 1.7 release we've changed the code generator behavior to by default no longer insert into the _pb2.py file assumed to be present and available. In the meantime it sounds like the behavior you want is what is currently (pre-1.7) available using the (not-exactly-accurately-named) grpc_2_0 code generator flag. Take a look at this change to see the default behavior flip and this test to get a sense of how the code generator works in each case.

@abaldeva
Copy link
Author

Okay, I'll try it out with 1.7. Just one thing I'd like to add. The _pb2.py files were indeed present in the problematic case as I was running a 2-step code generation (first for protobuf and second for grpc).

Thanks.

@nathanielmanistaatgoogle
Copy link
Member

Regarding "The _pb2.py files were indeed present in the problematic case as I was running a 2-step code generation (first for protobuf and second for grpc)": I think that's expected, and counterintuitive and unhelpful, which is why we're changing the default to the more sensible behavior.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants