GeezerVison is showing github.com — Adding generated Bigtable classes. by saicheems · Pull Request #22 · dhermes/gcloud-python-bigtable
Conversation
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@saicheems Can you explain what these are and what generated them and why they are needed given the existence of gcloud_bigtable._generated?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
These are intended to replace the gRPC generated code that currently is in gcloud_bigtable._generated, for some common use cases. They hide some gRPC features, like explicit timeouts and request objects for every call, and are backed by the GAX library -- not included in this PR -- which performs things like retrying, page-streaming, and possibly eventually other features that might be desired of the callables. We're hoping that this will reduce the amount of code that needs to be handwritten on top of the gRPC generated code. They were generated by our code generator, which is not yet on github.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Before continuing I should note that we are in the process of merging gcloud-python-bigtable into the main gcloud-python, however this one remains the upstream master until they are at parity.
- Is there a link to the GAX library?
- Does importing this work? The generated code assumed the
google namespace package would be available but it was more trouble than it was worth, so I re-wrote it. Right now the gcloud_bigtable.google package looks public to users of this library, but we'd rather hide it as an implementation detail. How hard will that be to put it in a different place?
- Do you still depend on the
protobuf PyPI package?
- Can you give some sample code explaining how to use this?
- Do you have any documentation? I'm fairly uncomfortable depending on something undocumented.
/cc @jgeewax @tseaver
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- GAX link will come later. I think this is intended only to get feedback on the public surface of the generated code, not to actually run or be merged; maybe Sai can comment?
- I think we'll reorganize the package names before sending a working pull request. Most likely we'll use a package named "generated.google". For non-manually veneered APIs (unlike this one), the generated code will be the public surface with nothing sitting on top -- not sure how this will play into package naming if we need manually veneered codegen to look private.
- Yes, we depend on the
protobuf PyPI package
- @saicheems / @anthmgoogle -- should we be including sample code at this point?
- The documentation story is still in the works, I think.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Right, GAX is still in the works - we'll update when available but it's not intended to be a part of this review.
@geigerj @anthmgoogle Maybe we can include the end to end example for demonstration purposes?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I think that makes sense -- it's not necessary intended to be the final sample code, but it should give some sense of how it might look.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I don't expect GAX to be part of this review. I'd expect it to be include-able as a PyPI package.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@dhermes Right, our intention is to eventually have it available as a package.
I'll include our end to end example.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
GitHub and PyPI are a great start to be part of the Python community
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@geigerj So the current most pressing need is just to review the API surface? (And the forthcoming example usage docs)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
For the owners of gcloud-python, this PR is not intended for merging. but we are looking for feedback and sign-off on the APi surface, and also details of the documentation and source code. In parallel we are working on a PR that will be mergable with all dependencies and layout issues resolved. But it will include these files. If these files need to be changed, we would like to iterate on any changes in this PR now.
For reference, there was a lot of good feedback on the Java equivalent of this that took a while to iterate through, so we would like to get going on the Python equivalent now to avoid a long delay when the mergable version is ready.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we strip out the link headers so that this is ".. field type is google.bigtable.admin.cluster.v1.CreaseClusterMetadata. The ..."
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 It may be a pain unless you have something that can easily parse it from the comments in the .proto definition.
If you can parse it, you should reformat in Sphinx / RsT format to link within the generated classes.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're working on improving the docs as we can right now, and have an issue tracking it.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I haven't read the code yet, but have gone through e2e.py. It is essentially identical to writing an application with the standard code generated by protoc (using grpc_python_plugin).
Maybe I'm misunderstanding what the goal was?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manual and updates to that file doesn't make sense?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is circular.
>>> import sys
>>> sys.setrecursionlimit(4)
>>> class A(object):
... @property
... def b(self):
... return self.b
...
>>> a = A()
>>> a.b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in b
RuntimeError: maximum recursion depth exceeded
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
"It is essentially identical to writing an application with the standard code generated by protoc (using grpc_python_plugin).Maybe I'm misunderstanding what the goal was?"
The code generator can take advantage of patterns and conventions in Google APis like page streaming. Unfortunately, BigTable is an atypical API that uses few standard patterns and is mostly custom methods. So the generator does not save as much user code as other APIs.
There should still be some benefits even in the absense of pattern use:
- There are still savings to initialization code.
- The callable pattern makes it more concise to use same advanced gRPC patterns.
- There is an editable doc site for each method (unlike gRPC/stubby) where we can get proto-doc by default, but we can add usage examples.
- As we detect client-side features in use by multiple APIs, new features can be added over time that can be auto-generated across languages.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this uses double quotes while the scopes below use single quotes. Why mix and match? ISTM that using %r or {!r} or repr() would be what you'd want to do, and all of those would produce single quotes for the string above.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The code generator can take advantage of patterns and conventions in Google APis like page streaming
There are three two (a, b) methods that use streaming but they seem to be identical.
There are still savings to initialization code.
Where? It seems to be identical, and calling many methods on stubs requires the same level of knowledge about the generated message classes (seems to occur when a property is itself a message).
The callable pattern makes it more concise to use same advanced gRPC patterns.
I'm not clear what you mean. Side-by-side:
# Veneer generated
cluster_pb = cluster_api.create_cluster(
name=zone_name, cluster_id=disp_name, cluster=cluster)
# Standard protoc generated (with gRPC plugin)
cluster_pb = cluster_stub.CreateCluster(
request_pb, timeout_seconds)
The only distinction is that the Veneer call constructs the request_pb for the user.
There is an editable doc site for each method (unlike gRPC/stubby) where we can get proto-doc by default, but we can add usage examples.
I'm not sure what you mean by this.
As we detect client-side features in use by multiple APIs, new features can be added over time that can be auto-generated across languages.
But the exact same can be said of the existing toolchain.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Some clarifications related to my earlier comment.
Page streaming what we call the pattern of List methods returning a page at a time and turning this into an idiomatic collection. Most APIs have some of these but bigtable does not.
The initialization saving is stuff the like the scopes relative to raw gRPC, not the per method stuff.
The advanced calling patterns I meant whether things like Async, chaining, batching, etc.
Regarding docs; gRPC and stubby methods cannot be extended in source form. So you can't go an add a language-speicific usage example to their doc cmments. That is possible with these wrappers.
Regarding future features, I'm not sure what you mean by existing toolchain. But if you mean gRPC, there are some features that cannot be added or unlikely to be added because they would depend on One Platform patterns or would need to depend on configuration outside the proto.
But overall it is acknowledged that the before and after on this particular API is not very different because of its atypical nature. It was much more evident in APIs like PubSub and Logging. We should discuss if that changes our strategy here.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Page streaming what we call the pattern of List methods
Gotcher. I get it now.
The initialization saving is stuff the like the scopes relative to raw gRPC, not the per method stuff.
There is no reason that the gRPC generator couldn't do this. Though (I asked elsewhere in this PR) I don't actually know where the scopes and the API endpoints come from.
The advanced calling patterns I meant whether things like Async, chaining, batching, etc.
Where does that come into play? Why wouldn't the gRPC / protobuf code support it?
Regarding docs; gRPC and stubby methods cannot be extended in source form. So you can't go an add a language-speicific usage example to their doc cmments. That is possible with these wrappers.
That is not very relevant. Most library devs are going to wrap the generated code into something else anyway.
Even if this code was easier to use, the fact that there are 3 distinct services is a reason enough to wrap the Bigtable APIs into something higher-level to make it easier on users. (In our implementation we just concentrate on the nouns and verbs relevant to the API. It may help to take a peek at the docs.)
Regarding future features, I'm not sure what you mean by existing toolchain. But if you mean gRPC, there are some features that cannot be added or unlikely to be added because they would depend on One Platform patterns or would need to depend on configuration outside the proto.
I mean the protoc code generator with the grpc_python_plugin. I don't know what "One Platform" is, and generally am only concerned with publicly documented things users can see / already know about.
It seems this may be a hint at an answer to "where do the API scopes and URIs come from". If that's the case, why not provide those configuration values in a public way just like the .proto files so external developers can build their own toolchains or extend this one as they see fit?
It was much more evident in APIs like PubSub and Logging
We can run the generator on Pub/Sub and then get an idea of the differences there?
Overall, it seems like we are just adding another abstraction layer. For Bigtable at least, the current layers are
- Happybase library (to emulate a popular HBase/thrift library)
- Our low-level API mapping
- The gRPC generated code
- The Python
protobuf library
- The layer to just run Python (much slower than native)
- The gRPC core (C++) code
It just doesn't seem worth it.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The feedback provided on the code-gen is very valuable. It would be much appreciated if we could keep iterating until these point issues are either addressed or captured as work items. For the purposes of this review it would good to separate out these higher level questions.
For the higher level questions we should cover these in a different forum, but this boils down to 2 categories:
- This specific API will have a lot less code-gen saving than others because it has atypical patterns. As such we should reevaluate whether it should go first. We might, for example, apply all the feedback on the details, but select a different API to focus on.
- Broader questions such as whether code-gen features go in gRPC or another layer is complicated and best described elsewhere.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
OK. Let me know what else I can do?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
We will process the feedback you gave us. If you can review any updates and comment on whether the resolve the issue that would be much appreciated.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Sure thing. Ping me when the review is needed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@anthmgoogle I'm realizing in porting some of this over that a nice utility your library could provide would be to automatically convert Any messages into the correct type (based on the type_url).
Feature request?
PS You should really start a GitHub project, even if there is no code and just an issue tracker for feature requests.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for the feedback, we made changes to address the immediately resolvable ones. We have issues tracking some of the more difficult problems - mainly:
- Clearer, idiomatic (as much as possible) documentation
- Better formatting
- Parameter flattening
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just seems like a waste of time trying to implement this feature.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I don't see the value in the *_callable methods. Do you expect a user to actually think it's a good thing to have two methods with similar names, one of which they'll never use?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|