Skip to content
This repository was archived by the owner on Mar 20, 2018. It is now read-only.

Commit 9a42e3b

Browse files
authored
Remove references to grpc.beta (#127)
Also bump dependency on grpc, protobuf to non-rc versions.
1 parent d59635e commit 9a42e3b

File tree

5 files changed

+39
-44
lines changed

5 files changed

+39
-44
lines changed

google/gax/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import collections
3434

3535

36-
__version__ = '0.12.5'
36+
__version__ = '0.13.0'
3737

3838

3939
INITIAL_PAGE = object()

google/gax/grpc.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"""Adapts the grpc surface."""
3131

3232
from __future__ import absolute_import
33-
from grpc.beta import implementations
34-
from grpc.beta.interfaces import StatusCode
33+
import grpc
34+
from grpc import StatusCode
3535
from grpc.framework.interfaces.face import face
3636
from . import auth
3737

@@ -82,8 +82,8 @@ def grpc_auth(dummy_context, callback):
8282
def _make_channel_creds(auth_func, ssl_creds):
8383
"""Converts the auth func into the composite creds expected by grpc."""
8484
grpc_auth_func = _make_grpc_auth_func(auth_func)
85-
call_creds = implementations.metadata_call_credentials(grpc_auth_func)
86-
return implementations.composite_channel_credentials(ssl_creds, call_creds)
85+
call_creds = grpc.metadata_call_credentials(grpc_auth_func)
86+
return grpc.composite_channel_credentials(ssl_creds, call_creds)
8787

8888

8989
def create_stub(generated_create_stub, service_path, port, ssl_creds=None,
@@ -108,15 +108,14 @@ def create_stub(generated_create_stub, service_path, port, ssl_creds=None,
108108
"""
109109
if channel is None:
110110
if ssl_creds is None:
111-
ssl_creds = implementations.ssl_channel_credentials(
112-
None, None, None)
111+
ssl_creds = grpc.ssl_channel_credentials()
113112
if metadata_transformer is None:
114113
if scopes is None:
115114
scopes = []
116115
metadata_transformer = auth.make_auth_func(scopes)
117116

118117
channel_creds = _make_channel_creds(metadata_transformer, ssl_creds)
119-
channel = implementations.secure_channel(
120-
service_path, port, channel_creds)
118+
target = '{}:{}'.format(service_path, port)
119+
channel = grpc.secure_channel(target, channel_creds)
121120

122121
return generated_create_stub(channel)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050

5151
install_requires = [
5252
'future>=0.15.2',
53-
'grpcio>=1.0rc1',
53+
'grpcio>=1.0.0',
5454
'ply==3.8',
55-
'protobuf>=3.0.0b3',
55+
'protobuf>=3.0.0',
5656
'oauth2client>=1.5.2',
5757
]
5858

test-requirements.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,4 @@ pytest>=2.8.3
33
pytest-cov>=1.8.1
44
pytest-timeout>=1.0.0
55
unittest2>=1.1.0
6-
7-
# TODO: remove this line when grpcio goes to 1.0.0. This is only necessary
8-
# because pip (running in Travis CI) will not install the release candidate
9-
# when it gets pulled in as a dependency of grpcio-tools, below, which causes
10-
# build failure in Python 3 environments
11-
grpcio>=1.0.0rc1
12-
13-
grpcio-tools>=1.0.0rc2
6+
grpcio-tools>=1.0.0

test/test_grpc.py

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,41 @@ class TestCreateStub(unittest2.TestCase):
4646
FAKE_SERVICE_PATH = 'service_path'
4747
FAKE_PORT = 10101
4848

49-
@mock.patch('grpc.beta.implementations.composite_channel_credentials')
50-
@mock.patch('grpc.beta.implementations.ssl_channel_credentials')
51-
@mock.patch('grpc.beta.implementations.secure_channel')
49+
@mock.patch('grpc.composite_channel_credentials')
50+
@mock.patch('grpc.ssl_channel_credentials')
51+
@mock.patch('grpc.secure_channel')
5252
@mock.patch('google.gax.auth.make_auth_func')
5353
def test_creates_a_stub_ok_with_no_scopes(
5454
self, auth, chan, chan_creds, comp):
5555
got_channel = grpc.create_stub(
5656
_fake_create_stub, self.FAKE_SERVICE_PATH, self.FAKE_PORT)
57-
chan_creds.assert_called_once_with(None, None, None)
58-
chan.assert_called_once_with(self.FAKE_SERVICE_PATH, self.FAKE_PORT,
59-
comp.return_value)
57+
chan_creds.assert_called_once_with()
58+
chan.assert_called_once_with(
59+
'{}:{}'.format(self.FAKE_SERVICE_PATH, self.FAKE_PORT),
60+
comp.return_value)
6061
auth.assert_called_once_with([])
6162
self.assertEqual(got_channel, chan.return_value)
6263

63-
@mock.patch('grpc.beta.implementations.composite_channel_credentials')
64-
@mock.patch('grpc.beta.implementations.ssl_channel_credentials')
65-
@mock.patch('grpc.beta.implementations.secure_channel')
64+
@mock.patch('grpc.composite_channel_credentials')
65+
@mock.patch('grpc.ssl_channel_credentials')
66+
@mock.patch('grpc.secure_channel')
6667
@mock.patch('google.gax.auth.make_auth_func')
6768
def test_creates_a_stub_ok_with_scopes(
6869
self, auth, chan, chan_creds, comp):
6970
fake_scopes = ['dummy', 'scopes']
7071
grpc.create_stub(
7172
_fake_create_stub, self.FAKE_SERVICE_PATH, self.FAKE_PORT,
7273
scopes=fake_scopes)
73-
chan_creds.assert_called_once_with(None, None, None)
74-
chan.assert_called_once_with(self.FAKE_SERVICE_PATH, self.FAKE_PORT,
75-
comp.return_value)
74+
chan_creds.assert_called_once_with()
75+
chan.assert_called_once_with(
76+
'{}:{}'.format(self.FAKE_SERVICE_PATH, self.FAKE_PORT),
77+
comp.return_value)
7678
auth.assert_called_once_with(fake_scopes)
7779

78-
@mock.patch('grpc.beta.implementations.metadata_call_credentials')
79-
@mock.patch('grpc.beta.implementations.composite_channel_credentials')
80-
@mock.patch('grpc.beta.implementations.ssl_channel_credentials')
81-
@mock.patch('grpc.beta.implementations.secure_channel')
80+
@mock.patch('grpc.metadata_call_credentials')
81+
@mock.patch('grpc.composite_channel_credentials')
82+
@mock.patch('grpc.ssl_channel_credentials')
83+
@mock.patch('grpc.secure_channel')
8284
@mock.patch('google.gax.auth.make_auth_func')
8385
def test_creates_a_stub_with_given_channel(
8486
self, auth, chan, chan_creds, comp, md):
@@ -93,29 +95,30 @@ def test_creates_a_stub_with_given_channel(
9395
self.assertFalse(comp.called)
9496
self.assertFalse(md.called)
9597

96-
@mock.patch('grpc.beta.implementations.metadata_call_credentials')
97-
@mock.patch('grpc.beta.implementations.composite_channel_credentials')
98-
@mock.patch('grpc.beta.implementations.ssl_channel_credentials')
99-
@mock.patch('grpc.beta.implementations.secure_channel')
98+
@mock.patch('grpc.metadata_call_credentials')
99+
@mock.patch('grpc.composite_channel_credentials')
100+
@mock.patch('grpc.ssl_channel_credentials')
101+
@mock.patch('grpc.secure_channel')
100102
@mock.patch('google.gax.auth.make_auth_func')
101103
def test_creates_a_stub_ok_with_given_creds(self, auth, chan, chan_creds,
102104
comp, md):
103105
fake_creds = object()
104106
got_channel = grpc.create_stub(
105107
_fake_create_stub, self.FAKE_SERVICE_PATH, self.FAKE_PORT,
106108
ssl_creds=fake_creds)
107-
chan.assert_called_once_with(self.FAKE_SERVICE_PATH, self.FAKE_PORT,
108-
comp.return_value)
109+
chan.assert_called_once_with(
110+
'{}:{}'.format(self.FAKE_SERVICE_PATH, self.FAKE_PORT),
111+
comp.return_value)
109112
auth.assert_called_once_with([])
110113
self.assertTrue(chan.called)
111114
self.assertFalse(chan_creds.called)
112115
self.assertTrue(comp.called)
113116
self.assertTrue(md.called)
114117
self.assertEqual(got_channel, chan.return_value)
115118

116-
@mock.patch('grpc.beta.implementations.composite_channel_credentials')
117-
@mock.patch('grpc.beta.implementations.ssl_channel_credentials')
118-
@mock.patch('grpc.beta.implementations.secure_channel')
119+
@mock.patch('grpc.composite_channel_credentials')
120+
@mock.patch('grpc.ssl_channel_credentials')
121+
@mock.patch('grpc.secure_channel')
119122
@mock.patch('google.gax.auth.make_auth_func')
120123
def test_creates_a_stub_ok_with_given_auth_func(self, auth, dummy_chan,
121124
dummy_chan_creds, dummy_md):

0 commit comments

Comments
 (0)