From 84cfb979a6c5f51b3e0b593dd5bacffa4471b48e Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 15 Jan 2021 11:07:01 -0800 Subject: [PATCH 1/5] chore: tweak kokoro config (via synth) (#129) * chore(python): skip docfx in main presubmit * chore(python): skip docfx in main presubmit * fix: properly template the repo name Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Source-Date: Fri Jan 8 10:32:13 2021 -0700 Source-Repo: googleapis/synthtool Source-Sha: fb53b6fb373b7c3edf4e55f3e8036bc6d73fa483 Source-Link: https://github.com/googleapis/synthtool/commit/fb53b6fb373b7c3edf4e55f3e8036bc6d73fa483 * chore: add missing quotation mark Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Source-Date: Mon Jan 11 09:43:06 2021 -0700 Source-Repo: googleapis/synthtool Source-Sha: 16ec872dd898d7de6e1822badfac32484b5d9031 Source-Link: https://github.com/googleapis/synthtool/commit/16ec872dd898d7de6e1822badfac32484b5d9031 --- .kokoro/build.sh | 16 ++++++++++------ .kokoro/docs/docs-presubmit.cfg | 11 +++++++++++ .trampolinerc | 2 ++ synth.metadata | 4 ++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index adc4be46..41a88d59 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -15,7 +15,11 @@ set -eo pipefail -cd github/python-api-core +if [[ -z "${PROJECT_ROOT:-}" ]]; then + PROJECT_ROOT="github/python-api-core" +fi + +cd "${PROJECT_ROOT}" # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 @@ -30,16 +34,16 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json") # Remove old nox -python3.6 -m pip uninstall --yes --quiet nox-automation +python3 -m pip uninstall --yes --quiet nox-automation # Install nox -python3.6 -m pip install --upgrade --quiet nox -python3.6 -m nox --version +python3 -m pip install --upgrade --quiet nox +python3 -m nox --version # If NOX_SESSION is set, it only runs the specified session, # otherwise run all the sessions. if [[ -n "${NOX_SESSION:-}" ]]; then - python3.6 -m nox -s "${NOX_SESSION:-}" + python3 -m nox -s ${NOX_SESSION:-} else - python3.6 -m nox + python3 -m nox fi diff --git a/.kokoro/docs/docs-presubmit.cfg b/.kokoro/docs/docs-presubmit.cfg index 11181078..d1ed51eb 100644 --- a/.kokoro/docs/docs-presubmit.cfg +++ b/.kokoro/docs/docs-presubmit.cfg @@ -15,3 +15,14 @@ env_vars: { key: "TRAMPOLINE_IMAGE_UPLOAD" value: "false" } + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-api-core/.kokoro/build.sh" +} + +# Only run this nox session. +env_vars: { + key: "NOX_SESSION" + value: "docs docfx" +} diff --git a/.trampolinerc b/.trampolinerc index 995ee291..c7d663ae 100644 --- a/.trampolinerc +++ b/.trampolinerc @@ -18,12 +18,14 @@ required_envvars+=( "STAGING_BUCKET" "V2_STAGING_BUCKET" + "NOX_SESSION" ) # Add env vars which are passed down into the container here. pass_down_envvars+=( "STAGING_BUCKET" "V2_STAGING_BUCKET" + "NOX_SESSION" ) # Prevent unintentional override on the default image. diff --git a/synth.metadata b/synth.metadata index 1e35d075..d10948c9 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-api-core.git", - "sha": "b51b7f587042fe9340371c1b5c8e9adf8001c43a" + "sha": "abc3d88466a1e55cf459e6c78a6fb7343a29df6f" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "41a4e56982620d3edcf110d76f4fcdfdec471ac8" + "sha": "16ec872dd898d7de6e1822badfac32484b5d9031" } } ], From 232dab0ad3ef2cca0edfe707d8f90ca0ea200ba2 Mon Sep 17 00:00:00 2001 From: Juncheng LIU <37217311+JunchengL@users.noreply.github.com> Date: Fri, 15 Jan 2021 23:20:02 +0100 Subject: [PATCH 2/5] docs: fix spelling errors in retry (#131) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-api-core/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [NA] Ensure the tests and linter pass - [NA] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) Fixes #130 🦕 --- google/api_core/retry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/google/api_core/retry.py b/google/api_core/retry.py index ea890628..592d34fa 100644 --- a/google/api_core/retry.py +++ b/google/api_core/retry.py @@ -230,9 +230,9 @@ class Retry(object): Args: predicate (Callable[Exception]): A callable that should return ``True`` if the given exception is retryable. - initial (float): The minimum a,out of time to delay in seconds. This + initial (float): The minimum amount of time to delay in seconds. This must be greater than 0. - maximum (float): The maximum amout of time to delay in seconds. + maximum (float): The maximum amount of time to delay in seconds. multiplier (float): The multiplier applied to the delay. deadline (float): How long to keep retrying in seconds. The last sleep period is shortened as necessary, so that the last retry runs at From a47dfba3d43d403e6331992a386ec6d2202ee3da Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 20 Jan 2021 07:48:05 -0800 Subject: [PATCH 3/5] build(python): make `NOX_SESSION` optional (#135) I added this accidentally in #889. `NOX_SESSION` should be passed down if it is set but not marked required. Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Source-Date: Tue Jan 19 09:38:04 2021 -0700 Source-Repo: googleapis/synthtool Source-Sha: ba960d730416fe05c50547e975ce79fcee52c671 Source-Link: https://github.com/googleapis/synthtool/commit/ba960d730416fe05c50547e975ce79fcee52c671 --- .trampolinerc | 1 - synth.metadata | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.trampolinerc b/.trampolinerc index c7d663ae..383b6ec8 100644 --- a/.trampolinerc +++ b/.trampolinerc @@ -18,7 +18,6 @@ required_envvars+=( "STAGING_BUCKET" "V2_STAGING_BUCKET" - "NOX_SESSION" ) # Add env vars which are passed down into the container here. diff --git a/synth.metadata b/synth.metadata index d10948c9..fd863114 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-api-core.git", - "sha": "abc3d88466a1e55cf459e6c78a6fb7343a29df6f" + "sha": "232dab0ad3ef2cca0edfe707d8f90ca0ea200ba2" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "16ec872dd898d7de6e1822badfac32484b5d9031" + "sha": "ba960d730416fe05c50547e975ce79fcee52c671" } } ], From 97cef4ad1db55938715f9ac8000d1b0ad1e71873 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Mon, 25 Jan 2021 12:49:39 -0700 Subject: [PATCH 4/5] fix: add operation name to x-goog-request-params (#133) --- .../operations_v1/operations_client.py | 19 ++++++++++++++++++ .../operations_v1/test_operations_client.py | 20 +++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/google/api_core/operations_v1/operations_client.py b/google/api_core/operations_v1/operations_client.py index b8507964..b1218cfe 100644 --- a/google/api_core/operations_v1/operations_client.py +++ b/google/api_core/operations_v1/operations_client.py @@ -134,6 +134,11 @@ def get_operation( subclass will be raised. """ request = operations_pb2.GetOperationRequest(name=name) + + # Add routing header + metadata = metadata or [] + metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name})) + return self._get_operation(request, retry=retry, timeout=timeout, metadata=metadata) def list_operations( @@ -196,6 +201,10 @@ def list_operations( # Create the request object. request = operations_pb2.ListOperationsRequest(name=name, filter=filter_) + # Add routing header + metadata = metadata or [] + metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name})) + # Create the method used to fetch pages method = functools.partial(self._list_operations, retry=retry, timeout=timeout, metadata=metadata) @@ -260,6 +269,11 @@ def cancel_operation( """ # Create the request object. request = operations_pb2.CancelOperationRequest(name=name) + + # Add routing header + metadata = metadata or [] + metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name})) + self._cancel_operation(request, retry=retry, timeout=timeout, metadata=metadata) def delete_operation( @@ -306,4 +320,9 @@ def delete_operation( """ # Create the request object. request = operations_pb2.DeleteOperationRequest(name=name) + + # Add routing header + metadata = metadata or [] + metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name})) + self._delete_operation(request, retry=retry, timeout=timeout, metadata=metadata) diff --git a/tests/unit/operations_v1/test_operations_client.py b/tests/unit/operations_v1/test_operations_client.py index bd7f3736..ed19b7f3 100644 --- a/tests/unit/operations_v1/test_operations_client.py +++ b/tests/unit/operations_v1/test_operations_client.py @@ -24,9 +24,10 @@ def test_get_operation(): client = operations_v1.OperationsClient(channel) channel.GetOperation.response = operations_pb2.Operation(name="meep") - response = client.get_operation("name", metadata=[("x-goog-request-params", "foo")]) + response = client.get_operation("name", metadata=[("header", "foo")]) - assert ("x-goog-request-params", "foo") in channel.GetOperation.calls[0].metadata + assert ("header", "foo") in channel.GetOperation.calls[0].metadata + assert ("x-goog-request-params", "name=name") in channel.GetOperation.calls[0].metadata assert len(channel.GetOperation.requests) == 1 assert channel.GetOperation.requests[0].name == "name" assert response == channel.GetOperation.response @@ -42,12 +43,13 @@ def test_list_operations(): list_response = operations_pb2.ListOperationsResponse(operations=operations) channel.ListOperations.response = list_response - response = client.list_operations("name", "filter", metadata=[("x-goog-request-params", "foo")]) + response = client.list_operations("name", "filter", metadata=[("header", "foo")]) assert isinstance(response, page_iterator.Iterator) assert list(response) == operations - assert ("x-goog-request-params", "foo") in channel.ListOperations.calls[0].metadata + assert ("header", "foo") in channel.ListOperations.calls[0].metadata + assert ("x-goog-request-params", "name=name") in channel.ListOperations.calls[0].metadata assert len(channel.ListOperations.requests) == 1 request = channel.ListOperations.requests[0] assert isinstance(request, operations_pb2.ListOperationsRequest) @@ -60,9 +62,10 @@ def test_delete_operation(): client = operations_v1.OperationsClient(channel) channel.DeleteOperation.response = empty_pb2.Empty() - client.delete_operation("name", metadata=[("x-goog-request-params", "foo")]) + client.delete_operation("name", metadata=[("header", "foo")]) - assert ("x-goog-request-params", "foo") in channel.DeleteOperation.calls[0].metadata + assert ("header", "foo") in channel.DeleteOperation.calls[0].metadata + assert ("x-goog-request-params", "name=name") in channel.DeleteOperation.calls[0].metadata assert len(channel.DeleteOperation.requests) == 1 assert channel.DeleteOperation.requests[0].name == "name" @@ -72,8 +75,9 @@ def test_cancel_operation(): client = operations_v1.OperationsClient(channel) channel.CancelOperation.response = empty_pb2.Empty() - client.cancel_operation("name", metadata=[("x-goog-request-params", "foo")]) + client.cancel_operation("name", metadata=[("header", "foo")]) - assert ("x-goog-request-params", "foo") in channel.CancelOperation.calls[0].metadata + assert ("header", "foo") in channel.CancelOperation.calls[0].metadata + assert ("x-goog-request-params", "name=name") in channel.CancelOperation.calls[0].metadata assert len(channel.CancelOperation.requests) == 1 assert channel.CancelOperation.requests[0].name == "name" From 5e8923f541b8482a05ab46554b108a2efcc615a9 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 25 Jan 2021 12:50:21 -0700 Subject: [PATCH 5/5] chore: release 1.25.1 (#132) --- CHANGELOG.md | 12 ++++++++++++ google/api_core/version.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7a70077..b4ff7fd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://pypi.org/project/google-api-core/#history +### [1.25.1](https://www.github.com/googleapis/python-api-core/compare/v1.25.0...v1.25.1) (2021-01-25) + + +### Bug Fixes + +* add operation name to x-goog-request-params ([#133](https://www.github.com/googleapis/python-api-core/issues/133)) ([97cef4a](https://www.github.com/googleapis/python-api-core/commit/97cef4ad1db55938715f9ac8000d1b0ad1e71873)) + + +### Documentation + +* fix spelling errors in retry ([#131](https://www.github.com/googleapis/python-api-core/issues/131)) ([232dab0](https://www.github.com/googleapis/python-api-core/commit/232dab0ad3ef2cca0edfe707d8f90ca0ea200ba2)) + ## [1.25.0](https://www.github.com/googleapis/python-api-core/compare/v1.24.1...v1.25.0) (2021-01-14) diff --git a/google/api_core/version.py b/google/api_core/version.py index 327a56e2..5966ec4e 100644 --- a/google/api_core/version.py +++ b/google/api_core/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.25.0" +__version__ = "1.25.1"