Skip to content
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

'grpc.experimental.aio' has no attribute 'StreamUnaryCall' due to PR#29 #40

Closed
gtoonstra opened this issue Jun 5, 2020 · 15 comments · Fixed by #41
Closed

'grpc.experimental.aio' has no attribute 'StreamUnaryCall' due to PR#29 #40

gtoonstra opened this issue Jun 5, 2020 · 15 comments · Fixed by #41
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@gtoonstra
Copy link

gtoonstra commented Jun 5, 2020

We observe a stack trace on one of our clusters due to a package upgrade, possibly introduced by the new release of python-api-core, which we don't pin to a specific version.

Due to PR#29, we now see the following error:

'grpc.experimental.aio' has no attribute 'StreamUnaryCall'

We will pin our version to the previous one, but documenting this here as it can affect other customers. Probably we should be pinning a more recent version of google.cloud libraries that are compatible, we're still researching this.

Environment details

  • OS type and version: image 1.4-ubuntu18 (GCP dataproc).
  • Python version: 3.6
  • pip version: pip --version
  • google-api-core version: 1.19.0

Steps to reproduce

  1. See stack trace below, it happens on import bigquery client.

Stack trace

    from google.cloud import bigquery, bigquery_storage, storage
  File "/opt/conda/default/lib/python3.6/site-packages/google/cloud/bigquery/__init__.py", line 35, in <module>
    from google.cloud.bigquery.client import Client
  File "/opt/conda/default/lib/python3.6/site-packages/google/cloud/bigquery/client.py", line 58, in <module>
    from google.cloud.bigquery import _pandas_helpers
  File "/opt/conda/default/lib/python3.6/site-packages/google/cloud/bigquery/_pandas_helpers.py", line 25, in <module>
    from google.cloud import bigquery_storage_v1beta1
  File "/opt/conda/default/lib/python3.6/site-packages/google/cloud/bigquery_storage_v1beta1/__init__.py", line 26, in <module>
    from google.cloud.bigquery_storage_v1beta1 import client
  File "/opt/conda/default/lib/python3.6/site-packages/google/cloud/bigquery_storage_v1beta1/client.py", line 24, in <module>
    import google.api_core.gapic_v1.method
  File "/opt/conda/default/lib/python3.6/site-packages/google/api_core/gapic_v1/__init__.py", line 26, in <module>
    from google.api_core.gapic_v1 import method_async  # noqa: F401
  File "/opt/conda/default/lib/python3.6/site-packages/google/api_core/gapic_v1/method_async.py", line 20, in <module>
    from google.api_core import general_helpers, grpc_helpers_async
  File "/opt/conda/default/lib/python3.6/site-packages/google/api_core/grpc_helpers_async.py", line 145, in <module>
    class _WrappedStreamUnaryCall(_WrappedUnaryResponseMixin, _WrappedStreamRequestMixin, aio.StreamUnaryCall):
AttributeError: module 'grpc.experimental.aio' has no attribute 'StreamUnaryCall'
@gtoonstra
Copy link
Author

These are the version numbers of the relevant libraries that we pin down:

    "pandas==1.0.2",
    "google-cloud-bigquery==1.23.0",
    "google-cloud-bigquery-storage==0.7.0",
    "google-cloud-storage==1.23.0",
    "pyarrow==0.15.1",
    "grpcio==1.27.2",

@KushGoyal
Copy link

KushGoyal commented Jun 5, 2020

I am getting the same error.

As a workaround using an older version.
google-api-core==1.16.0

@bchazalet
Copy link

we too have been bitten by this in a cloud function. It was painful to track down.

@fernandobrito
Copy link

fernandobrito commented Jun 5, 2020

I just had a similar issue in our Google Cloud Composer environment.

Requirements:

boto3==1.11.17
snowflake-sqlalchemy~=1.2.0
google-cloud-bigquery-datatransfer~=0.4.1
pybigquery~=0.4.15
setuptools~=46.1.3
google-cloud-bigquery==1.24.0
docker==4.2.1

Everything was working fine until today when I added the last row and it triggered some versions bumps (last one was weeks/months ago).

The error manifested to me as:

  File "/home/airflow/gcs/dags/jobs_history/import_jobs_history.py", line 13, in <module>
    from google.cloud import bigquery_datatransfer_v1
  File "/opt/python3.6/lib/python3.6/site-packages/google/cloud/bigquery_datatransfer_v1/__init__.py", line 23, in <module>
    from google.cloud.bigquery_datatransfer_v1.gapic import data_transfer_service_client
  File "/opt/python3.6/lib/python3.6/site-packages/google/cloud/bigquery_datatransfer_v1/gapic/data_transfer_service_client.py", line 25, in <module>
    import google.api_core.gapic_v1.client_info
  File "/opt/python3.6/lib/python3.6/site-packages/google/api_core/gapic_v1/__init__.py", line 26, in <module>
    from google.api_core.gapic_v1 import method_async  # noqa: F401
  File "/opt/python3.6/lib/python3.6/site-packages/google/api_core/gapic_v1/method_async.py", line 20, in <module>
    from google.api_core import general_helpers, grpc_helpers_async
  File "/opt/python3.6/lib/python3.6/site-packages/google/api_core/grpc_helpers_async.py", line 25, in <module>
    from grpc.experimental import aio
