Skip to content
This repository has been archived by the owner on Jan 26, 2018. It is now read-only.

Only build common protos with --grpc option for LRO. #109

Merged
merged 5 commits into from
Sep 12, 2016

Conversation

bjwatson
Copy link
Contributor

@bjwatson bjwatson commented Sep 7, 2016

Updates googleapis/google-cloud-python#1893 (comment)

grpc/grpc#8056 is a proposal to fix this issue in gRPC (FYI @jmuk)

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 7, 2016

@jmuk @garrettjonesgoogle @jskeet @vchudnov-g @pongad, do any of your languages have standalone googleapis-common-protos packages? If so, and if you're adding LRO service methods to it, please check in with me. I've been through a few battles with it already in Python, which might be relevant to you.

@codecov-io
Copy link

codecov-io commented Sep 7, 2016

Current coverage is 91.73% (diff: 75.00%)

Merging #109 into master will increase coverage by 0.03%

@@             master       #109   diff @@
==========================================
  Files             3          3          
  Lines           711        714     +3   
  Methods         150        150          
  Messages          0          0          
  Branches        111        113     +2   
==========================================
+ Hits            652        655     +3   
  Misses           59         59          
  Partials          0          0          

Powered by Codecov. Last update 498dfc7...cc1f8bc

} else {
args.push('--grpc_out=' + outDir);
if (!opts.buildCommonProtos ||
_.includes(COMMON_GRPC_PROTOS, protoPath)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this the path from the proto's rootdir (i.e. 'google/longrunning/operations.proto')?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's just the last element. pkg has the path.

@jmuk
Copy link
Contributor

jmuk commented Sep 7, 2016

This looks a bit weird, could be a bug of grpc tools for Python. Are there any bugs in grpc?
Might be worth filing a new one if not, and noted the link as a comment.

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 7, 2016

@jmuk Does gRPC codegen make the grpc imports conditional on actually using gRPC for other languages?

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 7, 2016

@jmuk I checked Ruby and saw that it generates the message and services in different files, which avoids this problem. @garrettjonesgoogle told me the same thing for Java, thanks to their rigid one-class-per-file policy.

@jmuk
Copy link
Contributor

jmuk commented Sep 7, 2016

That's right (although I didn't know what Java does). If Python generator needs to generate single file containing both message and service definition -- then, Python generator should add grpc import line conditionally.
To be clear, I'm not against this PR, this PR will be good under the current situation. I'm saying this situation would be better to be recognized by the grpc-python team too.

@jmuk jmuk mentioned this pull request Sep 7, 2016
@jskeet
Copy link

jskeet commented Sep 8, 2016

@bjwatson: Our "common types" (Google.Api.CommonProtos) package includes the LRO definition, but not any gRPC code for it. I'd anticipate putting that in a separate package which then depends on Google.Api.CommonProtos. At the moment, I don't think any of these packages are produced by the pipeline, although we may well want to change this at some point...

@garrettjonesgoogle
Copy link
Member

@bjwatson , java has google-grpc-common-protos, which is including the Operations Grpc generated code now.

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 8, 2016

@garrettjonesgoogle So do you have two packages for the Java common protos: one with just the messages, and one with the full gRPC build? Where can I find them?

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 8, 2016

@jskeet A potential problem with that approach is if the Google.Api.CommonProtos already has the LRO messages (like the Python googleapis-common-protos package does), and then the gRPC generated code attempts to duplicate the messages in another package that depends on Google.Api.CommonProtos (the Python gRPC compiler generates both messages and service methods in the same file for a given .proto).

@jskeet
Copy link

jskeet commented Sep 8, 2016

The gRPC proto plugin for C# only generates the services - we should be fine.

@garrettjonesgoogle
Copy link
Member

@bjwatson , we have a single package with both the common protos and the gRPC-generated class for Operations. http://search.maven.org/#artifactdetails%7Ccom.google.api.grpc%7Cgrpc-google-common-protos%7C0.0.9%7Cjar

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 8, 2016

@garrettjonesgoogle So googleapis-common-protos has been abandoned?

I assume you don't have any concerns about adding a gRPC dependency, because gRPC works fine with the Java version of GAE Standard, right?

@garrettjonesgoogle
Copy link
Member

@bjwatson Yes, the java repo googleapis-common-protos is abandoned now.

I haven't tried this with GAE standard; theoretically it shouldn't cause an issue to have dependencies that are unused (although if someone tried to use the gRPC dependency directly, I think it wouldn't work).

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 9, 2016

@garrettjonesgoogle I was having problems with our gcloud-python users on GAE Standard (e.g. googleapis/google-cloud-python#1893 (comment)), so I'm having to do more to make gRPC a soft dependency in the Python version of googleapis-common-protos.

Hopefully you don't run into the same problems. Has gcloud-java done a release yet that uses your new package? I ran into my issue promptly since I released a new version of the same package, and gcloud-python pulled it in.

@garrettjonesgoogle
Copy link
Member

@bjwatson google-cloud-java has had an indirect dependency on grpc through gax-java since April: googleapis/google-cloud-java@2cd4b0c - so, I'm guessing it hasn't been a problem.

@jskeet
Copy link

jskeet commented Sep 9, 2016

Including the gRPC dependency in C# would be less desirable, I think - it's a large package due to the native binaries involved, so anywhere you don't need it, you really don't want it. That said, if all the other platforms take that approach, there are benefits in consistency, and there are relatively few places you'd want the common protos without gRPC at the moment...

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 9, 2016

@jskeet The primary driver right now for this in Python and other languages is supporting Speech v1beta1. The AsyncRecognize method is the primary method for the API that we need to support, and it returns an LRO object. Our gcloud counterparts need the gRPC service methods for LRO to make this work.

There will probably also be other APIs that drive the need for LRO.

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 9, 2016

@garrettjonesgoogle That's good to hear. google-cloud-python has always had a soft dependency on gax-python, to avoid pulling in gRPC for HTTP1.1-only clients. Seems like Java doesn't have that requirement.

@jskeet
Copy link

jskeet commented Sep 9, 2016

@bjwatson: Yes, we need LRO in C# as well. The options are:

  • Include the LRO and IAM gRPC APIs within Google.Api.CommonProtos (required Grpc.Core dependency in Google.Api.CommonProtos).
  • Have separate Google.Longrunning and Google.Iam.V1 packages

We definitely need it one way or another; it's just which route we go down. But maybe that would be better discussion away from this PR.

@bjwatson
Copy link
Contributor Author

bjwatson commented Sep 9, 2016

@jskeet Sounds good. We've been wrestling with both LRO and IAM in the other languages, too. Your choice of venue to continue this conversation. :)

@bjwatson
Copy link
Contributor Author

@jmuk @geigerj I made your suggested changes, and fixed the code coverage error. PTAL

_.includes(COMMON_GRPC_PROTOS, protoPath)) {
if (language === 'python') {
// required per https://github.com/grpc/grpc/issues/7857
args.push('--grpc_python_out=' + outDir);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we decided not to do this in order to support GAE?

My understanding was that this required a more complex change to generate both gRPC and gRPC-less modules.

Copy link
Contributor

@geigerj geigerj Sep 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After offline discussion, I understand that this is actually an improvement over the current state of master, where every common proto is being built with the gRPC plugin (and hence is potentially GAE-incompatible).

@jmuk
Copy link
Contributor

jmuk commented Sep 12, 2016

LGTM, with a nit.

@geigerj
Copy link
Contributor

geigerj commented Sep 12, 2016

LGTM, although would like to get to a state without hand-edits as soon as we can to reduce the risk of accidents when regenerating the package.

@bjwatson
Copy link
Contributor Author

@geigerj Agreed. #112 covers this, and it would be a good idea to fix it before we do our next release of common-protos.

@bjwatson
Copy link
Contributor Author

@jmuk I fixed your nit. PTAL

@jmuk
Copy link
Contributor

jmuk commented Sep 12, 2016

LGTM

@bjwatson bjwatson merged commit 5763ff7 into googleapis:master Sep 12, 2016
@bjwatson bjwatson deleted the selective-grpc branch September 12, 2016 22:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants