-
Notifications
You must be signed in to change notification settings - Fork 3
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
Adding generated Bigtable classes. #22
Conversation
@saicheems Can you explain what these are and what generated them and why they are needed given the existence of |
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. |
Before continuing I should note that we are in the process of merging
|
|
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? |
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. |
I don't expect GAX to be part of this review. I'd expect it to be include-able as a PyPI package. |
@dhermes Right, our intention is to eventually have it available as a package. I'll include our end to end example. |
@dhermes @saicheems Yes, although note that as a temporary solution, we may have to put it in gcloud-python, similar to what happed with Java GAX (googleapis/google-cloud-java#320). We haven't yet worked out a permanent home for GAX. |
GitHub and PyPI are a great start to be part of the Python community |
@geigerj So the current most pressing need is just to review the API surface? (And the forthcoming example usage docs) |
Yup, that's right. |
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. |
* New tables can be created in the cluster. | ||
* The cluster's allocated resource levels will be readable via the API. | ||
The embedded operation's "metadata" field type is | ||
[CreateClusterMetadata][google.bigtable.admin.cluster.v1.CreateClusterMetadata] The embedded operation's "response" field type is |
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 ..."
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.
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.
I haven't read the code yet, but have gone through Maybe I'm misunderstanding what the goal was? |
# EDITING INSTRUCTIONS | ||
# This file was generated from google/bigtable/admin/cluster/v1/bigtable_cluster_service.proto, | ||
# and updates to that file get reflected here through a regular refresh | ||
# process. However, manual and updates to that file get reflected here |
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?
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.
Done.
# Properties | ||
@property | ||
def channel(self): | ||
return self.channel |
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
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.
Removed.
"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:
|
"""Service for reading from and writing to existing Bigtables.""" | ||
|
||
# The default address of the logging service. | ||
_SERVICE_ADDRESS = "bigtable.googleapis.com" |
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.
There are
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).
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
I'm not sure what you mean by this.
But the exact same can be said of the existing toolchain. |
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. |
Gotcher. I get it now.
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.
Where does that come into play? Why wouldn't the gRPC /
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.)
I mean the 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
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
It just doesn't seem worth it. |
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:
|
OK. Let me know what else I can do? |
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. |
Sure thing. Ping me when the review is needed. |
@anthmgoogle I'm realizing in porting some of this over that a nice utility your library could provide would be to automatically convert Feature request? PS You should really start a GitHub project, even if there is no code and just an issue tracker for feature requests. |
Thanks for the feedback, we made changes to address the immediately resolvable ones. We have issues tracking some of the more difficult problems - mainly:
|
# Manual additions are allowed because the refresh process performs | ||
# a 3-way merge in order to preserve those manual additions. In order to not | ||
# break the refresh process, only certain types of modifications are | ||
# allowed. |
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.
I don't see the value in the |
No description provided.