Skip to content

fix: fix broken import for google.api_core.retry_async.AsyncRetry #587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/retry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Retry in AsyncIO

.. automodule:: google.api_core.retry_async
:members:
:noindex:
:show-inheritance:
3 changes: 0 additions & 3 deletions google/api_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@
from google.api_core import version as api_core_version

__version__ = api_core_version.__version__

# for backwards compatibility, expose async unary retries as google.api_core.retry_async
from .retry import retry_unary_async as retry_async # noqa: F401
34 changes: 34 additions & 0 deletions google/api_core/retry_async/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2024 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.
#
# The following imports are for backwards compatibility with https://github.com/googleapis/python-api-core/blob/4d7d2edee2c108d43deb151e6e0fdceb56b73275/google/api_core/retry_async.py
#
# TODO: Revert these imports on the next major version release (https://github.com/googleapis/python-api-core/issues/576)
from google.api_core import datetime_helpers # noqa: F401
from google.api_core import exceptions # noqa: F401
from google.api_core.retry import exponential_sleep_generator # noqa: F401
from google.api_core.retry import if_exception_type # noqa: F401
from google.api_core.retry import if_transient_error # noqa: F401
from google.api_core.retry.retry_unary_async import AsyncRetry
from google.api_core.retry.retry_unary_async import retry_target

__all__ = (
"AsyncRetry",
"datetime_helpers",
"exceptions",
"exponential_sleep_generator",
"if_exception_type",
"if_transient_error",
"retry_target",
)
Copy link
Contributor

@daniel-sanche daniel-sanche Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be potentially fixed with a file at google/api_core/retry_async.py, right?

Either way works for me, but it does seem like it could be confusing to have a retry_async folder, even though the actual async implementation is in /retry.

Using a retry_async.py file mirrors the old implementation, which feels slightly cleaner to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4f01471

4 changes: 4 additions & 0 deletions tests/unit/retry/test_retry_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ def test_legacy_imports_retry_unary_async():
# next major version release
# (https://github.com/googleapis/python-api-core/issues/576)
from google.api_core import retry_async # noqa: F401

# See https://github.com/googleapis/python-api-core/issues/586
# for context on why we need to test this import this explicitly.
from google.api_core.retry_async import AsyncRetry # noqa: F401