From fecde3f5ae939d8fab0db0b645744d9729627af4 Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Tue, 21 Jun 2016 18:55:01 -0700 Subject: [PATCH 01/19] Fix error with setting repeated proto field for bundling. Update bundling tests to use actual proto messages, to prove this fix works. --- .gitignore | 3 ++ google/gax/__init__.py | 2 +- google/gax/bundling.py | 7 ++--- test/fixture.proto | 30 +++++++++++++++++++ test/test_bundling.py | 65 ++++++++++++++++++++---------------------- tox.ini | 6 ++-- 6 files changed, 72 insertions(+), 41 deletions(-) create mode 100644 test/fixture.proto diff --git a/.gitignore b/.gitignore index 38f98b3..904b7ae 100644 --- a/.gitignore +++ b/.gitignore @@ -65,5 +65,8 @@ coverage.xml docs/_build/ _build +#Protobuf +*_pb2.py + # PyBuilder target/ diff --git a/google/gax/__init__.py b/google/gax/__init__.py index bd2458a..fb609c2 100644 --- a/google/gax/__init__.py +++ b/google/gax/__init__.py @@ -33,7 +33,7 @@ import collections -__version__ = '0.12.0' +__version__ = '0.12.1' INITIAL_PAGE = object() diff --git a/google/gax/bundling.py b/google/gax/bundling.py index 9ee941a..bf6dd31 100644 --- a/google/gax/bundling.py +++ b/google/gax/bundling.py @@ -67,11 +67,9 @@ def _str_dotted_getattr(obj, name): Raises: AttributeError if the named attribute does not exist. """ - if name.find('.') == -1: - return getattr(obj, name) for part in name.split('.'): obj = getattr(obj, part) - return str(obj) if obj is not None else None + return str(obj) if obj else None def compute_bundle_id(obj, discriminator_fields): @@ -190,7 +188,8 @@ def _run_with_subresponses(self, req, subresponse_field, kwargs): for i, event in zip(in_sizes, self._event_deque): next_copy = copy.copy(resp) subresponses = all_subresponses[start:start + i] - setattr(next_copy, subresponse_field, subresponses) + next_copy.ClearField(subresponse_field) + getattr(next_copy, subresponse_field).extend(subresponses) start += i event.result = next_copy event.set() diff --git a/test/fixture.proto b/test/fixture.proto new file mode 100644 index 0000000..79a169a --- /dev/null +++ b/test/fixture.proto @@ -0,0 +1,30 @@ +// Copyright 2016 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +syntax = "proto3"; + +package google.protobuf; + +message Simple { + string field1 = 1; + string field2 = 2; +} + +message Outer { + Simple inner = 1; + string field1 = 2; +} + +message Bundled { + repeated string field1 = 1; +} diff --git a/test/test_bundling.py b/test/test_bundling.py index ae1b30f..98a7b7d 100644 --- a/test/test_bundling.py +++ b/test/test_bundling.py @@ -37,25 +37,22 @@ from google.gax import bundling, BundleOptions, BundleDescriptor +from fixture_pb2 import Simple, Outer, Bundled -# pylint: disable=too-few-public-methods -class _Simple(object): - def __init__(self, value, other_value=None): - self.field1 = value - self.field2 = other_value - def __eq__(self, other): - return (self.field1 == other.field1 and - self.field2 == other.field2) +def _Simple(value, other_value=None): + if (other_value is None): + return Simple(field1=value) + else: + return Simple(field1=value, field2=other_value) - def __str__(self): - return 'field1={0}, field2={1}'.format(self.field1, self.field2) - -class _Outer(object): - def __init__(self, value): - self.inner = _Simple(value, other_value=value) - self.field1 = value +def _Outer(value): + return Outer(inner=_Simple(value, value), field1=value) + + +def _Bundled(value): + return Bundled(field1=value) class TestComputeBundleId(unittest2.TestCase): @@ -135,7 +132,7 @@ def _make_a_test_task(api_call=_return_request): api_call, 'an_id', 'field1', - _Simple([]), + _Bundled([]), dict()) @@ -212,13 +209,13 @@ def test_run_sends_the_bundle_elements(self): 'message': 'a single bundled message', 'has_event': True, 'count_before_run': 1, - 'want': _Simple([simple_msg]) + 'want': _Bundled([simple_msg]) }, { 'update': (lambda t: _extend_with_n_elts(t, simple_msg, 5)), 'message': '5 bundle messages', 'has_event': True, 'count_before_run': 5, - 'want': _Simple([simple_msg] * 5) + 'want': _Bundled([simple_msg] * 5) } ] for t in tests: @@ -259,7 +256,7 @@ def test_calling_the_canceller_stops_the_element_from_getting_sent(self): self.assertEquals(test_task.element_count, 1) test_task.run() self.assertEquals(test_task.element_count, 0) - self.assertEquals(_Simple([another_msg]), another_event.result) + self.assertEquals(_Bundled([another_msg]), another_event.result) self.assertFalse(an_event.is_set()) self.assertIsNone(an_event.result) @@ -283,7 +280,7 @@ def test_api_calls_are_grouped_by_bundle_id(self): api_call, an_id, SIMPLE_DESCRIPTOR, - _Simple([an_elt]) + _Bundled([an_elt]) ) self.assertIsNotNone( got_event.canceller, @@ -297,14 +294,14 @@ def test_api_calls_are_grouped_by_bundle_id(self): api_call, an_id, SIMPLE_DESCRIPTOR, - _Simple([an_elt]) + _Bundled([an_elt]) ) self.assertIsNotNone(got_event.canceller, 'missing expected canceller') self.assertTrue( got_event.is_set(), 'event is not set after triggering element') - self.assertEquals(_Simple([an_elt] * threshold), + self.assertEquals(_Bundled([an_elt] * threshold), got_event.result) def test_each_event_has_exception_when_demuxed_api_call_fails(self): @@ -320,7 +317,7 @@ def test_each_event_has_exception_when_demuxed_api_call_fails(self): api_call, bundle_id, DEMUX_DESCRIPTOR, - _Simple(['%s%d' % (an_elt, i)]) + _Bundled(['%s%d' % (an_elt, i)]) ) self.assertFalse( got_event.is_set(), @@ -331,7 +328,7 @@ def test_each_event_has_exception_when_demuxed_api_call_fails(self): api_call, bundle_id, DEMUX_DESCRIPTOR, - _Simple(['%s%d' % (an_elt, threshold - 1)]) + _Bundled(['%s%d' % (an_elt, threshold - 1)]) ) events.append(last_event) @@ -359,7 +356,7 @@ def test_each_event_has_its_result_from_a_demuxed_api_call(self): api_call, bundle_id, DEMUX_DESCRIPTOR, - _Simple(['%s%d' % (an_elt, i)] * i) + _Bundled(['%s%d' % (an_elt, i)] * i) ) events.append(got_event) previous_event = None @@ -370,12 +367,12 @@ def test_each_event_has_its_result_from_a_demuxed_api_call(self): self.assertTrue(event.is_set(), 'event is not set after triggering element') self.assertEquals(event.result, - _Simple(['%s%d' % (an_elt, index)] * index)) + _Bundled(['%s%d' % (an_elt, index)] * index)) previous_event = event def test_each_event_has_same_result_from_mismatched_demuxed_api_call(self): an_elt = 'dummy message' - mismatched_result = _Simple([an_elt, an_elt]) + mismatched_result = _Bundled([an_elt, an_elt]) bundle_id = 'an_id' threshold = 5 # arbitrary, greater than 1 options = BundleOptions(element_count_threshold=threshold) @@ -388,7 +385,7 @@ def test_each_event_has_same_result_from_mismatched_demuxed_api_call(self): lambda x: mismatched_result, bundle_id, DEMUX_DESCRIPTOR, - _Simple(['%s%d' % (an_elt, i)] * i) + _Bundled(['%s%d' % (an_elt, i)] * i) ) events.append(got_event) previous_event = None @@ -409,7 +406,7 @@ def test_schedule_passes_kwargs(self): _return_kwargs, bundle_id, SIMPLE_DESCRIPTOR, - _Simple([an_elt]), + _Bundled([an_elt]), {'an_option': 'a_value'} ) self.assertEquals('a_value', @@ -430,7 +427,7 @@ def test_api_call_not_invoked_until_threshold(self): api_call, an_id, SIMPLE_DESCRIPTOR, - _Simple([an_elt]) + _Bundled([an_elt]) ) self.assertIsNotNone( got_event.canceller, @@ -440,7 +437,7 @@ def test_api_call_not_invoked_until_threshold(self): self.assertIsNone(got_event.result) else: self.assertTrue(got_event.is_set()) - self.assertEquals(_Simple([an_elt] * threshold), + self.assertEquals(_Bundled([an_elt] * threshold), got_event.result) @@ -459,7 +456,7 @@ def test_api_call_not_invoked_until_threshold(self): api_call, an_id, SIMPLE_DESCRIPTOR, - _Simple([an_elt]) + _Bundled([an_elt]) ) self.assertIsNotNone( got_event.canceller, @@ -469,7 +466,7 @@ def test_api_call_not_invoked_until_threshold(self): self.assertIsNone(got_event.result) else: self.assertTrue(got_event.is_set()) - self.assertEquals(_Simple([an_elt] * elts_for_threshold), + self.assertEquals(_Bundled([an_elt] * elts_for_threshold), got_event.result) @@ -487,7 +484,7 @@ def test_api_call_is_scheduled_on_timer(self, timer_class): api_call, an_id, SIMPLE_DESCRIPTOR, - _Simple([an_elt]) + _Bundled([an_elt]) ) self.assertIsNotNone(got_event, 'missing event after first request') self.assertIsNone(got_event.result) diff --git a/tox.ini b/tox.ini index 062f0c4..19b7c51 100644 --- a/tox.ini +++ b/tox.ini @@ -6,11 +6,13 @@ envlist = py27,pep8,pylint-errors,pylint-full [testenv] setenv = - PYTHONPATH = {toxinidir} + PYTHONPATH = {toxinidir}:{toxinidir}/test deps = -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt -commands = py.test --timeout=30 --cov-report html --cov-report=term --cov {toxinidir}/google +whitelist_externals = protoc +commands = -protoc --python_out=. test/fixture.proto + -py.test --timeout=30 --cov-report html --cov-report=term --cov {toxinidir}/google [testenv:pep8] deps = flake8 From c57d175f77287bcbe1ac649db7708fbf07b4d4a7 Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 10:36:33 -0700 Subject: [PATCH 02/19] Install protoc on Travis server before running tests --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index cf1d4a3..17bdde7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ sudo: false language: python python: - "2.7" +before_install: + - sudo apt-get -qq update + - sudo apt-get install -y protobuf-compiler install: pip install codecov tox-travis script: tox after_success: From 1bf3c27e54558c294eda8c5b098af5f73927338b Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 10:38:03 -0700 Subject: [PATCH 03/19] Fix pep8 tests --- test/test_bundling.py | 4 ++-- tox.ini | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/test_bundling.py b/test/test_bundling.py index 98a7b7d..7c8e95b 100644 --- a/test/test_bundling.py +++ b/test/test_bundling.py @@ -49,8 +49,8 @@ def _Simple(value, other_value=None): def _Outer(value): return Outer(inner=_Simple(value, value), field1=value) - - + + def _Bundled(value): return Bundled(field1=value) diff --git a/tox.ini b/tox.ini index 19b7c51..3bae87d 100644 --- a/tox.ini +++ b/tox.ini @@ -16,9 +16,12 @@ commands = -protoc --python_out=. test/fixture.proto [testenv:pep8] deps = flake8 -commands = flake8 --max-complexity=10 google test --ignore=E501 +commands = flake8 --max-complexity=10 google test --ignore=E501 --exclude='test/*_pb2.py' [testenv:pylint-errors] +setenv = + PYTHONPATH = {toxinidir}:{toxinidir}/test + deps = pylint -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt From a17ec196771c4053c9d61841cf133068c35971c7 Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 11:14:19 -0700 Subject: [PATCH 04/19] Fix pylint issue --- test/test_bundling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_bundling.py b/test/test_bundling.py index 7c8e95b..af224ba 100644 --- a/test/test_bundling.py +++ b/test/test_bundling.py @@ -41,7 +41,7 @@ def _Simple(value, other_value=None): - if (other_value is None): + if other_value is None: return Simple(field1=value) else: return Simple(field1=value, field2=other_value) From 7fcf516625e777b6abec59c779ca405e4361e5b5 Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 11:14:36 -0700 Subject: [PATCH 05/19] Try linuxbrew for installing protoc --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17bdde7..b0c6802 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ language: python python: - "2.7" before_install: - - sudo apt-get -qq update - - sudo apt-get install -y protobuf-compiler + - brew update + - brew install --devel protobuf install: pip install codecov tox-travis script: tox after_success: From 4558e81cf08eb8433c6508b05e1e5ba42a75ec6d Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 11:15:08 -0700 Subject: [PATCH 06/19] Use a src-gen directory for proto output to make it easy to ignore --- tox.ini | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tox.ini b/tox.ini index 3bae87d..f498e6f 100644 --- a/tox.ini +++ b/tox.ini @@ -6,36 +6,35 @@ envlist = py27,pep8,pylint-errors,pylint-full [testenv] setenv = - PYTHONPATH = {toxinidir}:{toxinidir}/test + PYTHONPATH = {toxinidir}:{toxinidir}/src-gen/test deps = -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt -whitelist_externals = protoc -commands = -protoc --python_out=. test/fixture.proto +whitelist_externals = mkdir + protoc +commands = -mkdir src-gen + -protoc --python_out=src-gen test/fixture.proto -py.test --timeout=30 --cov-report html --cov-report=term --cov {toxinidir}/google [testenv:pep8] deps = flake8 -commands = flake8 --max-complexity=10 google test --ignore=E501 --exclude='test/*_pb2.py' +commands = flake8 --max-complexity=10 google test --ignore=E501 --exclude=src-gen [testenv:pylint-errors] -setenv = - PYTHONPATH = {toxinidir}:{toxinidir}/test - deps = pylint -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt -commands = pylint -f colorized -E google test +commands = pylint -f colorized -E google test --ignore=src-gen [testenv:pylint-warnings] deps = pylint -commands = pylint -f colorized -d all -e W -r n google test +commands = pylint -f colorized -d all -e W -r n google test --ignore=src-gen [testenv:pylint-full] deps = pylint -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt -commands = pylint -f colorized -e E,W,R -d fixme,locally-disabled google test +commands = pylint -f colorized -e E,W,R -d fixme,locally-disabled google test --ignore=src-gen [testenv:devenv] commands = From b74d8b817a9295327f8a9705b6af49941f5c4f1a Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 11:36:17 -0700 Subject: [PATCH 07/19] Try installing and using linuxbrew to get devel version of protoc --- .travis.yml | 4 +--- install-protobuf3.sh | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100755 install-protobuf3.sh diff --git a/.travis.yml b/.travis.yml index b0c6802..da5c8c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,7 @@ sudo: false language: python python: - "2.7" -before_install: - - brew update - - brew install --devel protobuf +before_install: ./install-protobuf3.sh install: pip install codecov tox-travis script: tox after_success: diff --git a/install-protobuf3.sh b/install-protobuf3.sh new file mode 100755 index 0000000..e2cedc8 --- /dev/null +++ b/install-protobuf3.sh @@ -0,0 +1,11 @@ +#!/bin/bash +#TODO: Could test that protoc is at least version 3.0.0 +command -v protoc >/dev/null 2>&1 || { + command -v brew >/dev/null 2>&1 || { + # install linuxbrew + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)" + } + + export PATH="$HOME/.linuxbrew/bin:$PATH" + brew install --devel protobuf +} From 5d0560a5ecf6aaaaa08645fbe1d451614ef0b11e Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 13:34:01 -0700 Subject: [PATCH 08/19] Install brew in headless mode for Travis CI --- install-protobuf3.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install-protobuf3.sh b/install-protobuf3.sh index e2cedc8..0cb7c2a 100755 --- a/install-protobuf3.sh +++ b/install-protobuf3.sh @@ -3,7 +3,8 @@ command -v protoc >/dev/null 2>&1 || { command -v brew >/dev/null 2>&1 || { # install linuxbrew - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)" + Date: Wed, 22 Jun 2016 13:56:01 -0700 Subject: [PATCH 09/19] Cache protoc installation, since it's expensive to do every time --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index da5c8c8..d2e722c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,14 @@ sudo: false + +# Protobuf is very expensive to install, so we cache it between builds +before_install: ./install-protobuf3.sh +cache: + directories: + - $HOME/.linuxbrew + language: python python: - "2.7" -before_install: ./install-protobuf3.sh install: pip install codecov tox-travis script: tox after_success: From 2008133a31f410590bf7b33d2e8986aa75250fe6 Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 14:00:47 -0700 Subject: [PATCH 10/19] Put linuxbrew in path for calling protoc. Update cache on each build. --- install-protobuf3.sh | 11 +++++++++-- tox.ini | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/install-protobuf3.sh b/install-protobuf3.sh index 0cb7c2a..9b4d619 100755 --- a/install-protobuf3.sh +++ b/install-protobuf3.sh @@ -1,12 +1,19 @@ #!/bin/bash + +export PATH="$HOME/.linuxbrew/bin:$PATH" + #TODO: Could test that protoc is at least version 3.0.0 command -v protoc >/dev/null 2>&1 || { command -v brew >/dev/null 2>&1 || { - # install linuxbrew + # install brew in headless mode Date: Wed, 22 Jun 2016 14:21:09 -0700 Subject: [PATCH 11/19] TODO comment no longer needed, since we do automatic upgrade --- install-protobuf3.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install-protobuf3.sh b/install-protobuf3.sh index 9b4d619..a978211 100755 --- a/install-protobuf3.sh +++ b/install-protobuf3.sh @@ -2,7 +2,6 @@ export PATH="$HOME/.linuxbrew/bin:$PATH" -#TODO: Could test that protoc is at least version 3.0.0 command -v protoc >/dev/null 2>&1 || { command -v brew >/dev/null 2>&1 || { # install brew in headless mode From 22164501cd80ed112890a5063554f7514a2e83b3 Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 14:28:25 -0700 Subject: [PATCH 12/19] Be explicit about location of protoc --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index d26818d..1f9044f 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,6 @@ envlist = py27,pep8,pylint-errors,pylint-full [testenv] setenv = - PATH = $HOME/.linuxbrew/bin:$PATH PYTHONPATH = {toxinidir}:{toxinidir}/src-gen/test deps = -r{toxinidir}/test-requirements.txt @@ -14,7 +13,7 @@ deps = -r{toxinidir}/test-requirements.txt whitelist_externals = mkdir protoc commands = -mkdir src-gen - -protoc --python_out=src-gen test/fixture.proto + -$HOME/.linuxbrew/bin/protoc --python_out=src-gen test/fixture.proto -py.test --timeout=30 --cov-report html --cov-report=term --cov {toxinidir}/google [testenv:pep8] From 4774dc7177a8852ec23d42385974c705bf7c675f Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 14:31:24 -0700 Subject: [PATCH 13/19] Temporary debug line --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 1f9044f..0a9eba6 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ deps = -r{toxinidir}/test-requirements.txt whitelist_externals = mkdir protoc commands = -mkdir src-gen + -ls $HOME/.linuxbrew/bin -$HOME/.linuxbrew/bin/protoc --python_out=src-gen test/fixture.proto -py.test --timeout=30 --cov-report html --cov-report=term --cov {toxinidir}/google From a8925026809b9cfd22d2c5ae974cfe852e39a443 Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 14:40:55 -0700 Subject: [PATCH 14/19] Improve script output --- install-protobuf3.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/install-protobuf3.sh b/install-protobuf3.sh index a978211..0361add 100755 --- a/install-protobuf3.sh +++ b/install-protobuf3.sh @@ -2,17 +2,21 @@ export PATH="$HOME/.linuxbrew/bin:$PATH" -command -v protoc >/dev/null 2>&1 || { - command -v brew >/dev/null 2>&1 || { - # install brew in headless mode +echo "Testing for protoc command" +command -v protoc 2>&1 || { + echo "Testing for brew command" + command -v brew 2>&1 || { + echo "Installing brew" + # install brew in headless mode to avoid user prompt requiring input Date: Wed, 22 Jun 2016 14:48:26 -0700 Subject: [PATCH 15/19] Define BREW_HOME variable to clarify what is defined where --- .travis.yml | 4 +++- install-protobuf3.sh | 2 +- tox.ini | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2e722c..d3bd0bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,12 @@ sudo: false +env: + - BREW_HOME=$HOME/.linuxbrew # Protobuf is very expensive to install, so we cache it between builds before_install: ./install-protobuf3.sh cache: directories: - - $HOME/.linuxbrew + - $BREW_HOME language: python python: diff --git a/install-protobuf3.sh b/install-protobuf3.sh index 0361add..b5ebe34 100755 --- a/install-protobuf3.sh +++ b/install-protobuf3.sh @@ -1,6 +1,6 @@ #!/bin/bash -export PATH="$HOME/.linuxbrew/bin:$PATH" +export PATH="$BREW_HOME/bin:$PATH" echo "Testing for protoc command" command -v protoc 2>&1 || { diff --git a/tox.ini b/tox.ini index 0a9eba6..549c238 100644 --- a/tox.ini +++ b/tox.ini @@ -13,8 +13,7 @@ deps = -r{toxinidir}/test-requirements.txt whitelist_externals = mkdir protoc commands = -mkdir src-gen - -ls $HOME/.linuxbrew/bin - -$HOME/.linuxbrew/bin/protoc --python_out=src-gen test/fixture.proto + -$BREW_HOME/bin/protoc --python_out=src-gen test/fixture.proto -py.test --timeout=30 --cov-report html --cov-report=term --cov {toxinidir}/google [testenv:pep8] From 00f91217a74fd64d67aeba265716888c1807dd4a Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 14:52:50 -0700 Subject: [PATCH 16/19] No need to redirect stderr --- install-protobuf3.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install-protobuf3.sh b/install-protobuf3.sh index b5ebe34..8e17c60 100755 --- a/install-protobuf3.sh +++ b/install-protobuf3.sh @@ -3,9 +3,9 @@ export PATH="$BREW_HOME/bin:$PATH" echo "Testing for protoc command" -command -v protoc 2>&1 || { +command -v protoc || { echo "Testing for brew command" - command -v brew 2>&1 || { + command -v brew || { echo "Installing brew" # install brew in headless mode to avoid user prompt requiring input Date: Wed, 22 Jun 2016 15:06:41 -0700 Subject: [PATCH 17/19] Pass BREW_HOME into test environment --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 549c238..dd1fc7f 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ envlist = py27,pep8,pylint-errors,pylint-full 2.7 = py27, pep8, pylint-full, docs [testenv] +passenv = BREW_HOME setenv = PYTHONPATH = {toxinidir}:{toxinidir}/src-gen/test From df7d11d50dd8d7bbf445aa2432ff363d67bd7585 Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 15:21:14 -0700 Subject: [PATCH 18/19] Use environment variable correctly in tox.ini --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index dd1fc7f..193501e 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,6 @@ envlist = py27,pep8,pylint-errors,pylint-full 2.7 = py27, pep8, pylint-full, docs [testenv] -passenv = BREW_HOME setenv = PYTHONPATH = {toxinidir}:{toxinidir}/src-gen/test @@ -14,7 +13,7 @@ deps = -r{toxinidir}/test-requirements.txt whitelist_externals = mkdir protoc commands = -mkdir src-gen - -$BREW_HOME/bin/protoc --python_out=src-gen test/fixture.proto + -{env:BREW_HOME}/bin/protoc --python_out=src-gen test/fixture.proto -py.test --timeout=30 --cov-report html --cov-report=term --cov {toxinidir}/google [testenv:pep8] From 8826e7ff8f9d0a516036ba28acb3a207a5557429 Mon Sep 17 00:00:00 2001 From: "Brian J. Watson" Date: Wed, 22 Jun 2016 15:45:11 -0700 Subject: [PATCH 19/19] Add TODO comment based on PR feedback --- google/gax/bundling.py | 1 + 1 file changed, 1 insertion(+) diff --git a/google/gax/bundling.py b/google/gax/bundling.py index bf6dd31..a24d8d7 100644 --- a/google/gax/bundling.py +++ b/google/gax/bundling.py @@ -188,6 +188,7 @@ def _run_with_subresponses(self, req, subresponse_field, kwargs): for i, event in zip(in_sizes, self._event_deque): next_copy = copy.copy(resp) subresponses = all_subresponses[start:start + i] + # TODO: assumes we are using GRPC; abstract into config.py for portability next_copy.ClearField(subresponse_field) getattr(next_copy, subresponse_field).extend(subresponses) start += i