Skip to content
Permalink
Browse files
fix: fix retry deadlines (#119)
feat: add `from_service_account_info`
  • Loading branch information
yoshi-automation committed Mar 30, 2021
1 parent b8d21a4 commit ace604680ff0f2d1b0d458aa5c3eb1e98b4e81b0
Showing with 3,232 additions and 2,061 deletions.
  1. +3 −1 .gitignore
  2. +10 −0 .kokoro/build.sh
  3. +11 −0 .kokoro/samples/python3.6/periodic-head.cfg
  4. +11 −0 .kokoro/samples/python3.7/periodic-head.cfg
  5. +11 −0 .kokoro/samples/python3.8/periodic-head.cfg
  6. +28 −0 .kokoro/test-samples-against-head.sh
  7. +102 −0 .kokoro/test-samples-impl.sh
  8. +16 −80 .kokoro/test-samples.sh
  9. +1 −1 .pre-commit-config.yaml
  10. +3 −3 UPGRADING.md
  11. +34 −2 google/cloud/vision_v1/services/image_annotator/async_client.py
  12. +13 −9 google/cloud/vision_v1/services/image_annotator/transports/base.py
  13. +38 −65 google/cloud/vision_v1/services/image_annotator/transports/grpc.py
  14. +42 −69 google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py
  15. +49 −2 google/cloud/vision_v1/services/product_search/async_client.py
  16. +28 −9 google/cloud/vision_v1/services/product_search/transports/base.py
  17. +38 −65 google/cloud/vision_v1/services/product_search/transports/grpc.py
  18. +42 −69 google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py
  19. +140 −140 google/cloud/vision_v1/types/__init__.py
  20. +31 −2 google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py
  21. +10 −9 google/cloud/vision_v1p1beta1/services/image_annotator/transports/base.py
  22. +37 −64 google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py
  23. +41 −68 google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py
  24. +50 −50 google/cloud/vision_v1p1beta1/types/__init__.py
  25. +32 −2 google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py
  26. +11 −9 google/cloud/vision_v1p2beta1/services/image_annotator/transports/base.py
  27. +38 −65 google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py
  28. +42 −69 google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py
  29. +70 −70 google/cloud/vision_v1p2beta1/types/__init__.py
  30. +32 −2 google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py
  31. +11 −9 google/cloud/vision_v1p3beta1/services/image_annotator/transports/base.py
  32. +38 −65 google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py
  33. +42 −69 google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py
  34. +48 −2 google/cloud/vision_v1p3beta1/services/product_search/async_client.py
  35. +27 −9 google/cloud/vision_v1p3beta1/services/product_search/transports/base.py
  36. +38 −65 google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py
  37. +42 −69 google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py
  38. +134 −134 google/cloud/vision_v1p3beta1/types/__init__.py
  39. +2 −2 google/cloud/vision_v1p4beta1/__init__.py
  40. +34 −2 google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py
  41. +13 −9 google/cloud/vision_v1p4beta1/services/image_annotator/transports/base.py
  42. +38 −65 google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py
  43. +42 −69 google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py
  44. +48 −2 google/cloud/vision_v1p4beta1/services/product_search/async_client.py
  45. +27 −9 google/cloud/vision_v1p4beta1/services/product_search/transports/base.py
  46. +38 −65 google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py
  47. +42 −69 google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py
  48. +147 −147 google/cloud/vision_v1p4beta1/types/__init__.py
  49. +43 −9 noxfile.py
  50. +2 −1 renovate.json
  51. +4 −2 setup.py
  52. +6 −245 synth.metadata
  53. +2 −2 synth.py
  54. 0 testing/constraints-3.10.txt
  55. 0 testing/constraints-3.11.txt
  56. +9 −0 testing/constraints-3.6.txt
  57. 0 testing/constraints-3.7.txt
  58. 0 testing/constraints-3.8.txt
  59. 0 testing/constraints-3.9.txt
  60. +15 −0 tests/unit/gapic/vision_v1/__init__.py
  61. +80 −2 tests/unit/gapic/vision_v1/test_image_annotator.py
  62. +336 −2 tests/unit/gapic/vision_v1/test_product_search.py
  63. +15 −0 tests/unit/gapic/vision_v1p1beta1/__init__.py
  64. +26 −2 tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py
  65. +15 −0 tests/unit/gapic/vision_v1p2beta1/__init__.py
  66. +44 −2 tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py
  67. +15 −0 tests/unit/gapic/vision_v1p3beta1/__init__.py
  68. +44 −2 tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py
  69. +320 −2 tests/unit/gapic/vision_v1p3beta1/test_product_search.py
  70. +15 −0 tests/unit/gapic/vision_v1p4beta1/__init__.py
  71. +80 −2 tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py
  72. +336 −2 tests/unit/gapic/vision_v1p4beta1/test_product_search.py
@@ -50,8 +50,10 @@ docs.metadata

# Virtual environment
env/

# Test logs
coverage.xml
sponge_log.xml
*sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
@@ -40,6 +40,16 @@ python3 -m pip uninstall --yes --quiet nox-automation
python3 -m pip install --upgrade --quiet nox
python3 -m nox --version

# If this is a continuous build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap cleanup EXIT HUP
fi

# If NOX_SESSION is set, it only runs the specified session,
# otherwise run all the sessions.
if [[ -n "${NOX_SESSION:-}" ]]; then
@@ -0,0 +1,11 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
}
@@ -0,0 +1,11 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
}
@@ -0,0 +1,11 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
}
@@ -0,0 +1,28 @@
#!/bin/bash
# Copyright 2020 Google LLC
#
# 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
#
# https://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.

# A customized test runner for samples.
#
# For periodic builds, you can specify this file for testing against head.

