Skip to content

Commit 6b5223d

Browse files
authored
Merge pull request googleapis#2388 from dhermes/revert-2336
Revert PR 2336 and upgrade to google-gax>=0.14.1
2 parents 99ac955 + 523100f commit 6b5223d

8 files changed

Lines changed: 160 additions & 160 deletions

File tree

google/cloud/logging/_gax.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
from google.gax import CallOptions
2020
from google.gax import INITIAL_PAGE
21+
from google.gax.errors import GaxError
22+
from google.gax.grpc import exc_to_code
2123
from google.logging.type.log_severity_pb2 import LogSeverity
2224
from google.logging.v2.logging_config_pb2 import LogSink
2325
from google.logging.v2.logging_metrics_pb2 import LogMetric
@@ -29,7 +31,6 @@
2931
from google.cloud._helpers import _datetime_to_pb_timestamp
3032
from google.cloud._helpers import _pb_timestamp_to_rfc3339
3133
from google.cloud.exceptions import Conflict
32-
from google.cloud.exceptions import GrpcRendezvous
3334
from google.cloud.exceptions import NotFound
3435
# pylint: enable=ungrouped-imports
3536

@@ -122,8 +123,8 @@ def logger_delete(self, project, logger_name):
122123
path = 'projects/%s/logs/%s' % (project, logger_name)
123124
try:
124125
self._gax_api.delete_log(path, options)
125-
except GrpcRendezvous as exc:
126-
if exc.code() == StatusCode.NOT_FOUND:
126+
except GaxError as exc:
127+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
127128
raise NotFound(path)
128129
raise
129130

@@ -194,8 +195,8 @@ def sink_create(self, project, sink_name, filter_, destination):
194195
destination=destination)
195196
try:
196197
self._gax_api.create_sink(parent, sink_pb, options)
197-
except GrpcRendezvous as exc:
198-
if exc.code() == StatusCode.FAILED_PRECONDITION:
198+
except GaxError as exc:
199+
if exc_to_code(exc.cause) == StatusCode.FAILED_PRECONDITION:
199200
path = 'projects/%s/sinks/%s' % (project, sink_name)
200201
raise Conflict(path)
201202
raise
@@ -217,8 +218,8 @@ def sink_get(self, project, sink_name):
217218
path = 'projects/%s/sinks/%s' % (project, sink_name)
218219
try:
219220
sink_pb = self._gax_api.get_sink(path, options)
220-
except GrpcRendezvous as exc:
221-
if exc.code() == StatusCode.NOT_FOUND:
221+
except GaxError as exc:
222+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
222223
raise NotFound(path)
223224
raise
224225
return _log_sink_pb_to_mapping(sink_pb)
@@ -249,8 +250,8 @@ def sink_update(self, project, sink_name, filter_, destination):
249250
sink_pb = LogSink(name=path, filter=filter_, destination=destination)
250251
try:
251252
self._gax_api.update_sink(path, sink_pb, options)
252-
except GrpcRendezvous as exc:
253-
if exc.code() == StatusCode.NOT_FOUND:
253+
except GaxError as exc:
254+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
254255
raise NotFound(path)
255256
raise
256257
return _log_sink_pb_to_mapping(sink_pb)
@@ -268,8 +269,8 @@ def sink_delete(self, project, sink_name):
268269
path = 'projects/%s/sinks/%s' % (project, sink_name)
269270
try:
270271
self._gax_api.delete_sink(path, options)
271-
except GrpcRendezvous as exc:
272-
if exc.code() == StatusCode.NOT_FOUND:
272+
except GaxError as exc:
273+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
273274
raise NotFound(path)
274275
raise
275276

@@ -339,8 +340,8 @@ def metric_create(self, project, metric_name, filter_, description):
339340
description=description)
340341
try:
341342
self._gax_api.create_log_metric(parent, metric_pb, options)
342-
except GrpcRendezvous as exc:
343-
if exc.code() == StatusCode.FAILED_PRECONDITION:
343+
except GaxError as exc:
344+
if exc_to_code(exc.cause) == StatusCode.FAILED_PRECONDITION:
344345
path = 'projects/%s/metrics/%s' % (project, metric_name)
345346
raise Conflict(path)
346347
raise
@@ -362,8 +363,8 @@ def metric_get(self, project, metric_name):
362363
path = 'projects/%s/metrics/%s' % (project, metric_name)
363364
try:
364365
metric_pb = self._gax_api.get_log_metric(path, options)
365-
except GrpcRendezvous as exc:
366-
if exc.code() == StatusCode.NOT_FOUND:
366+
except GaxError as exc:
367+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
367368
raise NotFound(path)
368369
raise
369370
return _log_metric_pb_to_mapping(metric_pb)
@@ -394,8 +395,8 @@ def metric_update(self, project, metric_name, filter_, description):
394395
description=description)
395396
try:
396397
self._gax_api.update_log_metric(path, metric_pb, options)
397-
except GrpcRendezvous as exc:
398-
if exc.code() == StatusCode.NOT_FOUND:
398+
except GaxError as exc:
399+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
399400
raise NotFound(path)
400401
raise
401402
return _log_metric_pb_to_mapping(metric_pb)
@@ -413,8 +414,8 @@ def metric_delete(self, project, metric_name):
413414
path = 'projects/%s/metrics/%s' % (project, metric_name)
414415
try:
415416
self._gax_api.delete_log_metric(path, options)
416-
except GrpcRendezvous as exc:
417-
if exc.code() == StatusCode.NOT_FOUND:
417+
except GaxError as exc:
418+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
418419
raise NotFound(path)
419420
raise
420421

