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

Using absolute imports in core modules that import grpc. #2632

Merged
merged 1 commit into from
Oct 27, 2016

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented Oct 27, 2016

This is because a relative import (in Python 2.7) was causing failures when google.cloud.grpc was side-by-side with google.cloud._helpers, etc.

For example, see the failure: https://travis-ci.org/GoogleCloudPlatform/google-cloud-python/builds/171149390#L1738-L1750

FYI @geigerj @bjwatson

To repro (before this PR):

$ cd ${GIT_ROOT}
$ tox -e system-tests --recreate --notest
$ source .tox/system-tests/bin/activate
$ .tox/system-tests/bin/py.test system_tests/datastore.py --pdb
...
>       transport_creds = grpc.ssl_channel_credentials()
E       AttributeError: 'module' object has no attribute 'ssl_channel_credentials'

.tox/system-tests/local/lib/python2.7/site-packages/google/cloud/_helpers.py:643: AttributeError
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> .tox/system-tests/local/lib/python2.7/site-packages/google/cloud/_helpers.py(643)make_secure_stub()
-> transport_creds = grpc.ssl_channel_credentials()
(Pdb) grpc
<module 'google.cloud.grpc' (built-in)>
(Pdb) 

This is because a relative import (in Python 2.7) was
causing failures when google.cloud.grpc was side-by-side with
google.cloud._helpers, etc.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 27, 2016
@dhermes
Copy link
Contributor Author

dhermes commented Oct 27, 2016

@bjwatson ISTM that in later generations of GAPIC generated code the google.cloud.grpc package is gone. Is this correct?

i.e. it is brought in by the speech deps (uploaded on sept. 30)

https://pypi.python.org/pypi/grpc-google-cloud-speech-v1beta1/0.11.1
https://pypi.python.org/pypi/gapic-google-cloud-speech-v1beta1/0.11.1

@dhermes dhermes merged commit 0838d14 into googleapis:master Oct 27, 2016
@dhermes dhermes deleted the fix-grpc-rel branch October 27, 2016 18:34
@dhermes
Copy link
Contributor Author

dhermes commented Oct 27, 2016

Chatted @bjwatson, he confirmed that google.cloud.grpc is here to stay. For packages like speech where the namespace is google.cloud.speech.v1beta1, putting the autogenerated packages in google.cloud.speech.v1beta1.cloud_speech_pb would cause a collision with our package google.cloud.speech (which isn't a namespace package) so the autogenerated are instead in google.cloud.grpc.speech.v1beta1.cloud_speech_pb

/FYI @jonparrott

@theacodes
Copy link
Contributor

Yep - remember having that discussion a while back. SGTM.

richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Using absolute imports in core modules that import grpc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: core cla: yes This human has signed the Contributor License Agreement. grpc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants