Skip to content
Permalink
Browse files
chore: regenerate (#22)
fix: BREAKING rename `PriceRange.min` to `PriceRange.min_`, `PriceRange.max` to `PriceRange.max_`

fix: fix bug with enums closes #14, #20

feat: add async clients

feat: add common resource helper methods
  • Loading branch information
yoshi-automation committed Mar 29, 2021
1 parent fe7e6ed commit f8e3d0f8d12921b926c24cf33e10c4d4390164bb
Showing with 18,328 additions and 2,720 deletions.
  1. +20 −1 .flake8
  2. +1 −2 .github/ISSUE_TEMPLATE/bug_report.md
  3. +15 −0 .github/header-checker-lint.yml
  4. 0 .github/snippet-bot.yml
  5. +7 −2 .gitignore
  6. +26 −6 .kokoro/build.sh
  7. +98 −0 .kokoro/docker/docs/Dockerfile
  8. +45 −0 .kokoro/docker/docs/fetch_gpg_keys.sh
  9. +19 −2 .kokoro/docs/common.cfg
  10. +28 −0 .kokoro/docs/docs-presubmit.cfg
  11. +43 −0 .kokoro/populate-secrets.sh
  12. +24 −17 .kokoro/publish-docs.sh
  13. +0 −2 .kokoro/release.sh
  14. +13 −37 .kokoro/release/common.cfg
  15. +34 −0 .kokoro/samples/lint/common.cfg
  16. +6 −0 .kokoro/samples/lint/continuous.cfg
  17. +6 −0 .kokoro/samples/lint/periodic.cfg
  18. +6 −0 .kokoro/samples/lint/presubmit.cfg
  19. +40 −0 .kokoro/samples/python3.6/common.cfg
  20. +7 −0 .kokoro/samples/python3.6/continuous.cfg
  21. +11 −0 .kokoro/samples/python3.6/periodic-head.cfg
  22. +6 −0 .kokoro/samples/python3.6/periodic.cfg
  23. +6 −0 .kokoro/samples/python3.6/presubmit.cfg
  24. +40 −0 .kokoro/samples/python3.7/common.cfg
  25. +6 −0 .kokoro/samples/python3.7/continuous.cfg
  26. +11 −0 .kokoro/samples/python3.7/periodic-head.cfg
  27. +6 −0 .kokoro/samples/python3.7/periodic.cfg
  28. +6 −0 .kokoro/samples/python3.7/presubmit.cfg
  29. +40 −0 .kokoro/samples/python3.8/common.cfg
  30. +6 −0 .kokoro/samples/python3.8/continuous.cfg
  31. +11 −0 .kokoro/samples/python3.8/periodic-head.cfg
  32. +6 −0 .kokoro/samples/python3.8/periodic.cfg
  33. +6 −0 .kokoro/samples/python3.8/presubmit.cfg
  34. +28 −0 .kokoro/test-samples-against-head.sh
  35. +102 −0 .kokoro/test-samples-impl.sh
  36. +46 −0 .kokoro/test-samples.sh
  37. +10 −5 .kokoro/trampoline.sh
  38. +487 −0 .kokoro/trampoline_v2.sh
  39. +17 −0 .pre-commit-config.yaml
  40. +52 −0 .trampolinerc
  41. +87 −36 CODE_OF_CONDUCT.md
  42. +35 −40 CONTRIBUTING.rst
  43. +4 −3 LICENSE
  44. +20 −1 MANIFEST.in
  45. +6 −1 docs/_static/custom.css
  46. +2 −2 docs/_templates/layout.html
  47. +19 −11 docs/conf.py
  48. +3 −1 docs/index.rst
  49. +7 −0 docs/multiprocessing.rst
  50. +11 −0 docs/recommendationengine_v1beta1/catalog_service.rst
  51. +11 −0 docs/recommendationengine_v1beta1/prediction_api_key_registry.rst
  52. +11 −0 docs/recommendationengine_v1beta1/prediction_service.rst
  53. +8 −5 docs/recommendationengine_v1beta1/services.rst
  54. +4 −2 docs/recommendationengine_v1beta1/types.rst
  55. +11 −0 docs/recommendationengine_v1beta1/user_event_service.rst
  56. +17 −2 google/cloud/recommendationengine/__init__.py
  57. +3 −4 google/cloud/recommendationengine_v1beta1/__init__.py
  58. +1 −1 google/cloud/recommendationengine_v1beta1/services/__init__.py
  59. +6 −2 google/cloud/recommendationengine_v1beta1/services/catalog_service/__init__.py
  60. +778 −0 google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py
  61. +480 −101 google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py
  62. +88 −11 google/cloud/recommendationengine_v1beta1/services/catalog_service/pagers.py
  63. +8 −3 google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/__init__.py
  64. +172 −24 google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/base.py
  65. +144 −38 google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py
  66. +424 −0 google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc_asyncio.py
  67. +6 −2 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/__init__.py
  68. +470 −0 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py
  69. +405 −53 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py
  70. +103 −12 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/pagers.py
  71. +8 −3 ...le/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/__init__.py
  72. +116 −14 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/base.py
  73. +137 −30 google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py
  74. +336 −0 ...loud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc_asyncio.py
  75. +6 −2 google/cloud/recommendationengine_v1beta1/services/prediction_service/__init__.py
  76. +327 −0 google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py
  77. +330 −28 google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py
  78. +90 −10 google/cloud/recommendationengine_v1beta1/services/prediction_service/pagers.py
  79. +8 −3 google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/__init__.py
  80. +76 −8 google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/base.py
  81. +135 −28 google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py
  82. +262 −0 google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc_asyncio.py
  83. +6 −2 google/cloud/recommendationengine_v1beta1/services/user_event_service/__init__.py
  84. +864 −0 google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py
  85. +626 −112 google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py
  86. +88 −11 google/cloud/recommendationengine_v1beta1/services/user_event_service/pagers.py
  87. +8 −3 google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/__init__.py
  88. +153 −22 google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/base.py
  89. +146 −40 google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py
  90. +407 −0 google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc_asyncio.py
  91. +73 −67 google/cloud/recommendationengine_v1beta1/types/__init__.py
  92. +48 −21 google/cloud/recommendationengine_v1beta1/types/catalog.py
  93. +16 −9 google/cloud/recommendationengine_v1beta1/types/catalog_service.py
  94. +7 −6 google/cloud/recommendationengine_v1beta1/types/common.py
  95. +53 −34 google/cloud/recommendationengine_v1beta1/types/import_.py
  96. +9 −5 google/cloud/recommendationengine_v1beta1/types/prediction_apikey_registry_service.py
  97. +28 −13 google/cloud/recommendationengine_v1beta1/types/prediction_service.py
  98. +24 −0 google/cloud/recommendationengine_v1beta1/types/recommendationengine_resources.py
  99. +55 −25 google/cloud/recommendationengine_v1beta1/types/user_event.py
  100. +21 −9 google/cloud/recommendationengine_v1beta1/types/user_event_service.py
  101. +1 −1 mypy.ini
  102. +107 −22 noxfile.py
  103. +2 −1 renovate.json
  104. +46 −0 scripts/decrypt-secrets.sh
  105. +193 −0 scripts/fixup_recommendationengine_v1beta1_keywords.py
  106. +66 −0 scripts/readme-gen/readme_gen.py
  107. +87 −0 scripts/readme-gen/templates/README.tmpl.rst
  108. +9 −0 scripts/readme-gen/templates/auth.tmpl.rst
  109. +14 −0 scripts/readme-gen/templates/auth_api_key.tmpl.rst
  110. +29 −0 scripts/readme-gen/templates/install_deps.tmpl.rst
  111. +35 −0 scripts/readme-gen/templates/install_portaudio.tmpl.rst
  112. +16 −0 setup.cfg
  113. +3 −6 setup.py
  114. +16 −9 synth.metadata
  115. +68 −23 synth.py
  116. +3 −0 testing/.gitignore
  117. +9 −0 testing/constraints-3.6.txt
  118. +2 −0 testing/constraints-3.7.txt
  119. +2 −0 testing/constraints-3.8.txt
  120. +2 −0 testing/constraints-3.9.txt
  121. +16 −0 tests/unit/gapic/recommendationengine_v1beta1/__init__.py
  122. +2,650 −0 tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py
  123. +2,020 −0 tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py
  124. +1,380 −0 tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py
  125. +2,404 −0 tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py
  126. +0 −614 tests/unit/recommendationengine_v1beta1/test_catalog_service.py
  127. +0 −387 tests/unit/recommendationengine_v1beta1/test_prediction_api_key_registry.py
  128. +0 −265 tests/unit/recommendationengine_v1beta1/test_prediction_service.py
  129. +0 −458 tests/unit/recommendationengine_v1beta1/test_user_event_service.py
21 .flake8
@@ -1,13 +1,32 @@
# -*- coding: utf-8 -*-
#
# 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.

# Generated by synthtool. DO NOT EDIT!
[flake8]
ignore = E203, E266, E501, W503, F401, F841
ignore = E203, E266, E501, W503
exclude =
# Exclude generated code.
**/proto/**
**/gapic/**
**/services/**
**/types/**
*_pb2.py

# Standard linting exemptions.
**/.nox/**
__pycache__,
.git,
*.pyc,
@@ -11,8 +11,7 @@ Thanks for stopping by to let us know something could be better!
Please run down the following list and make sure you've tried the usual "quick fixes":

- Search the issues already opened: https://github.com/googleapis/python-recommendations-ai/issues
- Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-python
- Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+python
- Search StackOverflow: https://stackoverflow.com/questions/tagged/google-cloud-platform+python

If you are still having issues, please be sure to include as much information as possible:

@@ -0,0 +1,15 @@
{"allowedCopyrightHolders": ["Google LLC"],
"allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"],
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"],
"sourceFileExtensions": [
"ts",
"js",
"java",
"sh",
"Dockerfile",
"yaml",
"py",
"html",
"txt"
]
}
Empty file.
@@ -10,6 +10,7 @@
dist
build
eggs
.eggs
parts
bin
var
@@ -44,15 +45,19 @@ pip-log.txt

# Built documentation
docs/_build
htmlcov
bigquery/docs/generated
docs.metadata

# Virtual environment
env/

# Test logs
coverage.xml
*sponge_log.xml

# System test environment variables.
system_tests/local_test_setup

# Make sure a generated file isn't accidentally committed.
pylintrc
pylintrc.test
pylintrc.test
@@ -15,7 +15,11 @@

set -eo pipefail

cd github/python-recommendations-ai
if [[ -z "${PROJECT_ROOT:-}" ]]; then
PROJECT_ROOT="github/python-recommendations-ai"
fi

cd "${PROJECT_ROOT}"

# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1
@@ -30,10 +34,26 @@ 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.6 -m nox
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
python3 -m nox -s ${NOX_SESSION:-}
else
python3 -m nox
fi
@@ -0,0 +1,98 @@
# 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
#
# 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.

from ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive

# Ensure local Python is preferred over distribution Python.
ENV PATH /usr/local/bin:$PATH

# Install dependencies.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
build-essential \
ca-certificates \
curl \
dirmngr \
git \
gpg-agent \
graphviz \
libbz2-dev \
libdb5.3-dev \
libexpat1-dev \
libffi-dev \
liblzma-dev \
libreadline-dev \
libsnappy-dev \
libssl-dev \
libsqlite3-dev \
portaudio19-dev \
redis-server \
software-properties-common \
ssh \
sudo \
tcl \
tcl-dev \
tk \
tk-dev \
uuid-dev \
wget \
zlib1g-dev \
&& add-apt-repository universe \
&& apt-get update \
&& apt-get -y install jq \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -f /var/cache/apt/archives/*.deb


COPY fetch_gpg_keys.sh /tmp
# Install the desired versions of Python.
RUN set -ex \
&& export GNUPGHOME="$(mktemp -d)" \
&& echo "disable-ipv6" >> "${GNUPGHOME}/dirmngr.conf" \
&& /tmp/fetch_gpg_keys.sh \
&& for PYTHON_VERSION in 3.7.8 3.8.5; do \
wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
&& wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
&& gpg --batch --verify python-${PYTHON_VERSION}.tar.xz.asc python-${PYTHON_VERSION}.tar.xz \
&& rm -r python-${PYTHON_VERSION}.tar.xz.asc \
&& mkdir -p /usr/src/python-${PYTHON_VERSION} \
&& tar -xJC /usr/src/python-${PYTHON_VERSION} --strip-components=1 -f python-${PYTHON_VERSION}.tar.xz \
&& rm python-${PYTHON_VERSION}.tar.xz \
&& cd /usr/src/python-${PYTHON_VERSION} \
&& ./configure \
--enable-shared \
# This works only on Python 2.7 and throws a warning on every other
# version, but seems otherwise harmless.
--enable-unicode=ucs4 \
--with-system-ffi \
--without-ensurepip \
&& make -j$(nproc) \
&& make install \
&& ldconfig \
; done \
&& rm -rf "${GNUPGHOME}" \
&& rm -rf /usr/src/python* \
&& rm -rf ~/.cache/

RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
&& python3.7 /tmp/get-pip.py \
&& python3.8 /tmp/get-pip.py \
&& rm /tmp/get-pip.py

CMD ["python3.7"]
@@ -0,0 +1,45 @@
#!/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
#
# 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.

# A script to fetch gpg keys with retry.
# Avoid jinja parsing the file.
#

function retry {
if [[ "${#}" -le 1 ]]; then
echo "Usage: ${0} retry_count commands.."
exit 1
fi
local retries=${1}
local command="${@:2}"
until [[ "${retries}" -le 0 ]]; do
$command && return 0
if [[ $? -ne 0 ]]; then
echo "command failed, retrying"
((retries--))
fi
done
return 1
}

# 3.6.9, 3.7.5 (Ned Deily)
retry 3 gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \
0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D

# 3.8.0 (Łukasz Langa)
retry 3 gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \
E3FF2839C048B25C084DEBE9B26995E310250568

#
@@ -11,12 +11,12 @@ action {
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-recommendations-ai/.kokoro/trampoline.sh"
build_file: "python-recommendations-ai/.kokoro/trampoline_v2.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
value: "gcr.io/cloud-devrel-kokoro-resources/python-lib-docs"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
@@ -28,6 +28,23 @@ env_vars: {
value: "docs-staging"
}

env_vars: {
key: "V2_STAGING_BUCKET"
value: "docs-staging-v2"
}

# It will upload the docker image after successful builds.
env_vars: {
key: "TRAMPOLINE_IMAGE_UPLOAD"
value: "true"
}

# It will always build the docker image.
env_vars: {
key: "TRAMPOLINE_DOCKERFILE"
value: ".kokoro/docker/docs/Dockerfile"
}

# Fetch the token needed for reporting release status to GitHub
before_action {
fetch_keystore {
@@ -0,0 +1,28 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "STAGING_BUCKET"
value: "gcloud-python-test"
}

env_vars: {
key: "V2_STAGING_BUCKET"
value: "gcloud-python-test"
}

# We only upload the image in the main `docs` build.
env_vars: {
key: "TRAMPOLINE_IMAGE_UPLOAD"
value: "false"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-recommendations-ai/.kokoro/build.sh"
}

# Only run this nox session.
env_vars: {
key: "NOX_SESSION"
value: "docs docfx"
}
@@ -0,0 +1,43 @@
#!/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
#
# 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.

set -eo pipefail

function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
function msg { println "$*" >&2 ;}
function println { printf '%s\n' "$(now) $*" ;}


# Populates requested secrets set in SECRET_MANAGER_KEYS from service account:
# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
mkdir -p ${SECRET_LOCATION}
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
do
msg "Retrieving secret ${key}"
docker run --entrypoint=gcloud \
--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \
gcr.io/google.com/cloudsdktool/cloud-sdk \
secrets versions access latest \
--project cloud-devrel-kokoro-resources \
--secret ${key} > \
"${SECRET_LOCATION}/${key}"
if [[ $? == 0 ]]; then
msg "Secret written to ${SECRET_LOCATION}/${key}"
else
msg "Error retrieving secret ${key}"
fi
done
Loading

0 comments on commit f8e3d0f

Please sign in to comment.