google/cloud/pubsub/_gax.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from google.cloud.gapic.pubsub.v1.subscriber_api import SubscriberApi
1919
from google.gax import CallOptions
2020
from google.gax import INITIAL_PAGE
21+
from google.gax.errors import GaxError
22+
from google.gax.grpc import exc_to_code
2123
from google.pubsub.v1.pubsub_pb2 import PubsubMessage
2224
from google.pubsub.v1.pubsub_pb2 import PushConfig
2325
from grpc import insecure_channel
@@ -27,7 +29,6 @@
2729
from google.cloud._helpers import _to_bytes
2830
from google.cloud._helpers import _pb_timestamp_to_rfc3339
2931
from google.cloud.exceptions import Conflict
30-
from google.cloud.exceptions import GrpcRendezvous
3132
from google.cloud.exceptions import NotFound
3233
# pylint: enable=ungrouped-imports
3334

@@ -92,8 +93,8 @@ def topic_create(self, topic_path):
9293
"""
9394
try:
9495
topic_pb = self._gax_api.create_topic(topic_path)
95-
except GrpcRendezvous as exc:
96-
if exc.code() == StatusCode.FAILED_PRECONDITION:
96+
except GaxError as exc:
97+
if exc_to_code(exc.cause) == StatusCode.FAILED_PRECONDITION:
9798
raise Conflict(topic_path)
9899
raise
99100
return {'name': topic_pb.name}
@@ -115,8 +116,8 @@ def topic_get(self, topic_path):
115116
"""
116117
try:
117118
topic_pb = self._gax_api.get_topic(topic_path)
118-
except GrpcRendezvous as exc:
119-
if exc.code() == StatusCode.NOT_FOUND:
119+
except GaxError as exc:
120+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
120121
raise NotFound(topic_path)
121122
raise
122123
return {'name': topic_pb.name}
@@ -133,8 +134,8 @@ def topic_delete(self, topic_path):
133134
"""
134135
try:
135136
self._gax_api.delete_topic(topic_path)
136-
except GrpcRendezvous as exc:
137-
if exc.code() == StatusCode.NOT_FOUND:
137+
except GaxError as exc:
138+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
138139
raise NotFound(topic_path)
139140
raise
140141

@@ -162,8 +163,8 @@ def topic_publish(self, topic_path, messages):
162163
try:
163164
result = self._gax_api.publish(topic_path, message_pbs,
164165
options=options)
165-
except GrpcRendezvous as exc:
166-
if exc.code() == StatusCode.NOT_FOUND:
166+
except GaxError as exc:
167+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
167168
raise NotFound(topic_path)
168169
raise
169170
return result.message_ids
@@ -200,8 +201,8 @@ def topic_list_subscriptions(self, topic_path, page_size=0,
200201
try:
201202
page_iter = self._gax_api.list_topic_subscriptions(
202203
topic_path, page_size=page_size, options=options)
203-
except GrpcRendezvous as exc:
204-
if exc.code() == StatusCode.NOT_FOUND:
204+
except GaxError as exc:
205+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
205206
raise NotFound(topic_path)
206207
raise
207208
subs = page_iter.next()
@@ -293,8 +294,8 @@ def subscription_create(self, subscription_path, topic_path,
293294
try:
294295
sub_pb = self._gax_api.create_subscription(
295296
subscription_path, topic_path, push_config, ack_deadline)
296-
except GrpcRendezvous as exc:
297-
if exc.code() == StatusCode.FAILED_PRECONDITION:
297+
except GaxError as exc:
298+
if exc_to_code(exc.cause) == StatusCode.FAILED_PRECONDITION:
298299
raise Conflict(topic_path)
299300
raise
300301
return _subscription_pb_to_mapping(sub_pb)
@@ -315,8 +316,8 @@ def subscription_get(self, subscription_path):
315316
"""
316317
try:
317318
sub_pb = self._gax_api.get_subscription(subscription_path)
318-
except GrpcRendezvous as exc:
319-
if exc.code() == StatusCode.NOT_FOUND:
319+
except GaxError as exc:
320+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
320321
raise NotFound(subscription_path)
321322
raise
322323
return _subscription_pb_to_mapping(sub_pb)
@@ -334,8 +335,8 @@ def subscription_delete(self, subscription_path):
334335
"""
335336
try:
336337
self._gax_api.delete_subscription(subscription_path)
337-
except GrpcRendezvous as exc:
338-
if exc.code() == StatusCode.NOT_FOUND:
338+
except GaxError as exc:
339+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
339340
raise NotFound(subscription_path)
340341
raise
341342

@@ -359,8 +360,8 @@ def subscription_modify_push_config(self, subscription_path,
359360
push_config = PushConfig(push_endpoint=push_endpoint)
360361
try:
361362
self._gax_api.modify_push_config(subscription_path, push_config)
362-
except GrpcRendezvous as exc:
363-
if exc.code() == StatusCode.NOT_FOUND:
363+
except GaxError as exc:
364+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
364365
raise NotFound(subscription_path)
365366
raise
366367

@@ -391,8 +392,8 @@ def subscription_pull(self, subscription_path, return_immediately=False,
391392
try:
392393
response_pb = self._gax_api.pull(
393394
subscription_path, max_messages, return_immediately)
394-
except GrpcRendezvous as exc:
395-
if exc.code() == StatusCode.NOT_FOUND:
395+
except GaxError as exc:
396+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
396397
raise NotFound(subscription_path)
397398
raise
398399
return [_received_message_pb_to_mapping(rmpb)
@@ -414,8 +415,8 @@ def subscription_acknowledge(self, subscription_path, ack_ids):
414415
"""
415416
try:
416417
self._gax_api.acknowledge(subscription_path, ack_ids)
417-
except GrpcRendezvous as exc:
418-
if exc.code() == StatusCode.NOT_FOUND:
418+
except GaxError as exc:
419+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
419420
raise NotFound(subscription_path)
420421
raise
421422

