Skip to content

Commit

Permalink
fix: update retry and timeout settings (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored Dec 29, 2020
1 parent 7460730 commit 00c0187
Show file tree
Hide file tree
Showing 19 changed files with 594 additions and 64 deletions.
1 change: 1 addition & 0 deletions packages/google-cloud-billing/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ exclude =
*_pb2.py

# Standard linting exemptions.
**/.nox/**
__pycache__,
.git,
*.pyc,
Expand Down
17 changes: 17 additions & 0 deletions packages/google-cloud-billing/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
21 changes: 15 additions & 6 deletions packages/google-cloud-billing/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ In order to add a feature:
- The feature must be documented in both the API and narrative
documentation.

- The feature must work fully on the following CPython versions: 2.7,
3.5, 3.6, 3.7 and 3.8 on both UNIX and Windows.
- The feature must work fully on the following CPython versions:
3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows.

- The feature must not add unnecessary dependencies (where
"unnecessary" is of course subjective, but new dependencies should
Expand Down Expand Up @@ -111,6 +111,16 @@ Coding Style
should point to the official ``googleapis`` checkout and the
the branch should be the main branch on that remote (``master``).

- This repository contains configuration for the
`pre-commit <https://pre-commit.com/>`__ tool, which automates checking
our linters during a commit. If you have it installed on your ``$PATH``,
you can enable enforcing those checks via:

.. code-block:: bash
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
Exceptions to PEP8:

- Many unit tests use a helper method, ``_call_fut`` ("FUT" is short for
Expand Down Expand Up @@ -192,25 +202,24 @@ Supported Python Versions

We support:

- `Python 3.5`_
- `Python 3.6`_
- `Python 3.7`_
- `Python 3.8`_
- `Python 3.9`_

.. _Python 3.5: https://docs.python.org/3.5/
.. _Python 3.6: https://docs.python.org/3.6/
.. _Python 3.7: https://docs.python.org/3.7/
.. _Python 3.8: https://docs.python.org/3.8/
.. _Python 3.9: https://docs.python.org/3.9/


Supported versions can be found in our ``noxfile.py`` `config`_.

.. _config: https://github.com/googleapis/python-billing/blob/master/noxfile.py

Python 2.7 support is deprecated. All code changes should maintain Python 2.7 compatibility until January 1, 2020.

We also explicitly decided to support Python 3 beginning with version
3.5. Reasons for this include:
3.6. Reasons for this include:

- Encouraging use of newest versions of Python 3
- Taking the lead of `prominent`_ open-source `projects`_
Expand Down
6 changes: 3 additions & 3 deletions packages/google-cloud-billing/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,10 @@

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("http://python.readthedocs.org/en/latest/", None),
"google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
"python": ("https://python.readthedocs.org/en/latest/", None),
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
"grpc": ("https://grpc.io/grpc/python/", None),
"grpc": ("https://grpc.github.io/grpc/python/", None),
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"AggregationInfo",
"BillingAccount",
"Category",
"CloudCatalogClient",
"CloudBillingClient",
"CreateBillingAccountRequest",
"GetBillingAccountRequest",
"GetProjectBillingInfoRequest",
Expand All @@ -63,5 +63,5 @@
"Sku",
"UpdateBillingAccountRequest",
"UpdateProjectBillingInfoRequest",
"CloudBillingClient",
"CloudCatalogClient",
)
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,15 @@ async def get_billing_account(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_billing_account,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -252,7 +260,15 @@ async def list_billing_accounts(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_billing_accounts,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -340,7 +356,15 @@ async def update_billing_account(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.update_billing_account,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -426,7 +450,7 @@ async def create_billing_account(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.create_billing_account,
default_timeout=None,
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -499,7 +523,15 @@ async def list_project_billing_info(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_project_billing_info,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -583,7 +615,15 @@ async def get_project_billing_info(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_project_billing_info,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -704,7 +744,15 @@ async def update_project_billing_info(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.update_project_billing_info,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -844,7 +892,15 @@ async def get_iam_policy(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_iam_policy,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -985,7 +1041,15 @@ async def set_iam_policy(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.set_iam_policy,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -1072,7 +1136,15 @@ async def test_iam_permissions(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.test_iam_permissions,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=60.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down
Loading

0 comments on commit 00c0187

Please sign in to comment.