ImportError: cannot import name 'aio'

The fix was to add google-api-core==1.17.0 to my requirements. 1.18.0 also causes the same error.

Google Cloud Composer composer-1.8.4-airflow-1.10.3
Python 3.6.8

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jun 5, 2020
@busunkim96 busunkim96 added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed triage me I really want to be triaged. labels Jun 6, 2020
@busunkim96
Copy link
Contributor

busunkim96 commented Jun 6, 2020

Sorry for the trouble this is causing folks! Please continue to use google-api-core==1.16.0 until this is resolved. (Alternatively, upgrading to the latest version of grpcio should also resolve the issue).

I suspect we need to increase the minimum required grpcio version. https://github.com/googleapis/python-api-core/blob/master/setup.py#L42

@lidizheng Could you help identify the minimum required version?

@lidizheng
Copy link
Contributor

@busunkim96 The minimum version of grpcio for the latest release of google-api-core is v1.29.0. The new release of gRPC Python adds support for retry in AsyncIO, and fix some stability issue.

Sorry that I didn't add this constraint earlier. Here is a PR to bump up the minimum version: #41

@busunkim96
Copy link
Contributor

@lidizheng No worries, It slipped my mind as well. Thank you for the PR!

@luogantt
Copy link

pip install google-api-core==1.16

solve the problem

@ZhengxunWu
Copy link

ZhengxunWu commented Jul 22, 2021

@busunkim96 The minimum version of grpcio for the latest release of google-api-core is v1.29.0. The new release of gRPC Python adds support for retry in AsyncIO, and fix some stability issue.

Sorry that I didn't add this constraint earlier. Here is a PR to bump up the minimum version: #41

Hi, but even if I upgraded to grpcio v1.36.1, still have the same error. Have been trying to fix it for quite a long time.
Relevant packages:

google-api-core           1.22.2           py37h21ff451_0
google-auth               1.25.0             pyh44b312d_0    conda-forge
google-cloud-bigquery     1.22.0                   py37_0    conda-forge
google-cloud-bigquery-storage 0.6.0                    py37_0    conda-forge
google-cloud-core         1.3.0                      py_0
google-pasta              0.2.0                      py_0
google-resumable-media    0.5.1              pyh9f0ad1d_0    conda-forge
googleapis-common-protos  1.52.0           py37h2eaa2aa_0

@lidizheng
Copy link
Contributor

@ZhengxunWu Hi, can you try to upgrade all packages to the latest version and try again? Also, what Python interpretor version did you use?

We tried hard to make sure there isn't any regression when we move gRPC AsyncIO API to stable a year ago. There might be something changed in Python's import mechanism.

@pramodh941
Copy link

I am facing the same issue. To summarise from the above workaround suggestions:

  • pin our version to the previous one (google-api-core==1.16.0), but the current version I have is (google-api-core-1.31.1). I got this error message {ImportError: cannot import name 'grpc_helpers_async' from 'google.api_core' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/init.py)} when I switched to (google-api-core==1.16.0) @luogantt

  • Alternatively, upgrading to the latest version of grpcio should also resolve the issue, I have this version if I am pointing this correctly: {grpcio<2.0.0dev,>=1.0.0 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from grpc-google-iam-v1<0.13dev,>=0.12.3->google-cloud-container>=0.3.0->caliban) (1.27.2)}

  • @lidizheng , I am using Python version 3.8 . Could you help me understand how do I resolve this issue?

Please find attached terminal report
caliban.pdf

@lidizheng
Copy link
Contributor

@pramodh941 According to GitHub, the grpcio version restriction is only added for google-api-core>=1.19.1. And, what you are getting is an old version before the initial asyncio support.

Can I ask if it is possible to use the latest google-api-core? If not, what is blocking it?

@pramodh941
Copy link

pramodh941 commented Aug 2, 2021

@lidizheng yeah, I tried initially with the latest version 1.31.1, but it's not working.

If you take a look at the attached pdf file with the terminal report, you will find the detailed error message while using with the old and latest versions

@lidizheng
Copy link
Contributor

lidizheng commented Aug 2, 2021

Sorry about that. I saw the import namespace error, as well as the asyncio helper import error.

@busunkim96
Copy link
Contributor

@pramodh941 Could you try installing in a brand new virtual environment?

python3 -m venv env
source env/bin/activate
pip install caliban

In the first bit of the log it looks like an older version of grpcio (1.27.2) is being used:

Requirement already satisfied: grpcio<2.0.0dev,>=1.0.0 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from grpc-google-iam-v1<0.13dev,>=0.12.3->google
-cloud-container>=0.3.0->caliban) (1.27.2)

To be extra sure, you can also check the grpcio version used at runtime:

import grpc
print(grpc.__version__)

I'm not sure why pip wouldn't upgrade grpcio==1.27.2 when google-cloud-container is installed though. The latest google-cloud-container requires google-api-core>=1.26.0, <3.0.0dev which would in turn require a version of grpcio (grpcio >= 1.29.0, < 2.0dev) with the grpc.experimental.aio surface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants