GeezerVison is showing github.com — Using google.cloud.operation for GAPIC Speech async? · Issue #2629 · googleapis/google-cloud-python
Using google.cloud.operation for GAPIC Speech async? #2629DescriptionI've been struggling today with the right way to implement this.
I can't seem to make_secure_stub for speech.
This is the error I get...
File "/Users/daspecster/Documents/google/google-cloud-py-2/.tox/py27/lib/python2.7/site-packages/google_cloud_speech-0.20.0.dev0-py2.7.egg/google/cloud/speech/_gax.py", line 92, in async_recognize
OPERATIONS_API_HOST)
File "/Users/daspecster/Documents/google/google-cloud-py-2/.tox/py27/lib/python2.7/site-packages/google_cloud_core-0.20.0-py2.7.egg/google/cloud/_helpers.py", line 642, in make_secure_stub
transport_creds = grpc.ssl_channel_credentials()
AttributeError: 'module' object has no attribute 'ssl_channel_credentials'
Example code:
config = RecognitionConfig(
encoding=sample.encoding, sample_rate=sample.sample_rate,
language_code=language_code, max_alternatives=max_alternatives,
profanity_filter=profanity_filter,
speech_context=SpeechContext(phrases=speech_context))
audio = RecognitionAudio(content=sample.content,
uri=sample.source_uri)
self._client._operations_stub = make_secure_stub(
self._client.connection.credentials,
DEFAULT_USER_AGENT,
operations_grpc.OperationsStub,
OPERATIONS_API_HOST)
api = self._gapic_api
operation = api.sync_recognize(config=config, audio=audio)
return Operation.from_pb(operation, self._client)
Looking at the sample example it seems like the channel creation is different than it is in our _helpers.make_secure_stub Activitydaspecster commented on Oct 27, 2016 ContributorAuthor More actions This seems to work though.
╰─$ .tox/py27/bin/python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
Type "help", "copyright", "credits" or "license" for more information.
>>> import grpc
>>> grpc.ssl_channel_credentials()
<grpc.ChannelCredentials object at 0x109463950>
@bjwatson could something be messing up the grpc namespace in
'gapic-google-cloud-speech-v1beta1 >= 0.11.1, < 0.12.0',
'grpc-google-cloud-speech-v1beta1 >= 0.11.1, < 0.12.0',
Also, @bjwatson, is gapic-google-longrunning ok to use or is it not really production ready yet? dhermes commented on Oct 27, 2016 @daspecster It seems like there is an old version of grpc? Also, you don't need make_secure_stub for Speech (not used in Pub/Sub or Logging).
There is a "bug" in that we should pass credentials through, but you shouldn't worry about handling it to get Speech in. daspecster commented on Oct 27, 2016 ContributorAuthor More actions daspecster commented on Oct 27, 2016 ContributorAuthor More actions bjwatson commented on Oct 28, 2016 @daspecster Yes, gapic-google-longrunning is okay to use, although I plan to merge it into the next release of google-gax (with the same path and module name).
We are also designing a more convenient layer for you to use in the future that will sit on top of the gapic-google-longrunning code. I'll take a look at what you did for Speech, and want to discuss with you what pain points you had. daspecster commented on Oct 28, 2016 ContributorAuthor More actions
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|