-
Notifications
You must be signed in to change notification settings - Fork 13
GaxError is no longer raised in 0.13.0 when expected #130
Comments
I can reproduce this:
We should talk with the gRPC folks (@nathanielmanistaatgoogle et al). I'm somewhat uncomfortable with catching |
@geigerj Ditto. We have googleapis/google-cloud-python#2156 for that discussion as well. |
@geigerj: gRPC is raising an exception with a non-public class, but the public types of the instance that is raised are
. |
@nathanielmanistaatgoogle But what you're actually forcing users to do is try:
foo()
except grpc.RpcError as grpc_err:
if isinstance(grpc_err, grpc.Call):
code = grpc_err.code()
else:
raise (Already mentioned this in googleapis/google-cloud-python#2156) |
@dhermes: I don't understand the need for the instance check? |
@nathanielmanistaatgoogle What is the relationship between |
@geigerj: |
@nathanielmanistaatgoogle @dhermes Correct me if I misunderstood, but I think @dhermes's concern comes from the fact that |
/cc @tseaver @nathanielmanistaatgoogle Maybe we should have a more centralized place for this discussion? |
@dhermes: absolutely have that discussion, but if you'll indulge me I'd rather observe it than lead it. I intended for the API to be clear that the exception raised will implement both types and can (without having to check first) be used according to both types so I'd like to see where the ambiguity is creeping in. |
@nathanielmanistaatgoogle The ambiguity is that You've now got feedback from two downstream libraries / three users that this pattern is not intuitive / makes us uncomfortable. |
Yes, I have verified against the pubsub snippet referenced above in this issue with an install of GAX from source. |
Thanks @geigerj! |
Didn't realize you guys released so fast, 0.14.1 already out there! I'll whip up a PR to restore our usage of |
One of the things that I think is successful about the gRPC Python API is that I think it affords a lot of behavioral complexity while being very simply expressed. I admire this property in other systems and made an explicit goal for this design. By “simple” I mostly mean the raw number of code elements (constants, functions, classes, and methods, albeit weighted differently) in the API but also factor in the expected complexity of code using the API. The principal means of pulling it off (both in gRPC Python and in the other systems I’ve seen) is to avoid having code elements repeat one another statically (for example by having a method that does something in one class and then having another method in another class, possibly with the same name, that does the same thing) but then having the system dynamically interact across its API boundary in terms of combinations of those simple elements. One way to describe those combinations is with multiple inheritance: an API can define non-trivial classes A, B, C, and D all with interesting methods and then also define a class AB that inherits from A and B and a class CD that inherits from C and D, but then that widens the API with those additional code elements. In a type system like Java’s those subclasses (technically sub So gRPC Python passes across its API boundary, in the direction from itself to applications, objects that implement more than one type. In fact it has for a year because this was a property of the Beta API; that’s one reason why the matter coming up now has caught me off-guard. Another is that I always thought that having an object that implements two types and using it according to one type, then the other type, and then the first type again was just ordinary bread-and-butter programming rather than anything particularly advanced or special. Consider the case of
– is that really strange? Other than the long name which is only what it is for clarity of the illustration? It looks like the short, clear code that I want my users to write. And yet because metadata is a feature of both response-unary and response-streaming RPCs, if the metadata access methods were part of the Now to One change that I’ve been wanting to make is defining a new class in Thank you for being clear about how strongly you reacted to this part of the API. Now that it’s been a few days, has your feeling mellowed at all? Having had it to think about, has it become any more familiar or comfortable? Have you found any portion of your discomfort to have come from not having seen an API do that before? |
We don't have any problem with the |
Most of the virtues you extol above are about composability. I don't have any beef with this class inheriting from 3 (or 10) classes. The issue is that there is no single public class which represents the public exception interface. |
For example, when getting a non-existent topic we expect a
GaxError
but see agrpc._Rendezvous
instead.Related: googleapis/google-cloud-python#2336
The text was updated successfully, but these errors were encountered: