Run from google.api_core.retry_async import AsyncRetry -> this nicely works
Run from google.api_core.retry import AsyncRetry -> this does not work (as expected)
>>> from google.api_core.retry import AsyncRetry
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'AsyncRetry' from 'google.api_core.retry' (/usr/local/lib/python3.8/site-packages/google/api_core/retry.py)
Run pip insall google-api-core==2.16.0
Enter python repl with python
Run from google.api_core.retry_async import AsyncRetry -> this does not work (but should)
>>> from google.api_core.retry_async import AsyncRetry
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'google.api_core.retry_async'
>>>
Run from google.api_core.retry import AsyncRetry -> this works (as expected)
There was an attempt in #495 to make it work:
In: google/api_core/init.py
# for backwards compatibility, expose async unary retries as google.api_core.retry_async
from .retry import retry_unary_async as retry_async # noqa: F401
This is aimed to make from google.api_core.retry_async import AsyncRetry works, but importing a module into another modules __init__ does not work the way it is supposed to work.
While there was attempt to even test it in #577, it did not test the right imports:
def test_legacy_imports_retry_unary_async():
# TODO: Delete this test when when we revert these imports on the
# next major version release
# (https://github.com/googleapis/python-api-core/issues/576)
from google.api_core import retry_async # noqa: F401
The from google.api_core import retry_async works, fine, but from google.api_core.retry_async import AsyncRetry still raises the No module named 'google.api_core.retry_async - bycause of the way how python resolves from.
I guess good solution will be to add back the retry_async as a (mostly empty) submodule and import all the needed classess from the retry_unary_async package
Code example
from google.api_core.retry_async import AsyncRetry
from google.api_core.retry import AsyncRetry
Stack trace
>>> from google.api_core.retry_async import AsyncRetry
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'google.api_core.retry_async'
>>>
Making sure to follow these steps will guarantee the quickest resolution possible.
The code aimed to maintain backwards compatibity when importing
retry_async
did not work when the .Environment details
python --version
: 3.8.18pip --version
: 23.3.2google-api-core
version:pip show google-api-core
Steps to reproduce
pip insall google-api-core==2.15.0
python
from google.api_core.retry_async import AsyncRetry
-> this nicely worksfrom google.api_core.retry import AsyncRetry
-> this does not work (as expected)pip insall google-api-core==2.16.0
python
from google.api_core.retry_async import AsyncRetry
-> this does not work (but should)from google.api_core.retry import AsyncRetry
-> this works (as expected)There was an attempt in #495 to make it work:
In: google/api_core/init.py
This is aimed to make
from google.api_core.retry_async import AsyncRetry
works, but importing a module into another modules__init__
does not work the way it is supposed to work.While there was attempt to even test it in #577, it did not test the right imports:
The
from google.api_core import retry_async
works, fine, butfrom google.api_core.retry_async import AsyncRetry
still raises theNo module named 'google.api_core.retry_async
- bycause of the way how python resolvesfrom
.I guess good solution will be to add back the
retry_async
as a (mostly empty) submodule and import all the needed classess from theretry_unary_async
packageCode example
Stack trace
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!