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

TypeError: Unexpected type of callable when REST transport is used with Async clients #1961

Open
parthea opened this issue Feb 28, 2024 · 0 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@parthea
Copy link
Contributor

parthea commented Feb 28, 2024

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.

@parthea parthea added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant