Closed gabrielboehme closed 9 months ago
The code below uses ClientInfo from google.api_core.client_info.py
However there is also a ClientInfo in google/api_core/gapic_v1/client_info.py
which has the to_grpc_metadata
method
The latter one is the one used in gapic-generator-python. https://github.com/search?q=repo%3Agoogleapis%2Fgapic-generator-python%20%22clientinfo%22&type=code
Changing the code below to use ClientInfo
from google/api_core/gapic_v1/client_info.py
instead of google.api_core.client_info.py
should resolve the issue ClientInfo' object has no attribute 'to_grpc_metadata'
https://github.com/googleapis/python-documentai-toolbox/blob/ecb656cd88d36b401587f4173882e5238d8dbea0/google/cloud/documentai_toolbox/utilities/gcs_utilities.py#L27-L28
Thanks @parthea I'm not sure why this would be happening now, this has been working fine for quite a few versions. But I can try changing that import.
@holtskinner , Please could you check if you are able to reproduce the issue using the code provided?
from google.cloud import documentai
from google.cloud.documentai_toolbox import document
wrapped_document = document.Document.from_batch_process_operation(
operation_name=operation_name
location=location
)
wrapped_document.entities_to_bigquery(
dataset_name=dataset, table_name=table, project_id=project
)
from google.cloud import documentai from google.cloud.documentai_toolbox import document wrapped_document = document.Document.from_batch_process_operation( operation_name=operation_name location=location ) wrapped_document.entities_to_bigquery( dataset_name=dataset, table_name=table, project_id=project )
Not sure if this was just a copy-paste error, but there should be a comma after operation_name=operation_name
before the location parameter. The code won't run otherwise, but it's this error instead.
operation_name=operation_name
^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
I was able to reproduce this behavior in Python3.8 in the compiled library only.
I'll also add in Samples (w/tests) for this import method to catch this.
I think I see why this wasn't an issue earlier. In #249, I made changes to how from_batch_process_operation()
gets the Operation data, which might now require the gapic import for 3.8. The Unit/Integration tests didn't catch this.
@holtskinner thanks for addressing this so quickly! But now Im getting another error: the method 'from_batch_process_metadata' raises the following error,
ValueError: Invalid Document - shardInfo.shardCount (1) does not match number of shards (1053)
which is strange to me, since I expected to input my operation name (that succeeded FYI), and get all the wrapped documents. But the error is claiming that there are too many shards (?).
The same thing happens if I use the 'from_gcs' method, passing the root directory (
Environment details
Steps to reproduce
Requirements:
Execution:
python3 main.py
Code example
main.py:
Stack trace
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!