gapic-generator-python
gapic-generator-python copied to clipboard
`TypeError: Unexpected type of callable` when REST transport is used with Async clients
See the reproduction code below, and the stack trace that appears when setting the transport argument of DocumentServiceAsyncClient to "rest"
import asyncio
import json
from google.cloud import discoveryengine_v1
doc_json = {
"title": "Test document title",
"body": "Test document description",
"categories": ["sports > clip","sports > highlight"],
"uri": "http://www.example.com",
}
document = discoveryengine_v1.Document()
document.json_data = json.dumps(doc_json)
client = discoveryengine_v1.DocumentServiceAsyncClient(transport="rest")
request = discoveryengine_v1.CreateDocumentRequest(
parent="projects/python-docs-samples-tests/locations/global/dataStores/test-structured-data-engine/branches/default_branch",
document=document,
)
asyncio.run(client.create_document(request=request))
Traceback (most recent call last):
File "/usr/local/google/home/partheniou/git/google-cloud-python/check.py", line 21, in <module>
asyncio.run(client.create_document(request=request))
File "/usr/local/google/home/partheniou/.pyenv/versions/3.9.16/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/google/home/partheniou/.pyenv/versions/3.9.16/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/usr/local/google/home/partheniou/.pyenv/versions/3.9.16/envs/py39/lib/python3.9/site-packages/google/cloud/discoveryengine_v1/services/document_service/async_client.py", line 640, in create_document
rpc = gapic_v1.method_async.wrap_method(
File "/usr/local/google/home/partheniou/git/python-api-core/google/api_core/gapic_v1/method_async.py", line 43, in wrap_method
func = grpc_helpers_async.wrap_errors(func)
File "/usr/local/google/home/partheniou/git/python-api-core/google/api_core/grpc_helpers_async.py", line 209, in wrap_errors
raise TypeError("Unexpected type of callable: {}".format(type(callable_)))
TypeError: Unexpected type of callable: <class 'google.cloud.discoveryengine_v1.services.document_service.transports.rest.DocumentServiceRestTransport._CreateDocument'>
If support for REST transport in async clients is not actively being worked on, the error message should say that REST transport is not supported in async clients via a NotImplementedError.