Title: Backward compatible import of retry_async does not work in 2.16.0 · Issue #586 · googleapis/python-api-core · GitHub
Open Graph Title: Backward compatible import of retry_async does not work in 2.16.0 · Issue #586 · googleapis/python-api-core
X Title: Backward compatible import of retry_async does not work in 2.16.0 · Issue #586 · googleapis/python-api-core
Description: The code aimed to maintain backwards compatibity when importing retry_async did not work when the . Environment details OS type and version: Dockerised Debian Bookwork Python version: python --version: 3.8.18 pip version: pip --version: ...
Open Graph Description: The code aimed to maintain backwards compatibity when importing retry_async did not work when the . Environment details OS type and version: Dockerised Debian Bookwork Python version: python --vers...
X Description: The code aimed to maintain backwards compatibity when importing retry_async did not work when the . Environment details OS type and version: Dockerised Debian Bookwork Python version: python --vers...
Opengraph URL: https://github.com/googleapis/python-api-core/issues/586
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Backward compatible import of retry_async does not work in 2.16.0","articleBody":"The code aimed to maintain backwards compatibity when importing `retry_async` did not work when the .\r\n\r\n\r\n#### Environment details\r\n\r\n - OS type and version: Dockerised Debian Bookwork\r\n - Python version: `python --version`: 3.8.18\r\n - pip version: `pip --version`: 23.3.2\r\n - `google-api-core` version: `pip show google-api-core`\r\n\r\n```\r\nName: google-api-core\r\nVersion: 2.16.0\r\nSummary: Google API client core library\r\nHome-page: https://github.com/googleapis/python-api-core\r\nAuthor: Google LLC\r\nAuthor-email: googleapis-packages@google.com\r\nLicense: Apache 2.0\r\nLocation: /usr/local/lib/python3.8/site-packages\r\nRequires: google-auth, googleapis-common-protos, protobuf, requests\r\nRequired-by: google-ads, google-analytics-admin, google-api-python-client, google-cloud-aiplatform, google-cloud-appengine-logging, google-cloud-automl, google-cloud-batch, google-cloud-bigquery, google-cloud-bigquery-datatransfer, google-cloud-bigquery-storage, google-cloud-bigtable, google-cloud-build, google-cloud-compute, google-cloud-container, google-cloud-core, google-cloud-datacatalog, google-cloud-dataflow-client, google-cloud-dataform, google-cloud-dataplex, google-cloud-dataproc, google-cloud-dataproc-metastore, google-cloud-dlp, google-cloud-kms, google-cloud-language, google-cloud-logging, google-cloud-memcache, google-cloud-monitoring, google-cloud-orchestration-airflow, google-cloud-os-login, google-cloud-pubsub, google-cloud-redis, google-cloud-resource-manager, google-cloud-run, google-cloud-secret-manager, google-cloud-spanner, google-cloud-speech, google-cloud-storage, google-cloud-storage-transfer, google-cloud-tasks, google-cloud-texttospeech, google-cloud-translate, google-cloud-videointelligence, google-cloud-vision, google-cloud-workflows, pandas-gbq, sqlalchemy-bigquery\r\n```\r\n\r\n#### Steps to reproduce\r\n\r\n 1. Run `pip insall google-api-core==2.15.0`\r\n 2. Enter python repl with `python`\r\n 3. Run `from google.api_core.retry_async import AsyncRetry` -\u003e this nicely works\r\n 4. Run `from google.api_core.retry import AsyncRetry` -\u003e this does not work (as expected)\r\n\r\n```\r\n\u003e\u003e\u003e from google.api_core.retry import AsyncRetry\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\nImportError: cannot import name 'AsyncRetry' from 'google.api_core.retry' (/usr/local/lib/python3.8/site-packages/google/api_core/retry.py)\r\n```\r\n\r\n5. Run `pip insall google-api-core==2.16.0`\r\n6. Enter python repl with `python`\r\n7. Run `from google.api_core.retry_async import AsyncRetry` -\u003e this does not work (but should)\r\n\r\n```\r\n\u003e\u003e\u003e from google.api_core.retry_async import AsyncRetry\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\nModuleNotFoundError: No module named 'google.api_core.retry_async'\r\n\u003e\u003e\u003e \r\n```\r\n8. Run `from google.api_core.retry import AsyncRetry` -\u003e this works (as expected)\r\n\r\n----\r\n\r\nThere was an attempt in #495 to make it work:\r\n\r\nIn: google/api_core/__init__.py\r\n\r\n```python\r\n# for backwards compatibility, expose async unary retries as google.api_core.retry_async\r\nfrom .retry import retry_unary_async as retry_async # noqa: F401\r\n```\r\n\r\nThis 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.\r\n\r\nWhile there was attempt to even test it in #577, it did not test the right imports:\r\n\r\n```python\r\ndef test_legacy_imports_retry_unary_async():\r\n # TODO: Delete this test when when we revert these imports on the\r\n # next major version release\r\n # (https://github.com/googleapis/python-api-core/issues/576)\r\n from google.api_core import retry_async # noqa: F401\r\n```\r\n\r\nThe ` 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`.\r\n\r\nI 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\r\n\r\n#### Code example\r\n\r\n```python\r\nfrom google.api_core.retry_async import AsyncRetry\r\nfrom google.api_core.retry import AsyncRetry\r\n```\r\n\r\n#### Stack trace\r\n```\r\n\u003e\u003e\u003e from google.api_core.retry_async import AsyncRetry\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\nModuleNotFoundError: No module named 'google.api_core.retry_async'\r\n\u003e\u003e\u003e \r\n```\r\n\r\nMaking sure to follow these steps will guarantee the quickest resolution possible.\r\n\r\nThanks!\r\n","author":{"url":"https://github.com/potiuk","@type":"Person","name":"potiuk"},"datePublished":"2024-01-30T12:04:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/586/python-api-core/issues/586"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f639b8a2-e484-c4b4-9816-5e27bff2dde4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C866:23F3E2:A8A3B:EC796:6A4DB77B |
| html-safe-nonce | 95fd93126ff8cb6e8c8d1d0b733399d1afd5e58aef3548ee6ee92b76919b9308 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODY2OjIzRjNFMjpBOEEzQjpFQzc5Njo2QTREQjc3QiIsInZpc2l0b3JfaWQiOiIyNDcwNzAzNzg4NzYwODcyODI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ce0005e143d0ce5022d92013aded3e00cff9a8106853a1dc312da58eeee2a9fa |
| hovercard-subject-tag | issue:2107685002 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-api-core/586/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c7dbcc6bd5cea0be41627785f9b8dbf42e4dc695b063b2b1a2f30732314ed88f/googleapis/python-api-core/issues/586 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c7dbcc6bd5cea0be41627785f9b8dbf42e4dc695b063b2b1a2f30732314ed88f/googleapis/python-api-core/issues/586 |
| og:image:alt | The code aimed to maintain backwards compatibity when importing retry_async did not work when the . Environment details OS type and version: Dockerised Debian Bookwork Python version: python --vers... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | potiuk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-api-core git https://github.com/googleapis/python-api-core.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992456 |
| octolytics-dimension-repository_nwo | googleapis/python-api-core |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992456 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-api-core |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 32f7b614aca06e6bbd89842b1370df1328264f68 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width