@@ -441,8 +442,8 @@ def subscription_modify_ack_deadline(self, subscription_path, ack_ids,
441442
try:
442443
self._gax_api.modify_ack_deadline(
443444
subscription_path, ack_ids, ack_deadline)
444-
except GrpcRendezvous as exc:
445-
if exc.code() == StatusCode.NOT_FOUND:
445+
except GaxError as exc:
446+
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
446447
raise NotFound(subscription_path)
447448
raise
448449

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
GRPC_PACKAGES = [
3737
'grpcio >= 1.0.0',
38-
'google-gax >= 0.13.0, < 0.14dev',
38+
'google-gax >= 0.14.1, < 0.15dev',
3939
'gapic-google-pubsub-v1 >= 0.9.0, < 0.10dev',
4040
'grpc-google-pubsub-v1 >= 0.9.0, < 0.10dev',
4141
'gapic-google-logging-v2 >= 0.9.0, < 0.10dev',

system_tests/logging_.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ def _logger_name():
7373
return 'system-tests-logger' + unique_resource_id('-')
7474

7575
def _list_entries(self, logger):
76-
from google.cloud.exceptions import GrpcRendezvous
76+
from google.gax.errors import GaxError
77+
7778
inner = RetryResult(_has_entries)(logger.list_entries)
78-
outer = RetryErrors(GrpcRendezvous, _retry_on_unavailable)(inner)
79+
outer = RetryErrors(GaxError, _retry_on_unavailable)(inner)
7980
return outer()
8081

8182
def test_log_text(self):

system_tests/pubsub.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
import os
1616
import unittest
1717

18+
from google.gax.errors import GaxError
19+
from google.gax.grpc import exc_to_code
1820
from grpc import StatusCode
1921
import httplib2
2022

2123
# pylint: disable=ungrouped-imports
2224
from google.cloud.environment_vars import PUBSUB_EMULATOR
23-
from google.cloud.exceptions import GrpcRendezvous
2425
from google.cloud.pubsub import client
2526
# pylint: enable=ungrouped-imports
2627

@@ -32,10 +33,10 @@
3233

3334

3435
def _unavailable(exc):
35-
return exc.code() == StatusCode.UNAVAILABLE
36+
return exc_to_code(exc) == StatusCode.UNAVAILABLE
3637

3738

38-
retry_unavailable = RetryErrors(GrpcRendezvous, _unavailable)
39+
retry_unavailable = RetryErrors(GaxError, _unavailable)
3940

4041

4142
class Config(object):

unit_tests/_testing.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,10 @@ class _GAXBaseAPI(object):
5757
def __init__(self, **kw):
5858
self.__dict__.update(kw)
5959

60-
def _make_grpc_error(self, status_code=None):
60+
def _make_grpc_error(self, status_code):
6161
from grpc._channel import _RPCState
62-
from grpc import StatusCode
6362
from google.cloud.exceptions import GrpcRendezvous
6463

65-
if status_code is None:
66-
status_code = StatusCode.UNKNOWN
67-
6864
details = 'Some error details.'
6965
exc_state = _RPCState((), None, None, status_code, details)
7066
return GrpcRendezvous(exc_state, None, None, None)

0 commit comments

Comments
 (0)