# `-e` enables the script to automatically fail when a command fails
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
set -eo pipefail
# Enables `**` to include files nested inside sub-folders
shopt -s globstar

cd github/python-vision

exec .kokoro/test-samples-impl.sh
@@ -0,0 +1,102 @@
#!/bin/bash
# Copyright 2021 Google LLC
#
# 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
#
# https://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.


# `-e` enables the script to automatically fail when a command fails
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
set -eo pipefail
# Enables `**` to include files nested inside sub-folders
shopt -s globstar

# Exit early if samples directory doesn't exist
if [ ! -d "./samples" ]; then
echo "No tests run. `./samples` not found"
exit 0
fi

# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1

# Debug: show build environment
env | grep KOKORO

# Install nox
python3.6 -m pip install --upgrade --quiet nox

# Use secrets acessor service account to get secrets
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then
gcloud auth activate-service-account \
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \
--project="cloud-devrel-kokoro-resources"
fi

# This script will create 3 files:
# - testing/test-env.sh
# - testing/service-account.json
# - testing/client-secrets.json
./scripts/decrypt-secrets.sh

source ./testing/test-env.sh
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json

# For cloud-run session, we activate the service account for gcloud sdk.
gcloud auth activate-service-account \
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}"

export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json

echo -e "\n******************** TESTING PROJECTS ********************"

# Switch to 'fail at end' to allow all tests to complete before exiting.
set +e
# Use RTN to return a non-zero value if the test fails.
RTN=0
ROOT=$(pwd)
# Find all requirements.txt in the samples directory (may break on whitespace).
for file in samples/**/requirements.txt; do
cd "$ROOT"
# Navigate to the project folder.
file=$(dirname "$file")
cd "$file"

echo "------------------------------------------------------------"
echo "- testing $file"
echo "------------------------------------------------------------"

# Use nox to execute the tests for the project.
python3.6 -m nox -s "$RUN_TESTS_SESSION"
EXIT=$?

# If this is a periodic build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
fi

if [[ $EXIT -ne 0 ]]; then
RTN=1
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
else
echo -e "\n Testing completed.\n"
fi

done
cd "$ROOT"

# Workaround for Kokoro permissions issue: delete secrets
rm testing/{test-env.sh,client-secrets.json,service-account.json}

exit "$RTN"
@@ -13,6 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# The default test runner for samples.
#
# For periodic builds, we rewinds the repo to the latest release, and
# run test-samples-impl.sh.

# `-e` enables the script to automatically fail when a command fails
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
@@ -24,87 +28,19 @@ cd github/python-vision

# Run periodic samples tests at latest release
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
# preserving the test runner implementation.
cp .kokoro/test-samples-impl.sh "${TMPDIR}/test-samples-impl.sh"
echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
echo "Now we rewind the repo back to the latest release..."
LATEST_RELEASE=$(git describe --abbrev=0 --tags)
git checkout $LATEST_RELEASE
fi

# Exit early if samples directory doesn't exist
if [ ! -d "./samples" ]; then
echo "No tests run. `./samples` not found"
exit 0
fi

# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1

# Debug: show build environment
env | grep KOKORO

# Install nox
python3.6 -m pip install --upgrade --quiet nox

# Use secrets acessor service account to get secrets
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then
gcloud auth activate-service-account \
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \
--project="cloud-devrel-kokoro-resources"
fi

# This script will create 3 files:
# - testing/test-env.sh
# - testing/service-account.json
# - testing/client-secrets.json
./scripts/decrypt-secrets.sh

source ./testing/test-env.sh
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json

# For cloud-run session, we activate the service account for gcloud sdk.
gcloud auth activate-service-account \
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}"

export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json

echo -e "\n******************** TESTING PROJECTS ********************"

# Switch to 'fail at end' to allow all tests to complete before exiting.
set +e
# Use RTN to return a non-zero value if the test fails.
RTN=0
ROOT=$(pwd)
# Find all requirements.txt in the samples directory (may break on whitespace).
for file in samples/**/requirements.txt; do
cd "$ROOT"
# Navigate to the project folder.
file=$(dirname "$file")
cd "$file"

echo "------------------------------------------------------------"
echo "- testing $file"
echo "------------------------------------------------------------"

# Use nox to execute the tests for the project.
python3.6 -m nox -s "$RUN_TESTS_SESSION"
EXIT=$?

# If this is a periodic build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
echo "The current head is: "
echo $(git rev-parse --verify HEAD)
echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
# move back the test runner implementation if there's no file.
if [ ! -f .kokoro/test-samples-impl.sh ]; then
cp "${TMPDIR}/test-samples-impl.sh" .kokoro/test-samples-impl.sh
fi
fi

if [[ $EXIT -ne 0 ]]; then
RTN=1
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
else
echo -e "\n Testing completed.\n"
fi

done
cd "$ROOT"

# Workaround for Kokoro permissions issue: delete secrets
rm testing/{test-env.sh,client-secrets.json,service-account.json}

exit "$RTN"
exec .kokoro/test-samples-impl.sh
@@ -12,6 +12,6 @@ repos:
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.0
hooks:
- id: flake8
@@ -17,10 +17,10 @@ The 2.0.0 release requires Python 3.6+.
Methods expect request objects. We provide a script that will convert most common use cases.

* Install the library
* Install the library with `libcst`.

```py
python3 -m pip install google-cloud-vision
python3 -m pip install google-cloud-vision[libcst]
```

* The script `fixup_vision_v1_keywords.py` is shipped with the library. It expects
@@ -159,4 +159,4 @@ project = "my-project"
location = "location"
location_path = f"projects/{project}/locations/{location}"
```
```
Loading

0 comments on commit ace6046

Please sign in to comment.