From 1c3e2821870476b93438ab0006151b04580d3fd5 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 23 Mar 2022 10:25:44 +0100 Subject: [PATCH 01/16] chore(deps): update dependency google-cloud-documentai to v1.4.0 (#297) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index b9a58c5f..dea61094 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-documentai==1.3.0 +google-cloud-documentai==1.4.0 google-cloud-storage==2.2.1 From e8b2155bb65c7f1e074d38517e94e9ca25673647 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 23 Mar 2022 11:38:03 -0600 Subject: [PATCH 02/16] chore(python): configure release-please on previous major versions (#298) Source-Link: https://github.com/googleapis/synthtool/commit/c1dd87e9287f8de99930d3046dd555c4d03384c6 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:2d13c2172a5d6129c861edaa48b60ead15aeaf58aa75e02d870c4cbdfa63aaba Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- .github/release-please.yml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7c..88076277 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:2d13c2172a5d6129c861edaa48b60ead15aeaf58aa75e02d870c4cbdfa63aaba diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e5..6def37a8 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,8 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v0 + handleGHRelease: true + releaseType: python From 26039d5a3a6a0b410a66a42885040989329f08ae Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 23:56:14 +0000 Subject: [PATCH 03/16] chore(python): use black==22.3.0 (#301) Source-Link: https://github.com/googleapis/synthtool/commit/6fab84af09f2cf89a031fd8671d1def6b2931b11 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 5 +- .../async_client.py | 21 +- .../document_processor_service/client.py | 80 ++- .../transports/base.py | 6 +- .../transports/grpc.py | 3 +- google/cloud/documentai_v1/types/document.py | 626 ++++++++++++++---- .../cloud/documentai_v1/types/document_io.py | 51 +- .../types/document_processor_service.py | 149 ++++- google/cloud/documentai_v1/types/geometry.py | 36 +- .../documentai_v1/types/operation_metadata.py | 28 +- .../async_client.py | 14 +- .../document_understanding_service/client.py | 53 +- .../transports/base.py | 6 +- .../transports/grpc.py | 3 +- .../documentai_v1beta2/types/document.py | 446 ++++++++++--- .../types/document_understanding.py | 204 ++++-- .../documentai_v1beta2/types/geometry.py | 36 +- .../async_client.py | 68 +- .../document_processor_service/client.py | 137 +++- .../transports/base.py | 26 +- .../transports/grpc.py | 3 +- .../documentai_v1beta3/types/document.py | 626 ++++++++++++++---- .../documentai_v1beta3/types/document_io.py | 51 +- .../types/document_processor_service.py | 296 +++++++-- .../documentai_v1beta3/types/geometry.py | 36 +- .../types/operation_metadata.py | 28 +- .../documentai_v1beta3/types/processor.py | 47 +- .../types/processor_type.py | 34 +- noxfile.py | 9 +- .../batch_process_documents_sample.py | 4 +- samples/snippets/noxfile.py | 4 +- .../process_document_splitter_sample.py | 2 +- .../test_document_processor_service.py | 180 +++-- .../test_document_understanding_service.py | 134 +++- .../test_document_processor_service.py | 438 ++++++++---- 36 files changed, 3031 insertions(+), 861 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 88076277..87dd0061 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:2d13c2172a5d6129c861edaa48b60ead15aeaf58aa75e02d870c4cbdfa63aaba + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/docs/conf.py b/docs/conf.py index 17981c4e..baf004e8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -361,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/documentai_v1/services/document_processor_service/async_client.py b/google/cloud/documentai_v1/services/document_processor_service/async_client.py index d1bf70a6..48184c6a 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/async_client.py @@ -321,7 +321,12 @@ def sample_process_document(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -430,7 +435,12 @@ def sample_batch_process_documents(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -554,7 +564,12 @@ def sample_review_document(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( diff --git a/google/cloud/documentai_v1/services/document_processor_service/client.py b/google/cloud/documentai_v1/services/document_processor_service/client.py index ed696473..a8131e1b 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/client.py @@ -58,7 +58,8 @@ class DocumentProcessorServiceClientMeta(type): _transport_registry["grpc_asyncio"] = DocumentProcessorServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[DocumentProcessorServiceTransport]: """Returns an appropriate transport class. @@ -169,10 +170,16 @@ def transport(self) -> DocumentProcessorServiceTransport: return self._transport @staticmethod - def human_review_config_path(project: str, location: str, processor: str,) -> str: + def human_review_config_path( + project: str, + location: str, + processor: str, + ) -> str: """Returns a fully-qualified human_review_config string.""" return "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig".format( - project=project, location=location, processor=processor, + project=project, + location=location, + processor=processor, ) @staticmethod @@ -185,10 +192,16 @@ def parse_human_review_config_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def processor_path(project: str, location: str, processor: str,) -> str: + def processor_path( + project: str, + location: str, + processor: str, + ) -> str: """Returns a fully-qualified processor string.""" return "projects/{project}/locations/{location}/processors/{processor}".format( - project=project, location=location, processor=processor, + project=project, + location=location, + processor=processor, ) @staticmethod @@ -201,7 +214,9 @@ def parse_processor_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -214,9 +229,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -225,9 +244,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -236,9 +259,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -247,10 +274,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -513,7 +544,12 @@ def sample_process_document(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -612,7 +648,12 @@ def sample_batch_process_documents(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -726,7 +767,12 @@ def sample_review_document(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/base.py b/google/cloud/documentai_v1/services/document_processor_service/transports/base.py index e6f5168c..bf5a8263 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/base.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/base.py @@ -172,9 +172,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py index 2ab86d83..17dba4df 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py @@ -231,8 +231,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/documentai_v1/types/document.py b/google/cloud/documentai_v1/types/document.py index 904f46e2..a1ee8350 100644 --- a/google/cloud/documentai_v1/types/document.py +++ b/google/cloud/documentai_v1/types/document.py @@ -26,7 +26,10 @@ __protobuf__ = proto.module( - package="google.cloud.documentai.v1", manifest={"Document",}, + package="google.cloud.documentai.v1", + manifest={ + "Document", + }, ) @@ -114,9 +117,18 @@ class ShardInfo(proto.Message): the overall document global text. """ - shard_index = proto.Field(proto.INT64, number=1,) - shard_count = proto.Field(proto.INT64, number=2,) - text_offset = proto.Field(proto.INT64, number=3,) + shard_index = proto.Field( + proto.INT64, + number=1, + ) + shard_count = proto.Field( + proto.INT64, + number=2, + ) + text_offset = proto.Field( + proto.INT64, + number=3, + ) class Style(proto.Message): r"""Annotation for common text style attributes. This adheres to @@ -154,21 +166,46 @@ class FontSize(proto.Message): (in, px, pt, etc.). """ - size = proto.Field(proto.FLOAT, number=1,) - unit = proto.Field(proto.STRING, number=2,) + size = proto.Field( + proto.FLOAT, + number=1, + ) + unit = proto.Field( + proto.STRING, + number=2, + ) text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + color = proto.Field( + proto.MESSAGE, + number=2, + message=color_pb2.Color, ) - color = proto.Field(proto.MESSAGE, number=2, message=color_pb2.Color,) background_color = proto.Field( - proto.MESSAGE, number=3, message=color_pb2.Color, + proto.MESSAGE, + number=3, + message=color_pb2.Color, + ) + font_weight = proto.Field( + proto.STRING, + number=4, + ) + text_style = proto.Field( + proto.STRING, + number=5, + ) + text_decoration = proto.Field( + proto.STRING, + number=6, ) - font_weight = proto.Field(proto.STRING, number=4,) - text_style = proto.Field(proto.STRING, number=5,) - text_decoration = proto.Field(proto.STRING, number=6,) font_size = proto.Field( - proto.MESSAGE, number=7, message="Document.Style.FontSize", + proto.MESSAGE, + number=7, + message="Document.Style.FontSize", ) class Page(proto.Message): @@ -243,9 +280,18 @@ class Dimension(proto.Message): Dimension unit. """ - width = proto.Field(proto.FLOAT, number=1,) - height = proto.Field(proto.FLOAT, number=2,) - unit = proto.Field(proto.STRING, number=3,) + width = proto.Field( + proto.FLOAT, + number=1, + ) + height = proto.Field( + proto.FLOAT, + number=2, + ) + unit = proto.Field( + proto.STRING, + number=3, + ) class Image(proto.Message): r"""Rendered image contents for this page. @@ -261,10 +307,22 @@ class Image(proto.Message): Height of the image in pixels. """ - content = proto.Field(proto.BYTES, number=1,) - mime_type = proto.Field(proto.STRING, number=2,) - width = proto.Field(proto.INT32, number=3,) - height = proto.Field(proto.INT32, number=4,) + content = proto.Field( + proto.BYTES, + number=1, + ) + mime_type = proto.Field( + proto.STRING, + number=2, + ) + width = proto.Field( + proto.INT32, + number=3, + ) + height = proto.Field( + proto.INT32, + number=4, + ) class Matrix(proto.Message): r"""Representation for transformation matrix, intended to be @@ -285,10 +343,22 @@ class Matrix(proto.Message): The matrix data. """ - rows = proto.Field(proto.INT32, number=1,) - cols = proto.Field(proto.INT32, number=2,) - type_ = proto.Field(proto.INT32, number=3,) - data = proto.Field(proto.BYTES, number=4,) + rows = proto.Field( + proto.INT32, + number=1, + ) + cols = proto.Field( + proto.INT32, + number=2, + ) + type_ = proto.Field( + proto.INT32, + number=3, + ) + data = proto.Field( + proto.BYTES, + number=4, + ) class Layout(proto.Message): r"""Visual element describing a layout unit on a page. @@ -320,14 +390,23 @@ class Orientation(proto.Enum): PAGE_LEFT = 4 text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + confidence = proto.Field( + proto.FLOAT, + number=2, ) - confidence = proto.Field(proto.FLOAT, number=2,) bounding_poly = proto.Field( - proto.MESSAGE, number=3, message=geometry.BoundingPoly, + proto.MESSAGE, + number=3, + message=geometry.BoundingPoly, ) orientation = proto.Field( - proto.ENUM, number=4, enum="Document.Page.Layout.Orientation", + proto.ENUM, + number=4, + enum="Document.Page.Layout.Orientation", ) class Block(proto.Message): @@ -346,13 +425,19 @@ class Block(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) provenance = proto.Field( - proto.MESSAGE, number=3, message="Document.Provenance", + proto.MESSAGE, + number=3, + message="Document.Provenance", ) class Paragraph(proto.Message): @@ -372,13 +457,19 @@ class Paragraph(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) provenance = proto.Field( - proto.MESSAGE, number=3, message="Document.Provenance", + proto.MESSAGE, + number=3, + message="Document.Provenance", ) class Line(proto.Message): @@ -398,13 +489,19 @@ class Line(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) provenance = proto.Field( - proto.MESSAGE, number=3, message="Document.Provenance", + proto.MESSAGE, + number=3, + message="Document.Provenance", ) class Token(proto.Message): @@ -441,20 +538,30 @@ class Type(proto.Enum): HYPHEN = 3 type_ = proto.Field( - proto.ENUM, number=1, enum="Document.Page.Token.DetectedBreak.Type", + proto.ENUM, + number=1, + enum="Document.Page.Token.DetectedBreak.Type", ) layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_break = proto.Field( - proto.MESSAGE, number=2, message="Document.Page.Token.DetectedBreak", + proto.MESSAGE, + number=2, + message="Document.Page.Token.DetectedBreak", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=3, + message="Document.Page.DetectedLanguage", ) provenance = proto.Field( - proto.MESSAGE, number=4, message="Document.Provenance", + proto.MESSAGE, + number=4, + message="Document.Provenance", ) class Symbol(proto.Message): @@ -471,10 +578,14 @@ class Symbol(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) class VisualElement(proto.Message): @@ -495,11 +606,18 @@ class VisualElement(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", + ) + type_ = proto.Field( + proto.STRING, + number=2, ) - type_ = proto.Field(proto.STRING, number=2,) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=3, + message="Document.Page.DetectedLanguage", ) class Table(proto.Message): @@ -527,7 +645,9 @@ class TableRow(proto.Message): """ cells = proto.RepeatedField( - proto.MESSAGE, number=1, message="Document.Page.Table.TableCell", + proto.MESSAGE, + number=1, + message="Document.Page.Table.TableCell", ) class TableCell(proto.Message): @@ -548,25 +668,43 @@ class TableCell(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", + ) + row_span = proto.Field( + proto.INT32, + number=2, + ) + col_span = proto.Field( + proto.INT32, + number=3, ) - row_span = proto.Field(proto.INT32, number=2,) - col_span = proto.Field(proto.INT32, number=3,) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", ) layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) header_rows = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.Table.TableRow", + proto.MESSAGE, + number=2, + message="Document.Page.Table.TableRow", ) body_rows = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.Table.TableRow", + proto.MESSAGE, + number=3, + message="Document.Page.Table.TableRow", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", ) class FormField(proto.Message): @@ -602,20 +740,33 @@ class FormField(proto.Message): """ field_name = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) field_value = proto.Field( - proto.MESSAGE, number=2, message="Document.Page.Layout", + proto.MESSAGE, + number=2, + message="Document.Page.Layout", ) name_detected_languages = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=3, + message="Document.Page.DetectedLanguage", ) value_detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", + ) + value_type = proto.Field( + proto.STRING, + number=5, ) - value_type = proto.Field(proto.STRING, number=5,) provenance = proto.Field( - proto.MESSAGE, number=8, message="Document.Provenance", + proto.MESSAGE, + number=8, + message="Document.Provenance", ) class DetectedLanguage(proto.Message): @@ -630,47 +781,88 @@ class DetectedLanguage(proto.Message): Confidence of detected language. Range [0, 1]. """ - language_code = proto.Field(proto.STRING, number=1,) - confidence = proto.Field(proto.FLOAT, number=2,) + language_code = proto.Field( + proto.STRING, + number=1, + ) + confidence = proto.Field( + proto.FLOAT, + number=2, + ) - page_number = proto.Field(proto.INT32, number=1,) - image = proto.Field(proto.MESSAGE, number=13, message="Document.Page.Image",) + page_number = proto.Field( + proto.INT32, + number=1, + ) + image = proto.Field( + proto.MESSAGE, + number=13, + message="Document.Page.Image", + ) transforms = proto.RepeatedField( - proto.MESSAGE, number=14, message="Document.Page.Matrix", + proto.MESSAGE, + number=14, + message="Document.Page.Matrix", ) dimension = proto.Field( - proto.MESSAGE, number=2, message="Document.Page.Dimension", + proto.MESSAGE, + number=2, + message="Document.Page.Dimension", + ) + layout = proto.Field( + proto.MESSAGE, + number=3, + message="Document.Page.Layout", ) - layout = proto.Field(proto.MESSAGE, number=3, message="Document.Page.Layout",) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", ) blocks = proto.RepeatedField( - proto.MESSAGE, number=5, message="Document.Page.Block", + proto.MESSAGE, + number=5, + message="Document.Page.Block", ) paragraphs = proto.RepeatedField( - proto.MESSAGE, number=6, message="Document.Page.Paragraph", + proto.MESSAGE, + number=6, + message="Document.Page.Paragraph", ) lines = proto.RepeatedField( - proto.MESSAGE, number=7, message="Document.Page.Line", + proto.MESSAGE, + number=7, + message="Document.Page.Line", ) tokens = proto.RepeatedField( - proto.MESSAGE, number=8, message="Document.Page.Token", + proto.MESSAGE, + number=8, + message="Document.Page.Token", ) visual_elements = proto.RepeatedField( - proto.MESSAGE, number=9, message="Document.Page.VisualElement", + proto.MESSAGE, + number=9, + message="Document.Page.VisualElement", ) tables = proto.RepeatedField( - proto.MESSAGE, number=10, message="Document.Page.Table", + proto.MESSAGE, + number=10, + message="Document.Page.Table", ) form_fields = proto.RepeatedField( - proto.MESSAGE, number=11, message="Document.Page.FormField", + proto.MESSAGE, + number=11, + message="Document.Page.FormField", ) symbols = proto.RepeatedField( - proto.MESSAGE, number=12, message="Document.Page.Symbol", + proto.MESSAGE, + number=12, + message="Document.Page.Symbol", ) provenance = proto.Field( - proto.MESSAGE, number=16, message="Document.Provenance", + proto.MESSAGE, + number=16, + message="Document.Provenance", ) class Entity(proto.Message): @@ -798,30 +990,65 @@ class NormalizedValue(proto.Message): oneof="structured_value", message=postal_address_pb2.PostalAddress, ) - boolean_value = proto.Field(proto.BOOL, number=6, oneof="structured_value",) - text = proto.Field(proto.STRING, number=1,) + boolean_value = proto.Field( + proto.BOOL, + number=6, + oneof="structured_value", + ) + text = proto.Field( + proto.STRING, + number=1, + ) text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + type_ = proto.Field( + proto.STRING, + number=2, + ) + mention_text = proto.Field( + proto.STRING, + number=3, + ) + mention_id = proto.Field( + proto.STRING, + number=4, + ) + confidence = proto.Field( + proto.FLOAT, + number=5, ) - type_ = proto.Field(proto.STRING, number=2,) - mention_text = proto.Field(proto.STRING, number=3,) - mention_id = proto.Field(proto.STRING, number=4,) - confidence = proto.Field(proto.FLOAT, number=5,) page_anchor = proto.Field( - proto.MESSAGE, number=6, message="Document.PageAnchor", + proto.MESSAGE, + number=6, + message="Document.PageAnchor", + ) + id = proto.Field( + proto.STRING, + number=7, ) - id = proto.Field(proto.STRING, number=7,) normalized_value = proto.Field( - proto.MESSAGE, number=9, message="Document.Entity.NormalizedValue", + proto.MESSAGE, + number=9, + message="Document.Entity.NormalizedValue", ) properties = proto.RepeatedField( - proto.MESSAGE, number=10, message="Document.Entity", + proto.MESSAGE, + number=10, + message="Document.Entity", ) provenance = proto.Field( - proto.MESSAGE, number=11, message="Document.Provenance", + proto.MESSAGE, + number=11, + message="Document.Provenance", + ) + redacted = proto.Field( + proto.BOOL, + number=12, ) - redacted = proto.Field(proto.BOOL, number=12,) class EntityRelation(proto.Message): r"""Relationship between @@ -836,9 +1063,18 @@ class EntityRelation(proto.Message): Relationship description. """ - subject_id = proto.Field(proto.STRING, number=1,) - object_id = proto.Field(proto.STRING, number=2,) - relation = proto.Field(proto.STRING, number=3,) + subject_id = proto.Field( + proto.STRING, + number=1, + ) + object_id = proto.Field( + proto.STRING, + number=2, + ) + relation = proto.Field( + proto.STRING, + number=3, + ) class TextAnchor(proto.Message): r"""Text reference indexing into the @@ -872,13 +1108,24 @@ class TextSegment(proto.Message): [Document.text][google.cloud.documentai.v1.Document.text]. """ - start_index = proto.Field(proto.INT64, number=1,) - end_index = proto.Field(proto.INT64, number=2,) + start_index = proto.Field( + proto.INT64, + number=1, + ) + end_index = proto.Field( + proto.INT64, + number=2, + ) text_segments = proto.RepeatedField( - proto.MESSAGE, number=1, message="Document.TextAnchor.TextSegment", + proto.MESSAGE, + number=1, + message="Document.TextAnchor.TextSegment", + ) + content = proto.Field( + proto.STRING, + number=2, ) - content = proto.Field(proto.STRING, number=2,) class PageAnchor(proto.Message): r"""Referencing the visual context of the entity in the @@ -930,18 +1177,33 @@ class LayoutType(proto.Enum): TABLE = 6 FORM_FIELD = 7 - page = proto.Field(proto.INT64, number=1,) + page = proto.Field( + proto.INT64, + number=1, + ) layout_type = proto.Field( - proto.ENUM, number=2, enum="Document.PageAnchor.PageRef.LayoutType", + proto.ENUM, + number=2, + enum="Document.PageAnchor.PageRef.LayoutType", + ) + layout_id = proto.Field( + proto.STRING, + number=3, ) - layout_id = proto.Field(proto.STRING, number=3,) bounding_poly = proto.Field( - proto.MESSAGE, number=4, message=geometry.BoundingPoly, + proto.MESSAGE, + number=4, + message=geometry.BoundingPoly, + ) + confidence = proto.Field( + proto.FLOAT, + number=5, ) - confidence = proto.Field(proto.FLOAT, number=5,) page_refs = proto.RepeatedField( - proto.MESSAGE, number=1, message="Document.PageAnchor.PageRef", + proto.MESSAGE, + number=1, + message="Document.PageAnchor.PageRef", ) class Provenance(proto.Message): @@ -991,17 +1253,36 @@ class Parent(proto.Message): The id of the parent provenance. """ - revision = proto.Field(proto.INT32, number=1,) - index = proto.Field(proto.INT32, number=3,) - id = proto.Field(proto.INT32, number=2,) + revision = proto.Field( + proto.INT32, + number=1, + ) + index = proto.Field( + proto.INT32, + number=3, + ) + id = proto.Field( + proto.INT32, + number=2, + ) - revision = proto.Field(proto.INT32, number=1,) - id = proto.Field(proto.INT32, number=2,) + revision = proto.Field( + proto.INT32, + number=1, + ) + id = proto.Field( + proto.INT32, + number=2, + ) parents = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Provenance.Parent", + proto.MESSAGE, + number=3, + message="Document.Provenance.Parent", ) type_ = proto.Field( - proto.ENUM, number=4, enum="Document.Provenance.OperationType", + proto.ENUM, + number=4, + enum="Document.Provenance.OperationType", ) class Revision(proto.Message): @@ -1051,18 +1332,42 @@ class HumanReview(proto.Message): is ``rejected``. """ - state = proto.Field(proto.STRING, number=1,) - state_message = proto.Field(proto.STRING, number=2,) + state = proto.Field( + proto.STRING, + number=1, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) - agent = proto.Field(proto.STRING, number=4, oneof="source",) - processor = proto.Field(proto.STRING, number=5, oneof="source",) - id = proto.Field(proto.STRING, number=1,) - parent = proto.RepeatedField(proto.INT32, number=2,) + agent = proto.Field( + proto.STRING, + number=4, + oneof="source", + ) + processor = proto.Field( + proto.STRING, + number=5, + oneof="source", + ) + id = proto.Field( + proto.STRING, + number=1, + ) + parent = proto.RepeatedField( + proto.INT32, + number=2, + ) create_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, ) human_review = proto.Field( - proto.MESSAGE, number=6, message="Document.Revision.HumanReview", + proto.MESSAGE, + number=6, + message="Document.Revision.HumanReview", ) class TextChange(proto.Message): @@ -1083,27 +1388,78 @@ class TextChange(proto.Message): """ text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + changed_text = proto.Field( + proto.STRING, + number=2, ) - changed_text = proto.Field(proto.STRING, number=2,) provenance = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Provenance", + proto.MESSAGE, + number=3, + message="Document.Provenance", ) - uri = proto.Field(proto.STRING, number=1, oneof="source",) - content = proto.Field(proto.BYTES, number=2, oneof="source",) - mime_type = proto.Field(proto.STRING, number=3,) - text = proto.Field(proto.STRING, number=4,) - text_styles = proto.RepeatedField(proto.MESSAGE, number=5, message=Style,) - pages = proto.RepeatedField(proto.MESSAGE, number=6, message=Page,) - entities = proto.RepeatedField(proto.MESSAGE, number=7, message=Entity,) + uri = proto.Field( + proto.STRING, + number=1, + oneof="source", + ) + content = proto.Field( + proto.BYTES, + number=2, + oneof="source", + ) + mime_type = proto.Field( + proto.STRING, + number=3, + ) + text = proto.Field( + proto.STRING, + number=4, + ) + text_styles = proto.RepeatedField( + proto.MESSAGE, + number=5, + message=Style, + ) + pages = proto.RepeatedField( + proto.MESSAGE, + number=6, + message=Page, + ) + entities = proto.RepeatedField( + proto.MESSAGE, + number=7, + message=Entity, + ) entity_relations = proto.RepeatedField( - proto.MESSAGE, number=8, message=EntityRelation, + proto.MESSAGE, + number=8, + message=EntityRelation, + ) + text_changes = proto.RepeatedField( + proto.MESSAGE, + number=14, + message=TextChange, + ) + shard_info = proto.Field( + proto.MESSAGE, + number=9, + message=ShardInfo, + ) + error = proto.Field( + proto.MESSAGE, + number=10, + message=status_pb2.Status, + ) + revisions = proto.RepeatedField( + proto.MESSAGE, + number=13, + message=Revision, ) - text_changes = proto.RepeatedField(proto.MESSAGE, number=14, message=TextChange,) - shard_info = proto.Field(proto.MESSAGE, number=9, message=ShardInfo,) - error = proto.Field(proto.MESSAGE, number=10, message=status_pb2.Status,) - revisions = proto.RepeatedField(proto.MESSAGE, number=13, message=Revision,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1/types/document_io.py b/google/cloud/documentai_v1/types/document_io.py index 2f5d326b..cb8bc982 100644 --- a/google/cloud/documentai_v1/types/document_io.py +++ b/google/cloud/documentai_v1/types/document_io.py @@ -40,8 +40,14 @@ class RawDocument(proto.Message): of the [content]. """ - content = proto.Field(proto.BYTES, number=1,) - mime_type = proto.Field(proto.STRING, number=2,) + content = proto.Field( + proto.BYTES, + number=1, + ) + mime_type = proto.Field( + proto.STRING, + number=2, + ) class GcsDocument(proto.Message): @@ -54,8 +60,14 @@ class GcsDocument(proto.Message): An IANA MIME type (RFC6838) of the content. """ - gcs_uri = proto.Field(proto.STRING, number=1,) - mime_type = proto.Field(proto.STRING, number=2,) + gcs_uri = proto.Field( + proto.STRING, + number=1, + ) + mime_type = proto.Field( + proto.STRING, + number=2, + ) class GcsDocuments(proto.Message): @@ -66,7 +78,11 @@ class GcsDocuments(proto.Message): The list of documents. """ - documents = proto.RepeatedField(proto.MESSAGE, number=1, message="GcsDocument",) + documents = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="GcsDocument", + ) class GcsPrefix(proto.Message): @@ -78,7 +94,10 @@ class GcsPrefix(proto.Message): The URI prefix. """ - gcs_uri_prefix = proto.Field(proto.STRING, number=1,) + gcs_uri_prefix = proto.Field( + proto.STRING, + number=1, + ) class BatchDocumentsInputConfig(proto.Message): @@ -106,10 +125,16 @@ class BatchDocumentsInputConfig(proto.Message): """ gcs_prefix = proto.Field( - proto.MESSAGE, number=1, oneof="source", message="GcsPrefix", + proto.MESSAGE, + number=1, + oneof="source", + message="GcsPrefix", ) gcs_documents = proto.Field( - proto.MESSAGE, number=2, oneof="source", message="GcsDocuments", + proto.MESSAGE, + number=2, + oneof="source", + message="GcsDocuments", ) @@ -137,10 +162,16 @@ class GcsOutputConfig(proto.Message): output. """ - gcs_uri = proto.Field(proto.STRING, number=1,) + gcs_uri = proto.Field( + proto.STRING, + number=1, + ) gcs_output_config = proto.Field( - proto.MESSAGE, number=1, oneof="destination", message=GcsOutputConfig, + proto.MESSAGE, + number=1, + oneof="destination", + message=GcsOutputConfig, ) diff --git a/google/cloud/documentai_v1/types/document_processor_service.py b/google/cloud/documentai_v1/types/document_processor_service.py index c7a71cd9..44c6a781 100644 --- a/google/cloud/documentai_v1/types/document_processor_service.py +++ b/google/cloud/documentai_v1/types/document_processor_service.py @@ -65,13 +65,25 @@ class ProcessRequest(proto.Message): """ inline_document = proto.Field( - proto.MESSAGE, number=4, oneof="source", message=gcd_document.Document, + proto.MESSAGE, + number=4, + oneof="source", + message=gcd_document.Document, ) raw_document = proto.Field( - proto.MESSAGE, number=5, oneof="source", message=document_io.RawDocument, + proto.MESSAGE, + number=5, + oneof="source", + message=document_io.RawDocument, + ) + name = proto.Field( + proto.STRING, + number=1, + ) + skip_human_review = proto.Field( + proto.BOOL, + number=3, ) - name = proto.Field(proto.STRING, number=1,) - skip_human_review = proto.Field(proto.BOOL, number=3,) class HumanReviewStatus(proto.Message): @@ -100,9 +112,19 @@ class State(proto.Enum): IN_PROGRESS = 3 ERROR = 4 - state = proto.Field(proto.ENUM, number=1, enum=State,) - state_message = proto.Field(proto.STRING, number=2,) - human_review_operation = proto.Field(proto.STRING, number=3,) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) + human_review_operation = proto.Field( + proto.STRING, + number=3, + ) class ProcessResponse(proto.Message): @@ -117,9 +139,15 @@ class ProcessResponse(proto.Message): document. """ - document = proto.Field(proto.MESSAGE, number=1, message=gcd_document.Document,) + document = proto.Field( + proto.MESSAGE, + number=1, + message=gcd_document.Document, + ) human_review_status = proto.Field( - proto.MESSAGE, number=3, message="HumanReviewStatus", + proto.MESSAGE, + number=3, + message="HumanReviewStatus", ) @@ -138,19 +166,28 @@ class BatchProcessRequest(proto.Message): skipped for this request. Default to false. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) input_documents = proto.Field( - proto.MESSAGE, number=5, message=document_io.BatchDocumentsInputConfig, + proto.MESSAGE, + number=5, + message=document_io.BatchDocumentsInputConfig, ) document_output_config = proto.Field( - proto.MESSAGE, number=6, message=document_io.DocumentOutputConfig, + proto.MESSAGE, + number=6, + message=document_io.DocumentOutputConfig, + ) + skip_human_review = proto.Field( + proto.BOOL, + number=4, ) - skip_human_review = proto.Field(proto.BOOL, number=4,) class BatchProcessResponse(proto.Message): - r"""Response message for batch process document method. - """ + r"""Response message for batch process document method.""" class BatchProcessMetadata(proto.Message): @@ -204,19 +241,48 @@ class IndividualProcessStatus(proto.Message): document. """ - input_gcs_source = proto.Field(proto.STRING, number=1,) - status = proto.Field(proto.MESSAGE, number=2, message=status_pb2.Status,) - output_gcs_destination = proto.Field(proto.STRING, number=3,) + input_gcs_source = proto.Field( + proto.STRING, + number=1, + ) + status = proto.Field( + proto.MESSAGE, + number=2, + message=status_pb2.Status, + ) + output_gcs_destination = proto.Field( + proto.STRING, + number=3, + ) human_review_status = proto.Field( - proto.MESSAGE, number=5, message="HumanReviewStatus", + proto.MESSAGE, + number=5, + message="HumanReviewStatus", ) - state = proto.Field(proto.ENUM, number=1, enum=State,) - state_message = proto.Field(proto.STRING, number=2,) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) individual_process_statuses = proto.RepeatedField( - proto.MESSAGE, number=5, message=IndividualProcessStatus, + proto.MESSAGE, + number=5, + message=IndividualProcessStatus, ) @@ -247,11 +313,24 @@ class Priority(proto.Enum): URGENT = 1 inline_document = proto.Field( - proto.MESSAGE, number=4, oneof="source", message=gcd_document.Document, + proto.MESSAGE, + number=4, + oneof="source", + message=gcd_document.Document, + ) + human_review_config = proto.Field( + proto.STRING, + number=1, + ) + enable_schema_validation = proto.Field( + proto.BOOL, + number=3, + ) + priority = proto.Field( + proto.ENUM, + number=5, + enum=Priority, ) - human_review_config = proto.Field(proto.STRING, number=1,) - enable_schema_validation = proto.Field(proto.BOOL, number=3,) - priority = proto.Field(proto.ENUM, number=5, enum=Priority,) class ReviewDocumentResponse(proto.Message): @@ -263,7 +342,10 @@ class ReviewDocumentResponse(proto.Message): document. """ - gcs_destination = proto.Field(proto.STRING, number=1,) + gcs_destination = proto.Field( + proto.STRING, + number=1, + ) class ReviewDocumentOperationMetadata(proto.Message): @@ -279,9 +361,14 @@ class ReviewDocumentOperationMetadata(proto.Message): """ common_metadata = proto.Field( - proto.MESSAGE, number=5, message=operation_metadata.CommonOperationMetadata, + proto.MESSAGE, + number=5, + message=operation_metadata.CommonOperationMetadata, + ) + question_id = proto.Field( + proto.STRING, + number=6, ) - question_id = proto.Field(proto.STRING, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1/types/geometry.py b/google/cloud/documentai_v1/types/geometry.py index d6b41600..3d0c665a 100644 --- a/google/cloud/documentai_v1/types/geometry.py +++ b/google/cloud/documentai_v1/types/geometry.py @@ -18,7 +18,11 @@ __protobuf__ = proto.module( package="google.cloud.documentai.v1", - manifest={"Vertex", "NormalizedVertex", "BoundingPoly",}, + manifest={ + "Vertex", + "NormalizedVertex", + "BoundingPoly", + }, ) @@ -35,8 +39,14 @@ class Vertex(proto.Message): image). """ - x = proto.Field(proto.INT32, number=1,) - y = proto.Field(proto.INT32, number=2,) + x = proto.Field( + proto.INT32, + number=1, + ) + y = proto.Field( + proto.INT32, + number=2, + ) class NormalizedVertex(proto.Message): @@ -52,8 +62,14 @@ class NormalizedVertex(proto.Message): image). """ - x = proto.Field(proto.FLOAT, number=1,) - y = proto.Field(proto.FLOAT, number=2,) + x = proto.Field( + proto.FLOAT, + number=1, + ) + y = proto.Field( + proto.FLOAT, + number=2, + ) class BoundingPoly(proto.Message): @@ -66,9 +82,15 @@ class BoundingPoly(proto.Message): The bounding polygon normalized vertices. """ - vertices = proto.RepeatedField(proto.MESSAGE, number=1, message="Vertex",) + vertices = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Vertex", + ) normalized_vertices = proto.RepeatedField( - proto.MESSAGE, number=2, message="NormalizedVertex", + proto.MESSAGE, + number=2, + message="NormalizedVertex", ) diff --git a/google/cloud/documentai_v1/types/operation_metadata.py b/google/cloud/documentai_v1/types/operation_metadata.py index 32db9d66..e6037b71 100644 --- a/google/cloud/documentai_v1/types/operation_metadata.py +++ b/google/cloud/documentai_v1/types/operation_metadata.py @@ -19,7 +19,10 @@ __protobuf__ = proto.module( - package="google.cloud.documentai.v1", manifest={"CommonOperationMetadata",}, + package="google.cloud.documentai.v1", + manifest={ + "CommonOperationMetadata", + }, ) @@ -47,10 +50,25 @@ class State(proto.Enum): FAILED = 4 CANCELLED = 5 - state = proto.Field(proto.ENUM, number=1, enum=State,) - state_message = proto.Field(proto.STRING, number=2,) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py index 0f83bafa..417291c3 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py @@ -323,7 +323,12 @@ def sample_batch_process_documents(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -417,7 +422,12 @@ def sample_process_document(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py index ba817046..fd7b8776 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py @@ -61,7 +61,8 @@ class DocumentUnderstandingServiceClientMeta(type): ] = DocumentUnderstandingServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[DocumentUnderstandingServiceTransport]: """Returns an appropriate transport class. @@ -172,7 +173,9 @@ def transport(self) -> DocumentUnderstandingServiceTransport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -185,9 +188,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -196,9 +203,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -207,9 +218,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -218,10 +233,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -495,7 +514,12 @@ def sample_batch_process_documents(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -580,7 +604,12 @@ def sample_process_document(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py index d231500e..2282ea3a 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py @@ -158,9 +158,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py index d58f124c..8b2a4f8b 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py @@ -230,8 +230,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/documentai_v1beta2/types/document.py b/google/cloud/documentai_v1beta2/types/document.py index 94be9ebb..5c425ffe 100644 --- a/google/cloud/documentai_v1beta2/types/document.py +++ b/google/cloud/documentai_v1beta2/types/document.py @@ -21,7 +21,10 @@ __protobuf__ = proto.module( - package="google.cloud.documentai.v1beta2", manifest={"Document",}, + package="google.cloud.documentai.v1beta2", + manifest={ + "Document", + }, ) @@ -105,9 +108,18 @@ class ShardInfo(proto.Message): in the overall document global text. """ - shard_index = proto.Field(proto.INT64, number=1,) - shard_count = proto.Field(proto.INT64, number=2,) - text_offset = proto.Field(proto.INT64, number=3,) + shard_index = proto.Field( + proto.INT64, + number=1, + ) + shard_count = proto.Field( + proto.INT64, + number=2, + ) + text_offset = proto.Field( + proto.INT64, + number=3, + ) class Label(proto.Message): r"""Label attaches schema information and/or other metadata to segments @@ -139,9 +151,19 @@ class Label(proto.Message): assignment. """ - automl_model = proto.Field(proto.STRING, number=2, oneof="source",) - name = proto.Field(proto.STRING, number=1,) - confidence = proto.Field(proto.FLOAT, number=3,) + automl_model = proto.Field( + proto.STRING, + number=2, + oneof="source", + ) + name = proto.Field( + proto.STRING, + number=1, + ) + confidence = proto.Field( + proto.FLOAT, + number=3, + ) class Style(proto.Message): r"""Annotation for common text style attributes. This adheres to @@ -179,21 +201,46 @@ class FontSize(proto.Message): (in, px, pt, etc.). """ - size = proto.Field(proto.FLOAT, number=1,) - unit = proto.Field(proto.STRING, number=2,) + size = proto.Field( + proto.FLOAT, + number=1, + ) + unit = proto.Field( + proto.STRING, + number=2, + ) text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + color = proto.Field( + proto.MESSAGE, + number=2, + message=color_pb2.Color, ) - color = proto.Field(proto.MESSAGE, number=2, message=color_pb2.Color,) background_color = proto.Field( - proto.MESSAGE, number=3, message=color_pb2.Color, + proto.MESSAGE, + number=3, + message=color_pb2.Color, + ) + font_weight = proto.Field( + proto.STRING, + number=4, + ) + text_style = proto.Field( + proto.STRING, + number=5, + ) + text_decoration = proto.Field( + proto.STRING, + number=6, ) - font_weight = proto.Field(proto.STRING, number=4,) - text_style = proto.Field(proto.STRING, number=5,) - text_decoration = proto.Field(proto.STRING, number=6,) font_size = proto.Field( - proto.MESSAGE, number=7, message="Document.Style.FontSize", + proto.MESSAGE, + number=7, + message="Document.Style.FontSize", ) class Page(proto.Message): @@ -254,9 +301,18 @@ class Dimension(proto.Message): Dimension unit. """ - width = proto.Field(proto.FLOAT, number=1,) - height = proto.Field(proto.FLOAT, number=2,) - unit = proto.Field(proto.STRING, number=3,) + width = proto.Field( + proto.FLOAT, + number=1, + ) + height = proto.Field( + proto.FLOAT, + number=2, + ) + unit = proto.Field( + proto.STRING, + number=3, + ) class Layout(proto.Message): r"""Visual element describing a layout unit on a page. @@ -291,16 +347,28 @@ class Orientation(proto.Enum): PAGE_LEFT = 4 text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + confidence = proto.Field( + proto.FLOAT, + number=2, ) - confidence = proto.Field(proto.FLOAT, number=2,) bounding_poly = proto.Field( - proto.MESSAGE, number=3, message=geometry.BoundingPoly, + proto.MESSAGE, + number=3, + message=geometry.BoundingPoly, ) orientation = proto.Field( - proto.ENUM, number=4, enum="Document.Page.Layout.Orientation", + proto.ENUM, + number=4, + enum="Document.Page.Layout.Orientation", + ) + id = proto.Field( + proto.STRING, + number=5, ) - id = proto.Field(proto.STRING, number=5,) class Block(proto.Message): r"""A block has a set of lines (collected into paragraphs) that @@ -317,10 +385,14 @@ class Block(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) class Paragraph(proto.Message): @@ -338,10 +410,14 @@ class Paragraph(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) class Line(proto.Message): @@ -360,10 +436,14 @@ class Line(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) class Token(proto.Message): @@ -399,17 +479,25 @@ class Type(proto.Enum): HYPHEN = 3 type_ = proto.Field( - proto.ENUM, number=1, enum="Document.Page.Token.DetectedBreak.Type", + proto.ENUM, + number=1, + enum="Document.Page.Token.DetectedBreak.Type", ) layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_break = proto.Field( - proto.MESSAGE, number=2, message="Document.Page.Token.DetectedBreak", + proto.MESSAGE, + number=2, + message="Document.Page.Token.DetectedBreak", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=3, + message="Document.Page.DetectedLanguage", ) class VisualElement(proto.Message): @@ -430,11 +518,18 @@ class VisualElement(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", + ) + type_ = proto.Field( + proto.STRING, + number=2, ) - type_ = proto.Field(proto.STRING, number=2,) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=3, + message="Document.Page.DetectedLanguage", ) class Table(proto.Message): @@ -463,7 +558,9 @@ class TableRow(proto.Message): """ cells = proto.RepeatedField( - proto.MESSAGE, number=1, message="Document.Page.Table.TableCell", + proto.MESSAGE, + number=1, + message="Document.Page.Table.TableCell", ) class TableCell(proto.Message): @@ -484,25 +581,43 @@ class TableCell(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", + ) + row_span = proto.Field( + proto.INT32, + number=2, + ) + col_span = proto.Field( + proto.INT32, + number=3, ) - row_span = proto.Field(proto.INT32, number=2,) - col_span = proto.Field(proto.INT32, number=3,) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", ) layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) header_rows = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.Table.TableRow", + proto.MESSAGE, + number=2, + message="Document.Page.Table.TableRow", ) body_rows = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.Table.TableRow", + proto.MESSAGE, + number=3, + message="Document.Page.Table.TableRow", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", ) class FormField(proto.Message): @@ -542,20 +657,37 @@ class FormField(proto.Message): """ field_name = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) field_value = proto.Field( - proto.MESSAGE, number=2, message="Document.Page.Layout", + proto.MESSAGE, + number=2, + message="Document.Page.Layout", ) name_detected_languages = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=3, + message="Document.Page.DetectedLanguage", ) value_detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", + ) + value_type = proto.Field( + proto.STRING, + number=5, + ) + corrected_key_text = proto.Field( + proto.STRING, + number=6, + ) + corrected_value_text = proto.Field( + proto.STRING, + number=7, ) - value_type = proto.Field(proto.STRING, number=5,) - corrected_key_text = proto.Field(proto.STRING, number=6,) - corrected_value_text = proto.Field(proto.STRING, number=7,) class DetectedLanguage(proto.Message): r"""Detected language for a structural component. @@ -569,37 +701,68 @@ class DetectedLanguage(proto.Message): Confidence of detected language. Range [0, 1]. """ - language_code = proto.Field(proto.STRING, number=1,) - confidence = proto.Field(proto.FLOAT, number=2,) + language_code = proto.Field( + proto.STRING, + number=1, + ) + confidence = proto.Field( + proto.FLOAT, + number=2, + ) - page_number = proto.Field(proto.INT32, number=1,) + page_number = proto.Field( + proto.INT32, + number=1, + ) dimension = proto.Field( - proto.MESSAGE, number=2, message="Document.Page.Dimension", + proto.MESSAGE, + number=2, + message="Document.Page.Dimension", + ) + layout = proto.Field( + proto.MESSAGE, + number=3, + message="Document.Page.Layout", ) - layout = proto.Field(proto.MESSAGE, number=3, message="Document.Page.Layout",) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", ) blocks = proto.RepeatedField( - proto.MESSAGE, number=5, message="Document.Page.Block", + proto.MESSAGE, + number=5, + message="Document.Page.Block", ) paragraphs = proto.RepeatedField( - proto.MESSAGE, number=6, message="Document.Page.Paragraph", + proto.MESSAGE, + number=6, + message="Document.Page.Paragraph", ) lines = proto.RepeatedField( - proto.MESSAGE, number=7, message="Document.Page.Line", + proto.MESSAGE, + number=7, + message="Document.Page.Line", ) tokens = proto.RepeatedField( - proto.MESSAGE, number=8, message="Document.Page.Token", + proto.MESSAGE, + number=8, + message="Document.Page.Token", ) visual_elements = proto.RepeatedField( - proto.MESSAGE, number=9, message="Document.Page.VisualElement", + proto.MESSAGE, + number=9, + message="Document.Page.VisualElement", ) tables = proto.RepeatedField( - proto.MESSAGE, number=10, message="Document.Page.Table", + proto.MESSAGE, + number=10, + message="Document.Page.Table", ) form_fields = proto.RepeatedField( - proto.MESSAGE, number=11, message="Document.Page.FormField", + proto.MESSAGE, + number=11, + message="Document.Page.FormField", ) class Entity(proto.Message): @@ -634,18 +797,39 @@ class Entity(proto.Message): """ text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + type_ = proto.Field( + proto.STRING, + number=2, + ) + mention_text = proto.Field( + proto.STRING, + number=3, + ) + mention_id = proto.Field( + proto.STRING, + number=4, + ) + confidence = proto.Field( + proto.FLOAT, + number=5, ) - type_ = proto.Field(proto.STRING, number=2,) - mention_text = proto.Field(proto.STRING, number=3,) - mention_id = proto.Field(proto.STRING, number=4,) - confidence = proto.Field(proto.FLOAT, number=5,) page_anchor = proto.Field( - proto.MESSAGE, number=6, message="Document.PageAnchor", + proto.MESSAGE, + number=6, + message="Document.PageAnchor", + ) + id = proto.Field( + proto.STRING, + number=7, ) - id = proto.Field(proto.STRING, number=7,) bounding_poly_for_demo_frontend = proto.Field( - proto.MESSAGE, number=8, message=geometry.BoundingPoly, + proto.MESSAGE, + number=8, + message=geometry.BoundingPoly, ) class EntityRelation(proto.Message): @@ -661,9 +845,18 @@ class EntityRelation(proto.Message): Relationship description. """ - subject_id = proto.Field(proto.STRING, number=1,) - object_id = proto.Field(proto.STRING, number=2,) - relation = proto.Field(proto.STRING, number=3,) + subject_id = proto.Field( + proto.STRING, + number=1, + ) + object_id = proto.Field( + proto.STRING, + number=2, + ) + relation = proto.Field( + proto.STRING, + number=3, + ) class TextAnchor(proto.Message): r"""Text reference indexing into the @@ -696,13 +889,24 @@ class TextSegment(proto.Message): [Document.text][google.cloud.documentai.v1beta2.Document.text]. """ - start_index = proto.Field(proto.INT64, number=1,) - end_index = proto.Field(proto.INT64, number=2,) + start_index = proto.Field( + proto.INT64, + number=1, + ) + end_index = proto.Field( + proto.INT64, + number=2, + ) text_segments = proto.RepeatedField( - proto.MESSAGE, number=1, message="Document.TextAnchor.TextSegment", + proto.MESSAGE, + number=1, + message="Document.TextAnchor.TextSegment", + ) + content = proto.Field( + proto.STRING, + number=2, ) - content = proto.Field(proto.STRING, number=2,) class PageAnchor(proto.Message): r"""Referencing elements in @@ -746,29 +950,79 @@ class LayoutType(proto.Enum): TABLE = 6 FORM_FIELD = 7 - page = proto.Field(proto.INT64, number=1,) + page = proto.Field( + proto.INT64, + number=1, + ) layout_type = proto.Field( - proto.ENUM, number=2, enum="Document.PageAnchor.PageRef.LayoutType", + proto.ENUM, + number=2, + enum="Document.PageAnchor.PageRef.LayoutType", + ) + layout_id = proto.Field( + proto.STRING, + number=3, ) - layout_id = proto.Field(proto.STRING, number=3,) page_refs = proto.RepeatedField( - proto.MESSAGE, number=1, message="Document.PageAnchor.PageRef", + proto.MESSAGE, + number=1, + message="Document.PageAnchor.PageRef", ) - uri = proto.Field(proto.STRING, number=1, oneof="source",) - content = proto.Field(proto.BYTES, number=2, oneof="source",) - mime_type = proto.Field(proto.STRING, number=3,) - text = proto.Field(proto.STRING, number=4,) - text_styles = proto.RepeatedField(proto.MESSAGE, number=5, message=Style,) - pages = proto.RepeatedField(proto.MESSAGE, number=6, message=Page,) - entities = proto.RepeatedField(proto.MESSAGE, number=7, message=Entity,) + uri = proto.Field( + proto.STRING, + number=1, + oneof="source", + ) + content = proto.Field( + proto.BYTES, + number=2, + oneof="source", + ) + mime_type = proto.Field( + proto.STRING, + number=3, + ) + text = proto.Field( + proto.STRING, + number=4, + ) + text_styles = proto.RepeatedField( + proto.MESSAGE, + number=5, + message=Style, + ) + pages = proto.RepeatedField( + proto.MESSAGE, + number=6, + message=Page, + ) + entities = proto.RepeatedField( + proto.MESSAGE, + number=7, + message=Entity, + ) entity_relations = proto.RepeatedField( - proto.MESSAGE, number=8, message=EntityRelation, + proto.MESSAGE, + number=8, + message=EntityRelation, + ) + shard_info = proto.Field( + proto.MESSAGE, + number=9, + message=ShardInfo, + ) + labels = proto.RepeatedField( + proto.MESSAGE, + number=11, + message=Label, + ) + error = proto.Field( + proto.MESSAGE, + number=10, + message=status_pb2.Status, ) - shard_info = proto.Field(proto.MESSAGE, number=9, message=ShardInfo,) - labels = proto.RepeatedField(proto.MESSAGE, number=11, message=Label,) - error = proto.Field(proto.MESSAGE, number=10, message=status_pb2.Status,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1beta2/types/document_understanding.py b/google/cloud/documentai_v1beta2/types/document_understanding.py index d0df2906..e655eabd 100644 --- a/google/cloud/documentai_v1beta2/types/document_understanding.py +++ b/google/cloud/documentai_v1beta2/types/document_understanding.py @@ -60,9 +60,14 @@ class BatchProcessDocumentsRequest(proto.Message): """ requests = proto.RepeatedField( - proto.MESSAGE, number=1, message="ProcessDocumentRequest", + proto.MESSAGE, + number=1, + message="ProcessDocumentRequest", + ) + parent = proto.Field( + proto.STRING, + number=2, ) - parent = proto.Field(proto.STRING, number=2,) class ProcessDocumentRequest(proto.Message): @@ -110,21 +115,49 @@ class ProcessDocumentRequest(proto.Message): Params. """ - parent = proto.Field(proto.STRING, number=9,) - input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",) - output_config = proto.Field(proto.MESSAGE, number=2, message="OutputConfig",) - document_type = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=9, + ) + input_config = proto.Field( + proto.MESSAGE, + number=1, + message="InputConfig", + ) + output_config = proto.Field( + proto.MESSAGE, + number=2, + message="OutputConfig", + ) + document_type = proto.Field( + proto.STRING, + number=3, + ) table_extraction_params = proto.Field( - proto.MESSAGE, number=4, message="TableExtractionParams", + proto.MESSAGE, + number=4, + message="TableExtractionParams", ) form_extraction_params = proto.Field( - proto.MESSAGE, number=5, message="FormExtractionParams", + proto.MESSAGE, + number=5, + message="FormExtractionParams", ) entity_extraction_params = proto.Field( - proto.MESSAGE, number=6, message="EntityExtractionParams", + proto.MESSAGE, + number=6, + message="EntityExtractionParams", + ) + ocr_params = proto.Field( + proto.MESSAGE, + number=7, + message="OcrParams", + ) + automl_params = proto.Field( + proto.MESSAGE, + number=8, + message="AutoMlParams", ) - ocr_params = proto.Field(proto.MESSAGE, number=7, message="OcrParams",) - automl_params = proto.Field(proto.MESSAGE, number=8, message="AutoMlParams",) class BatchProcessDocumentsResponse(proto.Message): @@ -137,7 +170,9 @@ class BatchProcessDocumentsResponse(proto.Message): """ responses = proto.RepeatedField( - proto.MESSAGE, number=1, message="ProcessDocumentResponse", + proto.MESSAGE, + number=1, + message="ProcessDocumentResponse", ) @@ -155,8 +190,16 @@ class ProcessDocumentResponse(proto.Message): objects. """ - input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",) - output_config = proto.Field(proto.MESSAGE, number=2, message="OutputConfig",) + input_config = proto.Field( + proto.MESSAGE, + number=1, + message="InputConfig", + ) + output_config = proto.Field( + proto.MESSAGE, + number=2, + message="OutputConfig", + ) class OcrParams(proto.Message): @@ -176,7 +219,10 @@ class OcrParams(proto.Message): specified languages is not one of the supported languages. """ - language_hints = proto.RepeatedField(proto.STRING, number=1,) + language_hints = proto.RepeatedField( + proto.STRING, + number=1, + ) class TableExtractionParams(proto.Message): @@ -199,12 +245,23 @@ class TableExtractionParams(proto.Message): "builtin/latest" for the latest model. """ - enabled = proto.Field(proto.BOOL, number=1,) + enabled = proto.Field( + proto.BOOL, + number=1, + ) table_bound_hints = proto.RepeatedField( - proto.MESSAGE, number=2, message="TableBoundHint", + proto.MESSAGE, + number=2, + message="TableBoundHint", + ) + header_hints = proto.RepeatedField( + proto.STRING, + number=3, + ) + model_version = proto.Field( + proto.STRING, + number=4, ) - header_hints = proto.RepeatedField(proto.STRING, number=3,) - model_version = proto.Field(proto.STRING, number=4,) class TableBoundHint(proto.Message): @@ -223,8 +280,15 @@ class TableBoundHint(proto.Message): axis-aligned rectangle. """ - page_number = proto.Field(proto.INT32, number=1,) - bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,) + page_number = proto.Field( + proto.INT32, + number=1, + ) + bounding_box = proto.Field( + proto.MESSAGE, + number=2, + message=geometry.BoundingPoly, + ) class FormExtractionParams(proto.Message): @@ -257,11 +321,19 @@ class FormExtractionParams(proto.Message): are stored. """ - enabled = proto.Field(proto.BOOL, number=1,) + enabled = proto.Field( + proto.BOOL, + number=1, + ) key_value_pair_hints = proto.RepeatedField( - proto.MESSAGE, number=2, message="KeyValuePairHint", + proto.MESSAGE, + number=2, + message="KeyValuePairHint", + ) + model_version = proto.Field( + proto.STRING, + number=3, ) - model_version = proto.Field(proto.STRING, number=3,) class KeyValuePairHint(proto.Message): @@ -277,8 +349,14 @@ class KeyValuePairHint(proto.Message): Types not in this list will be ignored. """ - key = proto.Field(proto.STRING, number=1,) - value_types = proto.RepeatedField(proto.STRING, number=2,) + key = proto.Field( + proto.STRING, + number=1, + ) + value_types = proto.RepeatedField( + proto.STRING, + number=2, + ) class EntityExtractionParams(proto.Message): @@ -293,8 +371,14 @@ class EntityExtractionParams(proto.Message): "builtin/latest" for the latest model. """ - enabled = proto.Field(proto.BOOL, number=1,) - model_version = proto.Field(proto.STRING, number=2,) + enabled = proto.Field( + proto.BOOL, + number=1, + ) + model_version = proto.Field( + proto.STRING, + number=2, + ) class AutoMlParams(proto.Message): @@ -308,7 +392,10 @@ class AutoMlParams(proto.Message): ``projects/{project-id}/locations/{location-id}/models/{model-id}``. """ - model = proto.Field(proto.STRING, number=1,) + model = proto.Field( + proto.STRING, + number=1, + ) class InputConfig(proto.Message): @@ -347,10 +434,20 @@ class InputConfig(proto.Message): """ gcs_source = proto.Field( - proto.MESSAGE, number=1, oneof="source", message="GcsSource", + proto.MESSAGE, + number=1, + oneof="source", + message="GcsSource", + ) + contents = proto.Field( + proto.BYTES, + number=3, + oneof="source", + ) + mime_type = proto.Field( + proto.STRING, + number=2, ) - contents = proto.Field(proto.BYTES, number=3, oneof="source",) - mime_type = proto.Field(proto.STRING, number=2,) class OutputConfig(proto.Message): @@ -385,9 +482,15 @@ class OutputConfig(proto.Message): """ gcs_destination = proto.Field( - proto.MESSAGE, number=1, oneof="destination", message="GcsDestination", + proto.MESSAGE, + number=1, + oneof="destination", + message="GcsDestination", + ) + pages_per_shard = proto.Field( + proto.INT32, + number=2, ) - pages_per_shard = proto.Field(proto.INT32, number=2,) class GcsSource(proto.Message): @@ -399,7 +502,10 @@ class GcsSource(proto.Message): """ - uri = proto.Field(proto.STRING, number=1,) + uri = proto.Field( + proto.STRING, + number=1, + ) class GcsDestination(proto.Message): @@ -411,7 +517,10 @@ class GcsDestination(proto.Message): """ - uri = proto.Field(proto.STRING, number=1,) + uri = proto.Field( + proto.STRING, + number=1, + ) class OperationMetadata(proto.Message): @@ -439,10 +548,25 @@ class State(proto.Enum): CANCELLED = 5 FAILED = 6 - state = proto.Field(proto.ENUM, number=1, enum=State,) - state_message = proto.Field(proto.STRING, number=2,) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1beta2/types/geometry.py b/google/cloud/documentai_v1beta2/types/geometry.py index cb593df2..6f983474 100644 --- a/google/cloud/documentai_v1beta2/types/geometry.py +++ b/google/cloud/documentai_v1beta2/types/geometry.py @@ -18,7 +18,11 @@ __protobuf__ = proto.module( package="google.cloud.documentai.v1beta2", - manifest={"Vertex", "NormalizedVertex", "BoundingPoly",}, + manifest={ + "Vertex", + "NormalizedVertex", + "BoundingPoly", + }, ) @@ -34,8 +38,14 @@ class Vertex(proto.Message): Y coordinate. """ - x = proto.Field(proto.INT32, number=1,) - y = proto.Field(proto.INT32, number=2,) + x = proto.Field( + proto.INT32, + number=1, + ) + y = proto.Field( + proto.INT32, + number=2, + ) class NormalizedVertex(proto.Message): @@ -50,8 +60,14 @@ class NormalizedVertex(proto.Message): Y coordinate. """ - x = proto.Field(proto.FLOAT, number=1,) - y = proto.Field(proto.FLOAT, number=2,) + x = proto.Field( + proto.FLOAT, + number=1, + ) + y = proto.Field( + proto.FLOAT, + number=2, + ) class BoundingPoly(proto.Message): @@ -64,9 +80,15 @@ class BoundingPoly(proto.Message): The bounding polygon normalized vertices. """ - vertices = proto.RepeatedField(proto.MESSAGE, number=1, message="Vertex",) + vertices = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Vertex", + ) normalized_vertices = proto.RepeatedField( - proto.MESSAGE, number=2, message="NormalizedVertex", + proto.MESSAGE, + number=2, + message="NormalizedVertex", ) diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py index 64f6f451..09de0c54 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py @@ -333,7 +333,12 @@ def sample_process_document(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -442,7 +447,12 @@ def sample_batch_process_documents(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -543,7 +553,12 @@ def sample_fetch_processor_types(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -638,12 +653,20 @@ def sample_list_processors(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListProcessorsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -754,7 +777,12 @@ def sample_create_processor(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -864,7 +892,12 @@ def sample_delete_processor(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -947,7 +980,12 @@ def sample_enable_processor(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1030,7 +1068,12 @@ def sample_disable_processor(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1154,7 +1197,12 @@ def sample_review_document(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py index 00c31dd5..30336ce1 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py @@ -64,7 +64,8 @@ class DocumentProcessorServiceClientMeta(type): _transport_registry["grpc_asyncio"] = DocumentProcessorServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[DocumentProcessorServiceTransport]: """Returns an appropriate transport class. @@ -175,10 +176,16 @@ def transport(self) -> DocumentProcessorServiceTransport: return self._transport @staticmethod - def human_review_config_path(project: str, location: str, processor: str,) -> str: + def human_review_config_path( + project: str, + location: str, + processor: str, + ) -> str: """Returns a fully-qualified human_review_config string.""" return "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig".format( - project=project, location=location, processor=processor, + project=project, + location=location, + processor=processor, ) @staticmethod @@ -191,10 +198,16 @@ def parse_human_review_config_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def processor_path(project: str, location: str, processor: str,) -> str: + def processor_path( + project: str, + location: str, + processor: str, + ) -> str: """Returns a fully-qualified processor string.""" return "projects/{project}/locations/{location}/processors/{processor}".format( - project=project, location=location, processor=processor, + project=project, + location=location, + processor=processor, ) @staticmethod @@ -207,10 +220,16 @@ def parse_processor_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def processor_type_path(project: str, location: str, processor_type: str,) -> str: + def processor_type_path( + project: str, + location: str, + processor_type: str, + ) -> str: """Returns a fully-qualified processor_type string.""" return "projects/{project}/locations/{location}/processorTypes/{processor_type}".format( - project=project, location=location, processor_type=processor_type, + project=project, + location=location, + processor_type=processor_type, ) @staticmethod @@ -223,7 +242,9 @@ def parse_processor_type_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -236,9 +257,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -247,9 +272,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -258,9 +287,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -269,10 +302,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -535,7 +572,12 @@ def sample_process_document(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -634,7 +676,12 @@ def sample_batch_process_documents(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -737,7 +784,12 @@ def sample_fetch_processor_types(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -832,12 +884,20 @@ def sample_list_processors(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListProcessorsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -948,7 +1008,12 @@ def sample_create_processor(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1058,7 +1123,12 @@ def sample_delete_processor(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1142,7 +1212,12 @@ def sample_enable_processor(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1226,7 +1301,12 @@ def sample_disable_processor(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1340,7 +1420,12 @@ def sample_review_document(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py index 5053fe61..31523d15 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py @@ -159,19 +159,29 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.list_processors: gapic_v1.method.wrap_method( - self.list_processors, default_timeout=None, client_info=client_info, + self.list_processors, + default_timeout=None, + client_info=client_info, ), self.create_processor: gapic_v1.method.wrap_method( - self.create_processor, default_timeout=None, client_info=client_info, + self.create_processor, + default_timeout=None, + client_info=client_info, ), self.delete_processor: gapic_v1.method.wrap_method( - self.delete_processor, default_timeout=None, client_info=client_info, + self.delete_processor, + default_timeout=None, + client_info=client_info, ), self.enable_processor: gapic_v1.method.wrap_method( - self.enable_processor, default_timeout=None, client_info=client_info, + self.enable_processor, + default_timeout=None, + client_info=client_info, ), self.disable_processor: gapic_v1.method.wrap_method( - self.disable_processor, default_timeout=None, client_info=client_info, + self.disable_processor, + default_timeout=None, + client_info=client_info, ), self.review_document: gapic_v1.method.wrap_method( self.review_document, @@ -193,9 +203,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py index a4ae4d3f..f11ad3dd 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py @@ -232,8 +232,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/documentai_v1beta3/types/document.py b/google/cloud/documentai_v1beta3/types/document.py index 27d7d341..a963ffb0 100644 --- a/google/cloud/documentai_v1beta3/types/document.py +++ b/google/cloud/documentai_v1beta3/types/document.py @@ -26,7 +26,10 @@ __protobuf__ = proto.module( - package="google.cloud.documentai.v1beta3", manifest={"Document",}, + package="google.cloud.documentai.v1beta3", + manifest={ + "Document", + }, ) @@ -115,9 +118,18 @@ class ShardInfo(proto.Message): in the overall document global text. """ - shard_index = proto.Field(proto.INT64, number=1,) - shard_count = proto.Field(proto.INT64, number=2,) - text_offset = proto.Field(proto.INT64, number=3,) + shard_index = proto.Field( + proto.INT64, + number=1, + ) + shard_count = proto.Field( + proto.INT64, + number=2, + ) + text_offset = proto.Field( + proto.INT64, + number=3, + ) class Style(proto.Message): r"""Annotation for common text style attributes. This adheres to @@ -155,21 +167,46 @@ class FontSize(proto.Message): (in, px, pt, etc.). """ - size = proto.Field(proto.FLOAT, number=1,) - unit = proto.Field(proto.STRING, number=2,) + size = proto.Field( + proto.FLOAT, + number=1, + ) + unit = proto.Field( + proto.STRING, + number=2, + ) text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + color = proto.Field( + proto.MESSAGE, + number=2, + message=color_pb2.Color, ) - color = proto.Field(proto.MESSAGE, number=2, message=color_pb2.Color,) background_color = proto.Field( - proto.MESSAGE, number=3, message=color_pb2.Color, + proto.MESSAGE, + number=3, + message=color_pb2.Color, + ) + font_weight = proto.Field( + proto.STRING, + number=4, + ) + text_style = proto.Field( + proto.STRING, + number=5, + ) + text_decoration = proto.Field( + proto.STRING, + number=6, ) - font_weight = proto.Field(proto.STRING, number=4,) - text_style = proto.Field(proto.STRING, number=5,) - text_decoration = proto.Field(proto.STRING, number=6,) font_size = proto.Field( - proto.MESSAGE, number=7, message="Document.Style.FontSize", + proto.MESSAGE, + number=7, + message="Document.Style.FontSize", ) class Page(proto.Message): @@ -244,9 +281,18 @@ class Dimension(proto.Message): Dimension unit. """ - width = proto.Field(proto.FLOAT, number=1,) - height = proto.Field(proto.FLOAT, number=2,) - unit = proto.Field(proto.STRING, number=3,) + width = proto.Field( + proto.FLOAT, + number=1, + ) + height = proto.Field( + proto.FLOAT, + number=2, + ) + unit = proto.Field( + proto.STRING, + number=3, + ) class Image(proto.Message): r"""Rendered image contents for this page. @@ -262,10 +308,22 @@ class Image(proto.Message): Height of the image in pixels. """ - content = proto.Field(proto.BYTES, number=1,) - mime_type = proto.Field(proto.STRING, number=2,) - width = proto.Field(proto.INT32, number=3,) - height = proto.Field(proto.INT32, number=4,) + content = proto.Field( + proto.BYTES, + number=1, + ) + mime_type = proto.Field( + proto.STRING, + number=2, + ) + width = proto.Field( + proto.INT32, + number=3, + ) + height = proto.Field( + proto.INT32, + number=4, + ) class Matrix(proto.Message): r"""Representation for transformation matrix, intended to be @@ -286,10 +344,22 @@ class Matrix(proto.Message): The matrix data. """ - rows = proto.Field(proto.INT32, number=1,) - cols = proto.Field(proto.INT32, number=2,) - type_ = proto.Field(proto.INT32, number=3,) - data = proto.Field(proto.BYTES, number=4,) + rows = proto.Field( + proto.INT32, + number=1, + ) + cols = proto.Field( + proto.INT32, + number=2, + ) + type_ = proto.Field( + proto.INT32, + number=3, + ) + data = proto.Field( + proto.BYTES, + number=4, + ) class Layout(proto.Message): r"""Visual element describing a layout unit on a page. @@ -321,14 +391,23 @@ class Orientation(proto.Enum): PAGE_LEFT = 4 text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + confidence = proto.Field( + proto.FLOAT, + number=2, ) - confidence = proto.Field(proto.FLOAT, number=2,) bounding_poly = proto.Field( - proto.MESSAGE, number=3, message=geometry.BoundingPoly, + proto.MESSAGE, + number=3, + message=geometry.BoundingPoly, ) orientation = proto.Field( - proto.ENUM, number=4, enum="Document.Page.Layout.Orientation", + proto.ENUM, + number=4, + enum="Document.Page.Layout.Orientation", ) class Block(proto.Message): @@ -348,13 +427,19 @@ class Block(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) provenance = proto.Field( - proto.MESSAGE, number=3, message="Document.Provenance", + proto.MESSAGE, + number=3, + message="Document.Provenance", ) class Paragraph(proto.Message): @@ -374,13 +459,19 @@ class Paragraph(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) provenance = proto.Field( - proto.MESSAGE, number=3, message="Document.Provenance", + proto.MESSAGE, + number=3, + message="Document.Provenance", ) class Line(proto.Message): @@ -401,13 +492,19 @@ class Line(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) provenance = proto.Field( - proto.MESSAGE, number=3, message="Document.Provenance", + proto.MESSAGE, + number=3, + message="Document.Provenance", ) class Token(proto.Message): @@ -445,20 +542,30 @@ class Type(proto.Enum): HYPHEN = 3 type_ = proto.Field( - proto.ENUM, number=1, enum="Document.Page.Token.DetectedBreak.Type", + proto.ENUM, + number=1, + enum="Document.Page.Token.DetectedBreak.Type", ) layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_break = proto.Field( - proto.MESSAGE, number=2, message="Document.Page.Token.DetectedBreak", + proto.MESSAGE, + number=2, + message="Document.Page.Token.DetectedBreak", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=3, + message="Document.Page.DetectedLanguage", ) provenance = proto.Field( - proto.MESSAGE, number=4, message="Document.Provenance", + proto.MESSAGE, + number=4, + message="Document.Provenance", ) class Symbol(proto.Message): @@ -475,10 +582,14 @@ class Symbol(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=2, + message="Document.Page.DetectedLanguage", ) class VisualElement(proto.Message): @@ -499,11 +610,18 @@ class VisualElement(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", + ) + type_ = proto.Field( + proto.STRING, + number=2, ) - type_ = proto.Field(proto.STRING, number=2,) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=3, + message="Document.Page.DetectedLanguage", ) class Table(proto.Message): @@ -532,7 +650,9 @@ class TableRow(proto.Message): """ cells = proto.RepeatedField( - proto.MESSAGE, number=1, message="Document.Page.Table.TableCell", + proto.MESSAGE, + number=1, + message="Document.Page.Table.TableCell", ) class TableCell(proto.Message): @@ -553,25 +673,43 @@ class TableCell(proto.Message): """ layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", + ) + row_span = proto.Field( + proto.INT32, + number=2, + ) + col_span = proto.Field( + proto.INT32, + number=3, ) - row_span = proto.Field(proto.INT32, number=2,) - col_span = proto.Field(proto.INT32, number=3,) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", ) layout = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) header_rows = proto.RepeatedField( - proto.MESSAGE, number=2, message="Document.Page.Table.TableRow", + proto.MESSAGE, + number=2, + message="Document.Page.Table.TableRow", ) body_rows = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.Table.TableRow", + proto.MESSAGE, + number=3, + message="Document.Page.Table.TableRow", ) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", ) class FormField(proto.Message): @@ -607,20 +745,33 @@ class FormField(proto.Message): """ field_name = proto.Field( - proto.MESSAGE, number=1, message="Document.Page.Layout", + proto.MESSAGE, + number=1, + message="Document.Page.Layout", ) field_value = proto.Field( - proto.MESSAGE, number=2, message="Document.Page.Layout", + proto.MESSAGE, + number=2, + message="Document.Page.Layout", ) name_detected_languages = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=3, + message="Document.Page.DetectedLanguage", ) value_detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", + ) + value_type = proto.Field( + proto.STRING, + number=5, ) - value_type = proto.Field(proto.STRING, number=5,) provenance = proto.Field( - proto.MESSAGE, number=8, message="Document.Provenance", + proto.MESSAGE, + number=8, + message="Document.Provenance", ) class DetectedLanguage(proto.Message): @@ -635,47 +786,88 @@ class DetectedLanguage(proto.Message): Confidence of detected language. Range [0, 1]. """ - language_code = proto.Field(proto.STRING, number=1,) - confidence = proto.Field(proto.FLOAT, number=2,) + language_code = proto.Field( + proto.STRING, + number=1, + ) + confidence = proto.Field( + proto.FLOAT, + number=2, + ) - page_number = proto.Field(proto.INT32, number=1,) - image = proto.Field(proto.MESSAGE, number=13, message="Document.Page.Image",) + page_number = proto.Field( + proto.INT32, + number=1, + ) + image = proto.Field( + proto.MESSAGE, + number=13, + message="Document.Page.Image", + ) transforms = proto.RepeatedField( - proto.MESSAGE, number=14, message="Document.Page.Matrix", + proto.MESSAGE, + number=14, + message="Document.Page.Matrix", ) dimension = proto.Field( - proto.MESSAGE, number=2, message="Document.Page.Dimension", + proto.MESSAGE, + number=2, + message="Document.Page.Dimension", + ) + layout = proto.Field( + proto.MESSAGE, + number=3, + message="Document.Page.Layout", ) - layout = proto.Field(proto.MESSAGE, number=3, message="Document.Page.Layout",) detected_languages = proto.RepeatedField( - proto.MESSAGE, number=4, message="Document.Page.DetectedLanguage", + proto.MESSAGE, + number=4, + message="Document.Page.DetectedLanguage", ) blocks = proto.RepeatedField( - proto.MESSAGE, number=5, message="Document.Page.Block", + proto.MESSAGE, + number=5, + message="Document.Page.Block", ) paragraphs = proto.RepeatedField( - proto.MESSAGE, number=6, message="Document.Page.Paragraph", + proto.MESSAGE, + number=6, + message="Document.Page.Paragraph", ) lines = proto.RepeatedField( - proto.MESSAGE, number=7, message="Document.Page.Line", + proto.MESSAGE, + number=7, + message="Document.Page.Line", ) tokens = proto.RepeatedField( - proto.MESSAGE, number=8, message="Document.Page.Token", + proto.MESSAGE, + number=8, + message="Document.Page.Token", ) visual_elements = proto.RepeatedField( - proto.MESSAGE, number=9, message="Document.Page.VisualElement", + proto.MESSAGE, + number=9, + message="Document.Page.VisualElement", ) tables = proto.RepeatedField( - proto.MESSAGE, number=10, message="Document.Page.Table", + proto.MESSAGE, + number=10, + message="Document.Page.Table", ) form_fields = proto.RepeatedField( - proto.MESSAGE, number=11, message="Document.Page.FormField", + proto.MESSAGE, + number=11, + message="Document.Page.FormField", ) symbols = proto.RepeatedField( - proto.MESSAGE, number=12, message="Document.Page.Symbol", + proto.MESSAGE, + number=12, + message="Document.Page.Symbol", ) provenance = proto.Field( - proto.MESSAGE, number=16, message="Document.Provenance", + proto.MESSAGE, + number=16, + message="Document.Provenance", ) class Entity(proto.Message): @@ -803,30 +995,65 @@ class NormalizedValue(proto.Message): oneof="structured_value", message=postal_address_pb2.PostalAddress, ) - boolean_value = proto.Field(proto.BOOL, number=6, oneof="structured_value",) - text = proto.Field(proto.STRING, number=1,) + boolean_value = proto.Field( + proto.BOOL, + number=6, + oneof="structured_value", + ) + text = proto.Field( + proto.STRING, + number=1, + ) text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + type_ = proto.Field( + proto.STRING, + number=2, + ) + mention_text = proto.Field( + proto.STRING, + number=3, + ) + mention_id = proto.Field( + proto.STRING, + number=4, + ) + confidence = proto.Field( + proto.FLOAT, + number=5, ) - type_ = proto.Field(proto.STRING, number=2,) - mention_text = proto.Field(proto.STRING, number=3,) - mention_id = proto.Field(proto.STRING, number=4,) - confidence = proto.Field(proto.FLOAT, number=5,) page_anchor = proto.Field( - proto.MESSAGE, number=6, message="Document.PageAnchor", + proto.MESSAGE, + number=6, + message="Document.PageAnchor", + ) + id = proto.Field( + proto.STRING, + number=7, ) - id = proto.Field(proto.STRING, number=7,) normalized_value = proto.Field( - proto.MESSAGE, number=9, message="Document.Entity.NormalizedValue", + proto.MESSAGE, + number=9, + message="Document.Entity.NormalizedValue", ) properties = proto.RepeatedField( - proto.MESSAGE, number=10, message="Document.Entity", + proto.MESSAGE, + number=10, + message="Document.Entity", ) provenance = proto.Field( - proto.MESSAGE, number=11, message="Document.Provenance", + proto.MESSAGE, + number=11, + message="Document.Provenance", + ) + redacted = proto.Field( + proto.BOOL, + number=12, ) - redacted = proto.Field(proto.BOOL, number=12,) class EntityRelation(proto.Message): r"""Relationship between @@ -841,9 +1068,18 @@ class EntityRelation(proto.Message): Relationship description. """ - subject_id = proto.Field(proto.STRING, number=1,) - object_id = proto.Field(proto.STRING, number=2,) - relation = proto.Field(proto.STRING, number=3,) + subject_id = proto.Field( + proto.STRING, + number=1, + ) + object_id = proto.Field( + proto.STRING, + number=2, + ) + relation = proto.Field( + proto.STRING, + number=3, + ) class TextAnchor(proto.Message): r"""Text reference indexing into the @@ -877,13 +1113,24 @@ class TextSegment(proto.Message): [Document.text][google.cloud.documentai.v1beta3.Document.text]. """ - start_index = proto.Field(proto.INT64, number=1,) - end_index = proto.Field(proto.INT64, number=2,) + start_index = proto.Field( + proto.INT64, + number=1, + ) + end_index = proto.Field( + proto.INT64, + number=2, + ) text_segments = proto.RepeatedField( - proto.MESSAGE, number=1, message="Document.TextAnchor.TextSegment", + proto.MESSAGE, + number=1, + message="Document.TextAnchor.TextSegment", + ) + content = proto.Field( + proto.STRING, + number=2, ) - content = proto.Field(proto.STRING, number=2,) class PageAnchor(proto.Message): r"""Referencing the visual context of the entity in the @@ -935,18 +1182,33 @@ class LayoutType(proto.Enum): TABLE = 6 FORM_FIELD = 7 - page = proto.Field(proto.INT64, number=1,) + page = proto.Field( + proto.INT64, + number=1, + ) layout_type = proto.Field( - proto.ENUM, number=2, enum="Document.PageAnchor.PageRef.LayoutType", + proto.ENUM, + number=2, + enum="Document.PageAnchor.PageRef.LayoutType", + ) + layout_id = proto.Field( + proto.STRING, + number=3, ) - layout_id = proto.Field(proto.STRING, number=3,) bounding_poly = proto.Field( - proto.MESSAGE, number=4, message=geometry.BoundingPoly, + proto.MESSAGE, + number=4, + message=geometry.BoundingPoly, + ) + confidence = proto.Field( + proto.FLOAT, + number=5, ) - confidence = proto.Field(proto.FLOAT, number=5,) page_refs = proto.RepeatedField( - proto.MESSAGE, number=1, message="Document.PageAnchor.PageRef", + proto.MESSAGE, + number=1, + message="Document.PageAnchor.PageRef", ) class Provenance(proto.Message): @@ -996,17 +1258,36 @@ class Parent(proto.Message): The id of the parent provenance. """ - revision = proto.Field(proto.INT32, number=1,) - index = proto.Field(proto.INT32, number=3,) - id = proto.Field(proto.INT32, number=2,) + revision = proto.Field( + proto.INT32, + number=1, + ) + index = proto.Field( + proto.INT32, + number=3, + ) + id = proto.Field( + proto.INT32, + number=2, + ) - revision = proto.Field(proto.INT32, number=1,) - id = proto.Field(proto.INT32, number=2,) + revision = proto.Field( + proto.INT32, + number=1, + ) + id = proto.Field( + proto.INT32, + number=2, + ) parents = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Provenance.Parent", + proto.MESSAGE, + number=3, + message="Document.Provenance.Parent", ) type_ = proto.Field( - proto.ENUM, number=4, enum="Document.Provenance.OperationType", + proto.ENUM, + number=4, + enum="Document.Provenance.OperationType", ) class Revision(proto.Message): @@ -1056,18 +1337,42 @@ class HumanReview(proto.Message): is ``rejected``. """ - state = proto.Field(proto.STRING, number=1,) - state_message = proto.Field(proto.STRING, number=2,) + state = proto.Field( + proto.STRING, + number=1, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) - agent = proto.Field(proto.STRING, number=4, oneof="source",) - processor = proto.Field(proto.STRING, number=5, oneof="source",) - id = proto.Field(proto.STRING, number=1,) - parent = proto.RepeatedField(proto.INT32, number=2,) + agent = proto.Field( + proto.STRING, + number=4, + oneof="source", + ) + processor = proto.Field( + proto.STRING, + number=5, + oneof="source", + ) + id = proto.Field( + proto.STRING, + number=1, + ) + parent = proto.RepeatedField( + proto.INT32, + number=2, + ) create_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, ) human_review = proto.Field( - proto.MESSAGE, number=6, message="Document.Revision.HumanReview", + proto.MESSAGE, + number=6, + message="Document.Revision.HumanReview", ) class TextChange(proto.Message): @@ -1088,27 +1393,78 @@ class TextChange(proto.Message): """ text_anchor = proto.Field( - proto.MESSAGE, number=1, message="Document.TextAnchor", + proto.MESSAGE, + number=1, + message="Document.TextAnchor", + ) + changed_text = proto.Field( + proto.STRING, + number=2, ) - changed_text = proto.Field(proto.STRING, number=2,) provenance = proto.RepeatedField( - proto.MESSAGE, number=3, message="Document.Provenance", + proto.MESSAGE, + number=3, + message="Document.Provenance", ) - uri = proto.Field(proto.STRING, number=1, oneof="source",) - content = proto.Field(proto.BYTES, number=2, oneof="source",) - mime_type = proto.Field(proto.STRING, number=3,) - text = proto.Field(proto.STRING, number=4,) - text_styles = proto.RepeatedField(proto.MESSAGE, number=5, message=Style,) - pages = proto.RepeatedField(proto.MESSAGE, number=6, message=Page,) - entities = proto.RepeatedField(proto.MESSAGE, number=7, message=Entity,) + uri = proto.Field( + proto.STRING, + number=1, + oneof="source", + ) + content = proto.Field( + proto.BYTES, + number=2, + oneof="source", + ) + mime_type = proto.Field( + proto.STRING, + number=3, + ) + text = proto.Field( + proto.STRING, + number=4, + ) + text_styles = proto.RepeatedField( + proto.MESSAGE, + number=5, + message=Style, + ) + pages = proto.RepeatedField( + proto.MESSAGE, + number=6, + message=Page, + ) + entities = proto.RepeatedField( + proto.MESSAGE, + number=7, + message=Entity, + ) entity_relations = proto.RepeatedField( - proto.MESSAGE, number=8, message=EntityRelation, + proto.MESSAGE, + number=8, + message=EntityRelation, + ) + text_changes = proto.RepeatedField( + proto.MESSAGE, + number=14, + message=TextChange, + ) + shard_info = proto.Field( + proto.MESSAGE, + number=9, + message=ShardInfo, + ) + error = proto.Field( + proto.MESSAGE, + number=10, + message=status_pb2.Status, + ) + revisions = proto.RepeatedField( + proto.MESSAGE, + number=13, + message=Revision, ) - text_changes = proto.RepeatedField(proto.MESSAGE, number=14, message=TextChange,) - shard_info = proto.Field(proto.MESSAGE, number=9, message=ShardInfo,) - error = proto.Field(proto.MESSAGE, number=10, message=status_pb2.Status,) - revisions = proto.RepeatedField(proto.MESSAGE, number=13, message=Revision,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1beta3/types/document_io.py b/google/cloud/documentai_v1beta3/types/document_io.py index 3bc1ec68..cec64bbe 100644 --- a/google/cloud/documentai_v1beta3/types/document_io.py +++ b/google/cloud/documentai_v1beta3/types/document_io.py @@ -40,8 +40,14 @@ class RawDocument(proto.Message): of the [content]. """ - content = proto.Field(proto.BYTES, number=1,) - mime_type = proto.Field(proto.STRING, number=2,) + content = proto.Field( + proto.BYTES, + number=1, + ) + mime_type = proto.Field( + proto.STRING, + number=2, + ) class GcsDocument(proto.Message): @@ -54,8 +60,14 @@ class GcsDocument(proto.Message): An IANA MIME type (RFC6838) of the content. """ - gcs_uri = proto.Field(proto.STRING, number=1,) - mime_type = proto.Field(proto.STRING, number=2,) + gcs_uri = proto.Field( + proto.STRING, + number=1, + ) + mime_type = proto.Field( + proto.STRING, + number=2, + ) class GcsDocuments(proto.Message): @@ -66,7 +78,11 @@ class GcsDocuments(proto.Message): The list of documents. """ - documents = proto.RepeatedField(proto.MESSAGE, number=1, message="GcsDocument",) + documents = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="GcsDocument", + ) class GcsPrefix(proto.Message): @@ -78,7 +94,10 @@ class GcsPrefix(proto.Message): The URI prefix. """ - gcs_uri_prefix = proto.Field(proto.STRING, number=1,) + gcs_uri_prefix = proto.Field( + proto.STRING, + number=1, + ) class BatchDocumentsInputConfig(proto.Message): @@ -106,10 +125,16 @@ class BatchDocumentsInputConfig(proto.Message): """ gcs_prefix = proto.Field( - proto.MESSAGE, number=1, oneof="source", message="GcsPrefix", + proto.MESSAGE, + number=1, + oneof="source", + message="GcsPrefix", ) gcs_documents = proto.Field( - proto.MESSAGE, number=2, oneof="source", message="GcsDocuments", + proto.MESSAGE, + number=2, + oneof="source", + message="GcsDocuments", ) @@ -137,10 +162,16 @@ class GcsOutputConfig(proto.Message): output. """ - gcs_uri = proto.Field(proto.STRING, number=1,) + gcs_uri = proto.Field( + proto.STRING, + number=1, + ) gcs_output_config = proto.Field( - proto.MESSAGE, number=1, oneof="destination", message=GcsOutputConfig, + proto.MESSAGE, + number=1, + oneof="destination", + message=GcsOutputConfig, ) diff --git a/google/cloud/documentai_v1beta3/types/document_processor_service.py b/google/cloud/documentai_v1beta3/types/document_processor_service.py index 668e718f..67e2c41d 100644 --- a/google/cloud/documentai_v1beta3/types/document_processor_service.py +++ b/google/cloud/documentai_v1beta3/types/document_processor_service.py @@ -83,14 +83,30 @@ class ProcessRequest(proto.Message): """ inline_document = proto.Field( - proto.MESSAGE, number=4, oneof="source", message=gcd_document.Document, + proto.MESSAGE, + number=4, + oneof="source", + message=gcd_document.Document, ) raw_document = proto.Field( - proto.MESSAGE, number=5, oneof="source", message=document_io.RawDocument, + proto.MESSAGE, + number=5, + oneof="source", + message=document_io.RawDocument, + ) + name = proto.Field( + proto.STRING, + number=1, + ) + document = proto.Field( + proto.MESSAGE, + number=2, + message=gcd_document.Document, + ) + skip_human_review = proto.Field( + proto.BOOL, + number=3, ) - name = proto.Field(proto.STRING, number=1,) - document = proto.Field(proto.MESSAGE, number=2, message=gcd_document.Document,) - skip_human_review = proto.Field(proto.BOOL, number=3,) class HumanReviewStatus(proto.Message): @@ -119,9 +135,19 @@ class State(proto.Enum): IN_PROGRESS = 3 ERROR = 4 - state = proto.Field(proto.ENUM, number=1, enum=State,) - state_message = proto.Field(proto.STRING, number=2,) - human_review_operation = proto.Field(proto.STRING, number=3,) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) + human_review_operation = proto.Field( + proto.STRING, + number=3, + ) class ProcessResponse(proto.Message): @@ -143,10 +169,19 @@ class ProcessResponse(proto.Message): document. """ - document = proto.Field(proto.MESSAGE, number=1, message=gcd_document.Document,) - human_review_operation = proto.Field(proto.STRING, number=2,) + document = proto.Field( + proto.MESSAGE, + number=1, + message=gcd_document.Document, + ) + human_review_operation = proto.Field( + proto.STRING, + number=2, + ) human_review_status = proto.Field( - proto.MESSAGE, number=3, message="HumanReviewStatus", + proto.MESSAGE, + number=3, + message="HumanReviewStatus", ) @@ -184,8 +219,14 @@ class BatchInputConfig(proto.Message): should be application/json. """ - gcs_source = proto.Field(proto.STRING, number=1,) - mime_type = proto.Field(proto.STRING, number=2,) + gcs_source = proto.Field( + proto.STRING, + number=1, + ) + mime_type = proto.Field( + proto.STRING, + number=2, + ) class BatchOutputConfig(proto.Message): r"""The message for output config in batch process. @@ -196,25 +237,43 @@ class BatchOutputConfig(proto.Message): processed documents. """ - gcs_destination = proto.Field(proto.STRING, number=1,) + gcs_destination = proto.Field( + proto.STRING, + number=1, + ) - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) input_configs = proto.RepeatedField( - proto.MESSAGE, number=2, message=BatchInputConfig, + proto.MESSAGE, + number=2, + message=BatchInputConfig, + ) + output_config = proto.Field( + proto.MESSAGE, + number=3, + message=BatchOutputConfig, ) - output_config = proto.Field(proto.MESSAGE, number=3, message=BatchOutputConfig,) input_documents = proto.Field( - proto.MESSAGE, number=5, message=document_io.BatchDocumentsInputConfig, + proto.MESSAGE, + number=5, + message=document_io.BatchDocumentsInputConfig, ) document_output_config = proto.Field( - proto.MESSAGE, number=6, message=document_io.DocumentOutputConfig, + proto.MESSAGE, + number=6, + message=document_io.DocumentOutputConfig, + ) + skip_human_review = proto.Field( + proto.BOOL, + number=4, ) - skip_human_review = proto.Field(proto.BOOL, number=4,) class BatchProcessResponse(proto.Message): - r"""Response message for batch process document method. - """ + r"""Response message for batch process document method.""" class BatchProcessMetadata(proto.Message): @@ -275,20 +334,52 @@ class IndividualProcessStatus(proto.Message): document. """ - input_gcs_source = proto.Field(proto.STRING, number=1,) - status = proto.Field(proto.MESSAGE, number=2, message=status_pb2.Status,) - output_gcs_destination = proto.Field(proto.STRING, number=3,) - human_review_operation = proto.Field(proto.STRING, number=4,) + input_gcs_source = proto.Field( + proto.STRING, + number=1, + ) + status = proto.Field( + proto.MESSAGE, + number=2, + message=status_pb2.Status, + ) + output_gcs_destination = proto.Field( + proto.STRING, + number=3, + ) + human_review_operation = proto.Field( + proto.STRING, + number=4, + ) human_review_status = proto.Field( - proto.MESSAGE, number=5, message="HumanReviewStatus", + proto.MESSAGE, + number=5, + message="HumanReviewStatus", ) - state = proto.Field(proto.ENUM, number=1, enum=State,) - state_message = proto.Field(proto.STRING, number=2,) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) individual_process_statuses = proto.RepeatedField( - proto.MESSAGE, number=5, message=IndividualProcessStatus, + proto.MESSAGE, + number=5, + message=IndividualProcessStatus, ) @@ -302,7 +393,10 @@ class FetchProcessorTypesRequest(proto.Message): projects/{project}/locations/{location} """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) class FetchProcessorTypesResponse(proto.Message): @@ -314,7 +408,9 @@ class FetchProcessorTypesResponse(proto.Message): """ processor_types = proto.RepeatedField( - proto.MESSAGE, number=1, message=processor_type.ProcessorType, + proto.MESSAGE, + number=1, + message=processor_type.ProcessorType, ) @@ -337,9 +433,18 @@ class ListProcessorsRequest(proto.Message): next processor. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListProcessorsResponse(proto.Message): @@ -358,9 +463,14 @@ def raw_page(self): return self processors = proto.RepeatedField( - proto.MESSAGE, number=1, message=gcd_processor.Processor, + proto.MESSAGE, + number=1, + message=gcd_processor.Processor, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class CreateProcessorRequest(proto.Message): @@ -379,8 +489,15 @@ class CreateProcessorRequest(proto.Message): processor is under CMEK if CMEK fields are set. """ - parent = proto.Field(proto.STRING, number=1,) - processor = proto.Field(proto.MESSAGE, number=2, message=gcd_processor.Processor,) + parent = proto.Field( + proto.STRING, + number=1, + ) + processor = proto.Field( + proto.MESSAGE, + number=2, + message=gcd_processor.Processor, + ) class DeleteProcessorRequest(proto.Message): @@ -392,7 +509,10 @@ class DeleteProcessorRequest(proto.Message): deleted. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class DeleteProcessorMetadata(proto.Message): @@ -406,7 +526,9 @@ class DeleteProcessorMetadata(proto.Message): """ common_metadata = proto.Field( - proto.MESSAGE, number=5, message=operation_metadata.CommonOperationMetadata, + proto.MESSAGE, + number=5, + message=operation_metadata.CommonOperationMetadata, ) @@ -419,12 +541,14 @@ class EnableProcessorRequest(proto.Message): enabled. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class EnableProcessorResponse(proto.Message): - r"""Response message for the enable processor method. - """ + r"""Response message for the enable processor method.""" class EnableProcessorMetadata(proto.Message): @@ -438,7 +562,9 @@ class EnableProcessorMetadata(proto.Message): """ common_metadata = proto.Field( - proto.MESSAGE, number=5, message=operation_metadata.CommonOperationMetadata, + proto.MESSAGE, + number=5, + message=operation_metadata.CommonOperationMetadata, ) @@ -451,12 +577,14 @@ class DisableProcessorRequest(proto.Message): disabled. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class DisableProcessorResponse(proto.Message): - r"""Response message for the disable processor method. - """ + r"""Response message for the disable processor method.""" class DisableProcessorMetadata(proto.Message): @@ -470,7 +598,9 @@ class DisableProcessorMetadata(proto.Message): """ common_metadata = proto.Field( - proto.MESSAGE, number=5, message=operation_metadata.CommonOperationMetadata, + proto.MESSAGE, + number=5, + message=operation_metadata.CommonOperationMetadata, ) @@ -505,12 +635,29 @@ class Priority(proto.Enum): URGENT = 1 inline_document = proto.Field( - proto.MESSAGE, number=4, oneof="source", message=gcd_document.Document, + proto.MESSAGE, + number=4, + oneof="source", + message=gcd_document.Document, + ) + human_review_config = proto.Field( + proto.STRING, + number=1, + ) + document = proto.Field( + proto.MESSAGE, + number=2, + message=gcd_document.Document, + ) + enable_schema_validation = proto.Field( + proto.BOOL, + number=3, + ) + priority = proto.Field( + proto.ENUM, + number=5, + enum=Priority, ) - human_review_config = proto.Field(proto.STRING, number=1,) - document = proto.Field(proto.MESSAGE, number=2, message=gcd_document.Document,) - enable_schema_validation = proto.Field(proto.BOOL, number=3,) - priority = proto.Field(proto.ENUM, number=5, enum=Priority,) class ReviewDocumentResponse(proto.Message): @@ -522,7 +669,10 @@ class ReviewDocumentResponse(proto.Message): document. """ - gcs_destination = proto.Field(proto.STRING, number=1,) + gcs_destination = proto.Field( + proto.STRING, + number=1, + ) class ReviewDocumentOperationMetadata(proto.Message): @@ -556,14 +706,34 @@ class State(proto.Enum): FAILED = 4 CANCELLED = 5 - state = proto.Field(proto.ENUM, number=1, enum=State,) - state_message = proto.Field(proto.STRING, number=2,) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) common_metadata = proto.Field( - proto.MESSAGE, number=5, message=operation_metadata.CommonOperationMetadata, + proto.MESSAGE, + number=5, + message=operation_metadata.CommonOperationMetadata, + ) + question_id = proto.Field( + proto.STRING, + number=6, ) - question_id = proto.Field(proto.STRING, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1beta3/types/geometry.py b/google/cloud/documentai_v1beta3/types/geometry.py index e1a103b5..c0d94568 100644 --- a/google/cloud/documentai_v1beta3/types/geometry.py +++ b/google/cloud/documentai_v1beta3/types/geometry.py @@ -18,7 +18,11 @@ __protobuf__ = proto.module( package="google.cloud.documentai.v1beta3", - manifest={"Vertex", "NormalizedVertex", "BoundingPoly",}, + manifest={ + "Vertex", + "NormalizedVertex", + "BoundingPoly", + }, ) @@ -35,8 +39,14 @@ class Vertex(proto.Message): image). """ - x = proto.Field(proto.INT32, number=1,) - y = proto.Field(proto.INT32, number=2,) + x = proto.Field( + proto.INT32, + number=1, + ) + y = proto.Field( + proto.INT32, + number=2, + ) class NormalizedVertex(proto.Message): @@ -52,8 +62,14 @@ class NormalizedVertex(proto.Message): image). """ - x = proto.Field(proto.FLOAT, number=1,) - y = proto.Field(proto.FLOAT, number=2,) + x = proto.Field( + proto.FLOAT, + number=1, + ) + y = proto.Field( + proto.FLOAT, + number=2, + ) class BoundingPoly(proto.Message): @@ -66,9 +82,15 @@ class BoundingPoly(proto.Message): The bounding polygon normalized vertices. """ - vertices = proto.RepeatedField(proto.MESSAGE, number=1, message="Vertex",) + vertices = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Vertex", + ) normalized_vertices = proto.RepeatedField( - proto.MESSAGE, number=2, message="NormalizedVertex", + proto.MESSAGE, + number=2, + message="NormalizedVertex", ) diff --git a/google/cloud/documentai_v1beta3/types/operation_metadata.py b/google/cloud/documentai_v1beta3/types/operation_metadata.py index a4e57051..fdd32619 100644 --- a/google/cloud/documentai_v1beta3/types/operation_metadata.py +++ b/google/cloud/documentai_v1beta3/types/operation_metadata.py @@ -19,7 +19,10 @@ __protobuf__ = proto.module( - package="google.cloud.documentai.v1beta3", manifest={"CommonOperationMetadata",}, + package="google.cloud.documentai.v1beta3", + manifest={ + "CommonOperationMetadata", + }, ) @@ -47,10 +50,25 @@ class State(proto.Enum): FAILED = 4 CANCELLED = 5 - state = proto.Field(proto.ENUM, number=1, enum=State,) - state_message = proto.Field(proto.STRING, number=2,) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + state_message = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1beta3/types/processor.py b/google/cloud/documentai_v1beta3/types/processor.py index dc0dc83b..ad801491 100644 --- a/google/cloud/documentai_v1beta3/types/processor.py +++ b/google/cloud/documentai_v1beta3/types/processor.py @@ -19,7 +19,10 @@ __protobuf__ = proto.module( - package="google.cloud.documentai.v1beta3", manifest={"Processor",}, + package="google.cloud.documentai.v1beta3", + manifest={ + "Processor", + }, ) @@ -62,14 +65,40 @@ class State(proto.Enum): FAILED = 6 DELETING = 7 - name = proto.Field(proto.STRING, number=1,) - type_ = proto.Field(proto.STRING, number=2,) - display_name = proto.Field(proto.STRING, number=3,) - state = proto.Field(proto.ENUM, number=4, enum=State,) - default_processor_version = proto.Field(proto.STRING, number=9,) - process_endpoint = proto.Field(proto.STRING, number=6,) - create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) - kms_key_name = proto.Field(proto.STRING, number=8,) + name = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.STRING, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) + state = proto.Field( + proto.ENUM, + number=4, + enum=State, + ) + default_processor_version = proto.Field( + proto.STRING, + number=9, + ) + process_endpoint = proto.Field( + proto.STRING, + number=6, + ) + create_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + kms_key_name = proto.Field( + proto.STRING, + number=8, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/documentai_v1beta3/types/processor_type.py b/google/cloud/documentai_v1beta3/types/processor_type.py index 5161782c..8df603a3 100644 --- a/google/cloud/documentai_v1beta3/types/processor_type.py +++ b/google/cloud/documentai_v1beta3/types/processor_type.py @@ -17,7 +17,10 @@ __protobuf__ = proto.module( - package="google.cloud.documentai.v1beta3", manifest={"ProcessorType",}, + package="google.cloud.documentai.v1beta3", + manifest={ + "ProcessorType", + }, ) @@ -51,15 +54,32 @@ class LocationInfo(proto.Message): The location id. """ - location_id = proto.Field(proto.STRING, number=1,) + location_id = proto.Field( + proto.STRING, + number=1, + ) - name = proto.Field(proto.STRING, number=1,) - type_ = proto.Field(proto.STRING, number=2,) - category = proto.Field(proto.STRING, number=3,) + name = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.STRING, + number=2, + ) + category = proto.Field( + proto.STRING, + number=3, + ) available_locations = proto.RepeatedField( - proto.MESSAGE, number=4, message=LocationInfo, + proto.MESSAGE, + number=4, + message=LocationInfo, + ) + allow_creation = proto.Field( + proto.BOOL, + number=6, ) - allow_creation = proto.Field(proto.BOOL, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c4..3addb4ed 100644 --- a/noxfile.py +++ b/noxfile.py @@ -24,7 +24,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -57,7 +57,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +69,8 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) diff --git a/samples/snippets/batch_process_documents_sample.py b/samples/snippets/batch_process_documents_sample.py index d85948e7..88217093 100644 --- a/samples/snippets/batch_process_documents_sample.py +++ b/samples/snippets/batch_process_documents_sample.py @@ -63,7 +63,9 @@ def batch_process_documents( # Location can be 'us' or 'eu' name = f"projects/{project_id}/locations/{location}/processors/{processor_id}" request = documentai.types.document_processor_service.BatchProcessRequest( - name=name, input_documents=input_config, document_output_config=output_config, + name=name, + input_documents=input_config, + document_output_config=output_config, ) operation = client.batch_process_documents(request) diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 85f5836d..25f87a21 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10): diff --git a/samples/snippets/process_document_splitter_sample.py b/samples/snippets/process_document_splitter_sample.py index 95607854..f80c7b4e 100644 --- a/samples/snippets/process_document_splitter_sample.py +++ b/samples/snippets/process_document_splitter_sample.py @@ -75,7 +75,7 @@ def process_document_splitter_sample( def page_refs_to_string(page_refs: dict) -> str: - """ Converts a page ref to a string describing the page or page range.""" + """Converts a page ref to a string describing the page or page range.""" if len(page_refs) == 1: num = str(int(page_refs[0].page) + 1) return f"page {num} is" diff --git a/tests/unit/gapic/documentai_v1/test_document_processor_service.py b/tests/unit/gapic/documentai_v1/test_document_processor_service.py index f2674284..f462a23e 100644 --- a/tests/unit/gapic/documentai_v1/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1/test_document_processor_service.py @@ -108,7 +108,10 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( "client_class", - [DocumentProcessorServiceClient, DocumentProcessorServiceAsyncClient,], + [ + DocumentProcessorServiceClient, + DocumentProcessorServiceAsyncClient, + ], ) def test_document_processor_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -151,7 +154,10 @@ def test_document_processor_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( "client_class", - [DocumentProcessorServiceClient, DocumentProcessorServiceAsyncClient,], + [ + DocumentProcessorServiceClient, + DocumentProcessorServiceAsyncClient, + ], ) def test_document_processor_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -540,7 +546,9 @@ def test_document_processor_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -681,11 +689,16 @@ def test_document_processor_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [document_processor_service.ProcessRequest, dict,] + "request_type", + [ + document_processor_service.ProcessRequest, + dict, + ], ) def test_process_document(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -711,7 +724,8 @@ def test_process_document_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -728,7 +742,8 @@ async def test_process_document_async( request_type=document_processor_service.ProcessRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -780,7 +795,10 @@ def test_process_document_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -809,7 +827,10 @@ async def test_process_document_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_process_document_flattened(): @@ -823,7 +844,9 @@ def test_process_document_flattened(): call.return_value = document_processor_service.ProcessResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.process_document(name="name_value",) + client.process_document( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -843,7 +866,8 @@ def test_process_document_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.process_document( - document_processor_service.ProcessRequest(), name="name_value", + document_processor_service.ProcessRequest(), + name="name_value", ) @@ -863,7 +887,9 @@ async def test_process_document_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.process_document(name="name_value",) + response = await client.process_document( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -884,16 +910,22 @@ async def test_process_document_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.process_document( - document_processor_service.ProcessRequest(), name="name_value", + document_processor_service.ProcessRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [document_processor_service.BatchProcessRequest, dict,] + "request_type", + [ + document_processor_service.BatchProcessRequest, + dict, + ], ) def test_batch_process_documents(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -921,7 +953,8 @@ def test_batch_process_documents_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -940,7 +973,8 @@ async def test_batch_process_documents_async( request_type=document_processor_service.BatchProcessRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -996,7 +1030,10 @@ def test_batch_process_documents_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1027,7 +1064,10 @@ async def test_batch_process_documents_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_batch_process_documents_flattened(): @@ -1043,7 +1083,9 @@ def test_batch_process_documents_flattened(): call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.batch_process_documents(name="name_value",) + client.batch_process_documents( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1063,7 +1105,8 @@ def test_batch_process_documents_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.batch_process_documents( - document_processor_service.BatchProcessRequest(), name="name_value", + document_processor_service.BatchProcessRequest(), + name="name_value", ) @@ -1085,7 +1128,9 @@ async def test_batch_process_documents_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.batch_process_documents(name="name_value",) + response = await client.batch_process_documents( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1106,16 +1151,22 @@ async def test_batch_process_documents_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.batch_process_documents( - document_processor_service.BatchProcessRequest(), name="name_value", + document_processor_service.BatchProcessRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [document_processor_service.ReviewDocumentRequest, dict,] + "request_type", + [ + document_processor_service.ReviewDocumentRequest, + dict, + ], ) def test_review_document(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1141,7 +1192,8 @@ def test_review_document_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1158,7 +1210,8 @@ async def test_review_document_async( request_type=document_processor_service.ReviewDocumentRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1259,7 +1312,9 @@ def test_review_document_flattened(): call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.review_document(human_review_config="human_review_config_value",) + client.review_document( + human_review_config="human_review_config_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1335,7 +1390,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1356,7 +1412,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = DocumentProcessorServiceClient( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -1373,7 +1430,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DocumentProcessorServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1422,7 +1480,8 @@ def test_transport_grpc_default(): credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( - client.transport, transports.DocumentProcessorServiceGrpcTransport, + client.transport, + transports.DocumentProcessorServiceGrpcTransport, ) @@ -1475,7 +1534,8 @@ def test_document_processor_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DocumentProcessorServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1637,7 +1697,8 @@ def test_document_processor_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.DocumentProcessorServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1649,7 +1710,8 @@ def test_document_processor_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.DocumentProcessorServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1758,12 +1820,16 @@ def test_document_processor_service_transport_channel_mtls_with_adc(transport_cl def test_document_processor_service_grpc_lro_client(): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -1771,12 +1837,16 @@ def test_document_processor_service_grpc_lro_client(): def test_document_processor_service_grpc_lro_async_client(): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -1787,7 +1857,9 @@ def test_human_review_config_path(): location = "clam" processor = "whelk" expected = "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig".format( - project=project, location=location, processor=processor, + project=project, + location=location, + processor=processor, ) actual = DocumentProcessorServiceClient.human_review_config_path( project, location, processor @@ -1813,7 +1885,9 @@ def test_processor_path(): location = "mussel" processor = "winkle" expected = "projects/{project}/locations/{location}/processors/{processor}".format( - project=project, location=location, processor=processor, + project=project, + location=location, + processor=processor, ) actual = DocumentProcessorServiceClient.processor_path(project, location, processor) assert expected == actual @@ -1854,7 +1928,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = DocumentProcessorServiceClient.common_folder_path(folder) assert expected == actual @@ -1872,7 +1948,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = DocumentProcessorServiceClient.common_organization_path(organization) assert expected == actual @@ -1890,7 +1968,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = DocumentProcessorServiceClient.common_project_path(project) assert expected == actual @@ -1910,7 +1990,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = DocumentProcessorServiceClient.common_location_path(project, location) assert expected == actual @@ -1935,7 +2016,8 @@ def test_client_with_default_client_info(): transports.DocumentProcessorServiceTransport, "_prep_wrapped_messages" ) as prep: client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1944,7 +2026,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = DocumentProcessorServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1952,7 +2035,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py index 8f31ff05..6b3e2775 100644 --- a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py +++ b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py @@ -102,7 +102,10 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( "client_class", - [DocumentUnderstandingServiceClient, DocumentUnderstandingServiceAsyncClient,], + [ + DocumentUnderstandingServiceClient, + DocumentUnderstandingServiceAsyncClient, + ], ) def test_document_understanding_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -145,7 +148,10 @@ def test_document_understanding_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( "client_class", - [DocumentUnderstandingServiceClient, DocumentUnderstandingServiceAsyncClient,], + [ + DocumentUnderstandingServiceClient, + DocumentUnderstandingServiceAsyncClient, + ], ) def test_document_understanding_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -534,7 +540,9 @@ def test_document_understanding_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -675,11 +683,16 @@ def test_document_understanding_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [document_understanding.BatchProcessDocumentsRequest, dict,] + "request_type", + [ + document_understanding.BatchProcessDocumentsRequest, + dict, + ], ) def test_batch_process_documents(request_type, transport: str = "grpc"): client = DocumentUnderstandingServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -707,7 +720,8 @@ def test_batch_process_documents_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentUnderstandingServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -726,7 +740,8 @@ async def test_batch_process_documents_async( request_type=document_understanding.BatchProcessDocumentsRequest, ): client = DocumentUnderstandingServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -782,7 +797,10 @@ def test_batch_process_documents_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -813,7 +831,10 @@ async def test_batch_process_documents_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_batch_process_documents_flattened(): @@ -915,11 +936,16 @@ async def test_batch_process_documents_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [document_understanding.ProcessDocumentRequest, dict,] + "request_type", + [ + document_understanding.ProcessDocumentRequest, + dict, + ], ) def test_process_document(request_type, transport: str = "grpc"): client = DocumentUnderstandingServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -930,7 +956,9 @@ def test_process_document(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.process_document), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = document.Document( - mime_type="mime_type_value", text="text_value", uri="uri_value", + mime_type="mime_type_value", + text="text_value", + uri="uri_value", ) response = client.process_document(request) @@ -949,7 +977,8 @@ def test_process_document_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentUnderstandingServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -966,7 +995,8 @@ async def test_process_document_async( request_type=document_understanding.ProcessDocumentRequest, ): client = DocumentUnderstandingServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -977,7 +1007,10 @@ async def test_process_document_async( with mock.patch.object(type(client.transport.process_document), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - document.Document(mime_type="mime_type_value", text="text_value",) + document.Document( + mime_type="mime_type_value", + text="text_value", + ) ) response = await client.process_document(request) @@ -1020,7 +1053,10 @@ def test_process_document_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1047,7 +1083,10 @@ async def test_process_document_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -1057,7 +1096,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DocumentUnderstandingServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1078,7 +1118,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = DocumentUnderstandingServiceClient( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -1095,7 +1136,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DocumentUnderstandingServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1144,7 +1186,8 @@ def test_transport_grpc_default(): credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( - client.transport, transports.DocumentUnderstandingServiceGrpcTransport, + client.transport, + transports.DocumentUnderstandingServiceGrpcTransport, ) @@ -1196,7 +1239,8 @@ def test_document_understanding_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DocumentUnderstandingServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1361,7 +1405,8 @@ def test_document_understanding_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.DocumentUnderstandingServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1373,7 +1418,8 @@ def test_document_understanding_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.DocumentUnderstandingServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1484,12 +1530,16 @@ def test_document_understanding_service_transport_channel_mtls_with_adc( def test_document_understanding_service_grpc_lro_client(): client = DocumentUnderstandingServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -1497,12 +1547,16 @@ def test_document_understanding_service_grpc_lro_client(): def test_document_understanding_service_grpc_lro_async_client(): client = DocumentUnderstandingServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -1532,7 +1586,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = DocumentUnderstandingServiceClient.common_folder_path(folder) assert expected == actual @@ -1550,7 +1606,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = DocumentUnderstandingServiceClient.common_organization_path(organization) assert expected == actual @@ -1568,7 +1626,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = DocumentUnderstandingServiceClient.common_project_path(project) assert expected == actual @@ -1588,7 +1648,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = DocumentUnderstandingServiceClient.common_location_path(project, location) assert expected == actual @@ -1613,7 +1674,8 @@ def test_client_with_default_client_info(): transports.DocumentUnderstandingServiceTransport, "_prep_wrapped_messages" ) as prep: client = DocumentUnderstandingServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1622,7 +1684,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = DocumentUnderstandingServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1630,7 +1693,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = DocumentUnderstandingServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py index 39bcd6a2..e996223b 100644 --- a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py @@ -114,7 +114,10 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( "client_class", - [DocumentProcessorServiceClient, DocumentProcessorServiceAsyncClient,], + [ + DocumentProcessorServiceClient, + DocumentProcessorServiceAsyncClient, + ], ) def test_document_processor_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -157,7 +160,10 @@ def test_document_processor_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( "client_class", - [DocumentProcessorServiceClient, DocumentProcessorServiceAsyncClient,], + [ + DocumentProcessorServiceClient, + DocumentProcessorServiceAsyncClient, + ], ) def test_document_processor_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -546,7 +552,9 @@ def test_document_processor_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -687,11 +695,16 @@ def test_document_processor_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [document_processor_service.ProcessRequest, dict,] + "request_type", + [ + document_processor_service.ProcessRequest, + dict, + ], ) def test_process_document(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -720,7 +733,8 @@ def test_process_document_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -737,7 +751,8 @@ async def test_process_document_async( request_type=document_processor_service.ProcessRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -792,7 +807,10 @@ def test_process_document_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -821,7 +839,10 @@ async def test_process_document_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_process_document_flattened(): @@ -835,7 +856,9 @@ def test_process_document_flattened(): call.return_value = document_processor_service.ProcessResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.process_document(name="name_value",) + client.process_document( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -855,7 +878,8 @@ def test_process_document_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.process_document( - document_processor_service.ProcessRequest(), name="name_value", + document_processor_service.ProcessRequest(), + name="name_value", ) @@ -875,7 +899,9 @@ async def test_process_document_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.process_document(name="name_value",) + response = await client.process_document( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -896,16 +922,22 @@ async def test_process_document_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.process_document( - document_processor_service.ProcessRequest(), name="name_value", + document_processor_service.ProcessRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [document_processor_service.BatchProcessRequest, dict,] + "request_type", + [ + document_processor_service.BatchProcessRequest, + dict, + ], ) def test_batch_process_documents(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -933,7 +965,8 @@ def test_batch_process_documents_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -952,7 +985,8 @@ async def test_batch_process_documents_async( request_type=document_processor_service.BatchProcessRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1008,7 +1042,10 @@ def test_batch_process_documents_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1039,7 +1076,10 @@ async def test_batch_process_documents_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_batch_process_documents_flattened(): @@ -1055,7 +1095,9 @@ def test_batch_process_documents_flattened(): call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.batch_process_documents(name="name_value",) + client.batch_process_documents( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1075,7 +1117,8 @@ def test_batch_process_documents_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.batch_process_documents( - document_processor_service.BatchProcessRequest(), name="name_value", + document_processor_service.BatchProcessRequest(), + name="name_value", ) @@ -1097,7 +1140,9 @@ async def test_batch_process_documents_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.batch_process_documents(name="name_value",) + response = await client.batch_process_documents( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1118,16 +1163,22 @@ async def test_batch_process_documents_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.batch_process_documents( - document_processor_service.BatchProcessRequest(), name="name_value", + document_processor_service.BatchProcessRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [document_processor_service.FetchProcessorTypesRequest, dict,] + "request_type", + [ + document_processor_service.FetchProcessorTypesRequest, + dict, + ], ) def test_fetch_processor_types(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1155,7 +1206,8 @@ def test_fetch_processor_types_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1174,7 +1226,8 @@ async def test_fetch_processor_types_async( request_type=document_processor_service.FetchProcessorTypesRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1230,7 +1283,10 @@ def test_fetch_processor_types_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1261,7 +1317,10 @@ async def test_fetch_processor_types_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_fetch_processor_types_flattened(): @@ -1277,7 +1336,9 @@ def test_fetch_processor_types_flattened(): call.return_value = document_processor_service.FetchProcessorTypesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.fetch_processor_types(parent="parent_value",) + client.fetch_processor_types( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1320,7 +1381,9 @@ async def test_fetch_processor_types_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.fetch_processor_types(parent="parent_value",) + response = await client.fetch_processor_types( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1347,11 +1410,16 @@ async def test_fetch_processor_types_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [document_processor_service.ListProcessorsRequest, dict,] + "request_type", + [ + document_processor_service.ListProcessorsRequest, + dict, + ], ) def test_list_processors(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1380,7 +1448,8 @@ def test_list_processors_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1397,7 +1466,8 @@ async def test_list_processors_async( request_type=document_processor_service.ListProcessorsRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1452,7 +1522,10 @@ def test_list_processors_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1481,7 +1554,10 @@ async def test_list_processors_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_processors_flattened(): @@ -1495,7 +1571,9 @@ def test_list_processors_flattened(): call.return_value = document_processor_service.ListProcessorsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_processors(parent="parent_value",) + client.list_processors( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1515,7 +1593,8 @@ def test_list_processors_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.list_processors( - document_processor_service.ListProcessorsRequest(), parent="parent_value", + document_processor_service.ListProcessorsRequest(), + parent="parent_value", ) @@ -1535,7 +1614,9 @@ async def test_list_processors_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_processors(parent="parent_value",) + response = await client.list_processors( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1556,13 +1637,15 @@ async def test_list_processors_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_processors( - document_processor_service.ListProcessorsRequest(), parent="parent_value", + document_processor_service.ListProcessorsRequest(), + parent="parent_value", ) def test_list_processors_pager(transport_name: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1578,13 +1661,20 @@ def test_list_processors_pager(transport_name: str = "grpc"): next_page_token="abc", ), document_processor_service.ListProcessorsResponse( - processors=[], next_page_token="def", + processors=[], + next_page_token="def", ), document_processor_service.ListProcessorsResponse( - processors=[processor.Processor(),], next_page_token="ghi", + processors=[ + processor.Processor(), + ], + next_page_token="ghi", ), document_processor_service.ListProcessorsResponse( - processors=[processor.Processor(), processor.Processor(),], + processors=[ + processor.Processor(), + processor.Processor(), + ], ), RuntimeError, ) @@ -1604,7 +1694,8 @@ def test_list_processors_pager(transport_name: str = "grpc"): def test_list_processors_pages(transport_name: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1620,13 +1711,20 @@ def test_list_processors_pages(transport_name: str = "grpc"): next_page_token="abc", ), document_processor_service.ListProcessorsResponse( - processors=[], next_page_token="def", + processors=[], + next_page_token="def", ), document_processor_service.ListProcessorsResponse( - processors=[processor.Processor(),], next_page_token="ghi", + processors=[ + processor.Processor(), + ], + next_page_token="ghi", ), document_processor_service.ListProcessorsResponse( - processors=[processor.Processor(), processor.Processor(),], + processors=[ + processor.Processor(), + processor.Processor(), + ], ), RuntimeError, ) @@ -1656,17 +1754,26 @@ async def test_list_processors_async_pager(): next_page_token="abc", ), document_processor_service.ListProcessorsResponse( - processors=[], next_page_token="def", + processors=[], + next_page_token="def", ), document_processor_service.ListProcessorsResponse( - processors=[processor.Processor(),], next_page_token="ghi", + processors=[ + processor.Processor(), + ], + next_page_token="ghi", ), document_processor_service.ListProcessorsResponse( - processors=[processor.Processor(), processor.Processor(),], + processors=[ + processor.Processor(), + processor.Processor(), + ], ), RuntimeError, ) - async_pager = await client.list_processors(request={},) + async_pager = await client.list_processors( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1697,13 +1804,20 @@ async def test_list_processors_async_pages(): next_page_token="abc", ), document_processor_service.ListProcessorsResponse( - processors=[], next_page_token="def", + processors=[], + next_page_token="def", ), document_processor_service.ListProcessorsResponse( - processors=[processor.Processor(),], next_page_token="ghi", + processors=[ + processor.Processor(), + ], + next_page_token="ghi", ), document_processor_service.ListProcessorsResponse( - processors=[processor.Processor(), processor.Processor(),], + processors=[ + processor.Processor(), + processor.Processor(), + ], ), RuntimeError, ) @@ -1715,11 +1829,16 @@ async def test_list_processors_async_pages(): @pytest.mark.parametrize( - "request_type", [document_processor_service.CreateProcessorRequest, dict,] + "request_type", + [ + document_processor_service.CreateProcessorRequest, + dict, + ], ) def test_create_processor(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1760,7 +1879,8 @@ def test_create_processor_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1777,7 +1897,8 @@ async def test_create_processor_async( request_type=document_processor_service.CreateProcessorRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1844,7 +1965,10 @@ def test_create_processor_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1873,7 +1997,10 @@ async def test_create_processor_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_create_processor_flattened(): @@ -1888,7 +2015,8 @@ def test_create_processor_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_processor( - parent="parent_value", processor=gcd_processor.Processor(name="name_value"), + parent="parent_value", + processor=gcd_processor.Processor(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1935,7 +2063,8 @@ async def test_create_processor_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_processor( - parent="parent_value", processor=gcd_processor.Processor(name="name_value"), + parent="parent_value", + processor=gcd_processor.Processor(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1967,11 +2096,16 @@ async def test_create_processor_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [document_processor_service.DeleteProcessorRequest, dict,] + "request_type", + [ + document_processor_service.DeleteProcessorRequest, + dict, + ], ) def test_delete_processor(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1997,7 +2131,8 @@ def test_delete_processor_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2014,7 +2149,8 @@ async def test_delete_processor_async( request_type=document_processor_service.DeleteProcessorRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2066,7 +2202,10 @@ def test_delete_processor_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2095,7 +2234,10 @@ async def test_delete_processor_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_delete_processor_flattened(): @@ -2109,7 +2251,9 @@ def test_delete_processor_flattened(): call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_processor(name="name_value",) + client.delete_processor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2129,7 +2273,8 @@ def test_delete_processor_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.delete_processor( - document_processor_service.DeleteProcessorRequest(), name="name_value", + document_processor_service.DeleteProcessorRequest(), + name="name_value", ) @@ -2149,7 +2294,9 @@ async def test_delete_processor_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_processor(name="name_value",) + response = await client.delete_processor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2170,16 +2317,22 @@ async def test_delete_processor_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_processor( - document_processor_service.DeleteProcessorRequest(), name="name_value", + document_processor_service.DeleteProcessorRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [document_processor_service.EnableProcessorRequest, dict,] + "request_type", + [ + document_processor_service.EnableProcessorRequest, + dict, + ], ) def test_enable_processor(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2205,7 +2358,8 @@ def test_enable_processor_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2222,7 +2376,8 @@ async def test_enable_processor_async( request_type=document_processor_service.EnableProcessorRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2274,7 +2429,10 @@ def test_enable_processor_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2303,15 +2461,23 @@ async def test_enable_processor_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.parametrize( - "request_type", [document_processor_service.DisableProcessorRequest, dict,] + "request_type", + [ + document_processor_service.DisableProcessorRequest, + dict, + ], ) def test_disable_processor(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2339,7 +2505,8 @@ def test_disable_processor_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2358,7 +2525,8 @@ async def test_disable_processor_async( request_type=document_processor_service.DisableProcessorRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2414,7 +2582,10 @@ def test_disable_processor_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2445,15 +2616,23 @@ async def test_disable_processor_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.parametrize( - "request_type", [document_processor_service.ReviewDocumentRequest, dict,] + "request_type", + [ + document_processor_service.ReviewDocumentRequest, + dict, + ], ) def test_review_document(request_type, transport: str = "grpc"): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2479,7 +2658,8 @@ def test_review_document_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2496,7 +2676,8 @@ async def test_review_document_async( request_type=document_processor_service.ReviewDocumentRequest, ): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2597,7 +2778,9 @@ def test_review_document_flattened(): call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.review_document(human_review_config="human_review_config_value",) + client.review_document( + human_review_config="human_review_config_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2673,7 +2856,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -2694,7 +2878,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = DocumentProcessorServiceClient( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -2711,7 +2896,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DocumentProcessorServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2760,7 +2946,8 @@ def test_transport_grpc_default(): credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( - client.transport, transports.DocumentProcessorServiceGrpcTransport, + client.transport, + transports.DocumentProcessorServiceGrpcTransport, ) @@ -2819,7 +3006,8 @@ def test_document_processor_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DocumentProcessorServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2981,7 +3169,8 @@ def test_document_processor_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.DocumentProcessorServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2993,7 +3182,8 @@ def test_document_processor_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.DocumentProcessorServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3102,12 +3292,16 @@ def test_document_processor_service_transport_channel_mtls_with_adc(transport_cl def test_document_processor_service_grpc_lro_client(): client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -3115,12 +3309,16 @@ def test_document_processor_service_grpc_lro_client(): def test_document_processor_service_grpc_lro_async_client(): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -3131,7 +3329,9 @@ def test_human_review_config_path(): location = "clam" processor = "whelk" expected = "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig".format( - project=project, location=location, processor=processor, + project=project, + location=location, + processor=processor, ) actual = DocumentProcessorServiceClient.human_review_config_path( project, location, processor @@ -3157,7 +3357,9 @@ def test_processor_path(): location = "mussel" processor = "winkle" expected = "projects/{project}/locations/{location}/processors/{processor}".format( - project=project, location=location, processor=processor, + project=project, + location=location, + processor=processor, ) actual = DocumentProcessorServiceClient.processor_path(project, location, processor) assert expected == actual @@ -3181,7 +3383,9 @@ def test_processor_type_path(): location = "clam" processor_type = "whelk" expected = "projects/{project}/locations/{location}/processorTypes/{processor_type}".format( - project=project, location=location, processor_type=processor_type, + project=project, + location=location, + processor_type=processor_type, ) actual = DocumentProcessorServiceClient.processor_type_path( project, location, processor_type @@ -3224,7 +3428,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = DocumentProcessorServiceClient.common_folder_path(folder) assert expected == actual @@ -3242,7 +3448,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = DocumentProcessorServiceClient.common_organization_path(organization) assert expected == actual @@ -3260,7 +3468,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = DocumentProcessorServiceClient.common_project_path(project) assert expected == actual @@ -3280,7 +3490,8 @@ def test_common_location_path(): project = "whelk" location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = DocumentProcessorServiceClient.common_location_path(project, location) assert expected == actual @@ -3305,7 +3516,8 @@ def test_client_with_default_client_info(): transports.DocumentProcessorServiceTransport, "_prep_wrapped_messages" ) as prep: client = DocumentProcessorServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3314,7 +3526,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = DocumentProcessorServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3322,7 +3535,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = DocumentProcessorServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" From 9d52da3ad816d81180c45f3e1ef2834fbbdb280b Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 16:46:26 +0000 Subject: [PATCH 04/16] chore(python): add E231 to .flake8 ignore list (#302) Source-Link: https://github.com/googleapis/synthtool/commit/7ff4aad2ec5af0380e8bd6da1fa06eaadf24ec81 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:462782b0b492346b2d9099aaff52206dd30bc8e031ea97082e6facecc2373244 --- .flake8 | 2 +- .github/.OwlBot.lock.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index 29227d4c..2e438749 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 87dd0061..9e0a9356 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe + digest: sha256:462782b0b492346b2d9099aaff52206dd30bc8e031ea97082e6facecc2373244 From adf745c40f3b72137ead96f4f6567bed31de912a Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 00:22:33 +0000 Subject: [PATCH 05/16] chore(python): update .pre-commit-config.yaml to use black==22.3.0 (#303) Source-Link: https://github.com/googleapis/synthtool/commit/7804ade3daae0d66649bee8df6c55484c6580b8d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d --- .github/.OwlBot.lock.yaml | 3 ++- .pre-commit-config.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 9e0a9356..22cc254a 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:462782b0b492346b2d9099aaff52206dd30bc8e031ea97082e6facecc2373244 + digest: sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d +# created: 2022-03-30T23:44:26.560599165Z diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a77..46d23716 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 From 1a033dc6d6366c0e69496f5037a4448a74800c36 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 02:12:12 +0000 Subject: [PATCH 06/16] chore(python): Enable size-label bot (#304) Source-Link: https://github.com/googleapis/synthtool/commit/06e82790dd719a165ad32b8a06f8f6ec3e3cae0f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-label.yaml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .github/auto-label.yaml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 22cc254a..58a0b153 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d -# created: 2022-03-30T23:44:26.560599165Z + digest: sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce +# created: 2022-04-01T01:42:03.609279246Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 00000000..09c8d735 --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,2 @@ +requestsize: + enabled: true From eccc574a2203968470f81b3905685da3663c205c Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 19:34:27 +0000 Subject: [PATCH 07/16] chore(python): refactor unit / system test dependency install (#305) Source-Link: https://github.com/googleapis/synthtool/commit/993985f0fc4b37152e588f0549bcbdaf34666023 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd --- .github/.OwlBot.lock.yaml | 4 +- noxfile.py | 105 ++++++++++++++++++++++++++++++-------- 2 files changed, 87 insertions(+), 22 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 58a0b153..fa576229 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce -# created: 2022-04-01T01:42:03.609279246Z + digest: sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd +# created: 2022-04-01T15:48:07.524222836Z diff --git a/noxfile.py b/noxfile.py index 3addb4ed..6ee5e8ab 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,16 +20,40 @@ import os import pathlib import shutil +import warnings import nox - BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -81,23 +105,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -121,6 +163,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -143,13 +214,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: From 9d8ac0def62b62fca32dd54f905178b4747db3de Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 10:54:10 +0000 Subject: [PATCH 08/16] chore(python): add license header to auto-label.yaml (#306) Source-Link: https://github.com/googleapis/synthtool/commit/eb78c980b52c7c6746d2edb77d9cf7aaa99a2aab Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-label.yaml | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index fa576229..bc893c97 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd -# created: 2022-04-01T15:48:07.524222836Z + digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 +# created: 2022-04-06T10:30:21.687684602Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml index 09c8d735..41bff0b5 100644 --- a/.github/auto-label.yaml +++ b/.github/auto-label.yaml @@ -1,2 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. requestsize: enabled: true From 8c840c4c427f3408925d245e3fcabc44c91e3b8a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 02:03:05 +0200 Subject: [PATCH 09/16] chore(deps): update dependency google-cloud-storage to v2.3.0 (#310) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index dea61094..b15c1f31 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,2 +1,2 @@ google-cloud-documentai==1.4.0 -google-cloud-storage==2.2.1 +google-cloud-storage==2.3.0 From 1afdeba85471dd23e8c604d7d1ebe21832eb9678 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 14 Apr 2022 06:24:47 -0400 Subject: [PATCH 10/16] chore: use gapic-generator-python 0.65.1 (#311) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.65.1 PiperOrigin-RevId: 441524537 Source-Link: https://github.com/googleapis/googleapis/commit/2a273915b3f70fe86c9d2a75470a0b83e48d0abf Source-Link: https://github.com/googleapis/googleapis-gen/commit/ab6756a48c89b5bcb9fb73443cb8e55d574f4643 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWI2NzU2YTQ4Yzg5YjViY2I5ZmI3MzQ0M2NiOGU1NWQ1NzRmNDY0MyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .../async_client.py | 4 +- .../document_processor_service/client.py | 4 +- .../transports/base.py | 5 + .../transports/grpc.py | 4 + google/cloud/documentai_v1/types/__init__.py | 8 +- .../async_client.py | 3 +- .../document_understanding_service/client.py | 3 +- .../transports/base.py | 5 + .../transports/grpc.py | 4 + .../documentai_v1beta2/types/__init__.py | 4 +- .../async_client.py | 6 +- .../document_processor_service/client.py | 6 +- .../transports/base.py | 5 + .../transports/grpc.py | 4 + .../documentai_v1beta3/types/__init__.py | 16 +- .../snippet_metadata_documentai_v1.json | 250 +++++- .../snippet_metadata_documentai_v1beta2.json | 162 +++- .../snippet_metadata_documentai_v1beta3.json | 722 +++++++++++++++++- .../test_document_processor_service.py | 79 +- .../test_document_understanding_service.py | 79 +- .../test_document_processor_service.py | 85 ++- 21 files changed, 1322 insertions(+), 136 deletions(-) diff --git a/google/cloud/documentai_v1/services/document_processor_service/async_client.py b/google/cloud/documentai_v1/services/document_processor_service/async_client.py index 48184c6a..0a2eae32 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -343,7 +343,6 @@ async def batch_process_documents( r"""LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format. - .. code-block:: python from google.cloud import documentai_v1 @@ -465,7 +464,6 @@ async def review_document( r"""Send a document for Human Review. The input document should be processed by the specified processor. - .. code-block:: python from google.cloud import documentai_v1 diff --git a/google/cloud/documentai_v1/services/document_processor_service/client.py b/google/cloud/documentai_v1/services/document_processor_service/client.py index a8131e1b..472fed92 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -566,7 +566,6 @@ def batch_process_documents( r"""LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format. - .. code-block:: python from google.cloud import documentai_v1 @@ -678,7 +677,6 @@ def review_document( r"""Send a document for Human Review. The input document should be processed by the specified processor. - .. code-block:: python from google.cloud import documentai_v1 diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/base.py b/google/cloud/documentai_v1/services/document_processor_service/transports/base.py index bf5a8263..41f453b7 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/base.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/base.py @@ -82,6 +82,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -213,5 +214,9 @@ def review_document( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("DocumentProcessorServiceTransport",) diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py index 17dba4df..15fd5ea2 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py @@ -338,5 +338,9 @@ def review_document( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("DocumentProcessorServiceGrpcTransport",) diff --git a/google/cloud/documentai_v1/types/__init__.py b/google/cloud/documentai_v1/types/__init__.py index 079dd069..10edbb6d 100644 --- a/google/cloud/documentai_v1/types/__init__.py +++ b/google/cloud/documentai_v1/types/__init__.py @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .document import Document +from .document import ( + Document, +) from .document_io import ( BatchDocumentsInputConfig, DocumentOutputConfig, @@ -38,7 +40,9 @@ NormalizedVertex, Vertex, ) -from .operation_metadata import CommonOperationMetadata +from .operation_metadata import ( + CommonOperationMetadata, +) __all__ = ( "Document", diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py index 417291c3..31386906 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -227,7 +227,6 @@ async def batch_process_documents( r"""LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format. - .. code-block:: python from google.cloud import documentai_v1beta2 diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py index fd7b8776..edd95067 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -428,7 +428,6 @@ def batch_process_documents( r"""LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format. - .. code-block:: python from google.cloud import documentai_v1beta2 diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py index 2282ea3a..096e7dae 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py @@ -83,6 +83,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -187,5 +188,9 @@ def process_document( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("DocumentUnderstandingServiceTransport",) diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py index 8b2a4f8b..6ff7a880 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py @@ -305,5 +305,9 @@ def process_document( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("DocumentUnderstandingServiceGrpcTransport",) diff --git a/google/cloud/documentai_v1beta2/types/__init__.py b/google/cloud/documentai_v1beta2/types/__init__.py index 31c275ea..7a26ae1f 100644 --- a/google/cloud/documentai_v1beta2/types/__init__.py +++ b/google/cloud/documentai_v1beta2/types/__init__.py @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .document import Document +from .document import ( + Document, +) from .document_understanding import ( AutoMlParams, BatchProcessDocumentsRequest, diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py index 09de0c54..f7a9cdf3 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -355,7 +355,6 @@ async def batch_process_documents( r"""LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format. - .. code-block:: python from google.cloud import documentai_v1beta3 @@ -686,7 +685,6 @@ async def create_processor( user chose. The processor will be at "ENABLED" state by default after its creation. - .. code-block:: python from google.cloud import documentai_v1beta3 @@ -800,7 +798,6 @@ async def delete_processor( artifacts if it was enabled and then deletes all artifacts associated with this processor. - .. code-block:: python from google.cloud import documentai_v1beta3 @@ -1098,7 +1095,6 @@ async def review_document( r"""Send a document for Human Review. The input document should be processed by the specified processor. - .. code-block:: python from google.cloud import documentai_v1beta3 diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py index 30336ce1..c4337919 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -594,7 +594,6 @@ def batch_process_documents( r"""LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format. - .. code-block:: python from google.cloud import documentai_v1beta3 @@ -917,7 +916,6 @@ def create_processor( user chose. The processor will be at "ENABLED" state by default after its creation. - .. code-block:: python from google.cloud import documentai_v1beta3 @@ -1031,7 +1029,6 @@ def delete_processor( artifacts if it was enabled and then deletes all artifacts associated with this processor. - .. code-block:: python from google.cloud import documentai_v1beta3 @@ -1331,7 +1328,6 @@ def review_document( r"""Send a document for Human Review. The input document should be processed by the specified processor. - .. code-block:: python from google.cloud import documentai_v1beta3 diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py index 31523d15..541e713b 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py @@ -83,6 +83,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -304,5 +305,9 @@ def review_document( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("DocumentProcessorServiceTransport",) diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py index f11ad3dd..a84d7fb2 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py @@ -513,5 +513,9 @@ def review_document( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("DocumentProcessorServiceGrpcTransport",) diff --git a/google/cloud/documentai_v1beta3/types/__init__.py b/google/cloud/documentai_v1beta3/types/__init__.py index 522631ea..9f91420d 100644 --- a/google/cloud/documentai_v1beta3/types/__init__.py +++ b/google/cloud/documentai_v1beta3/types/__init__.py @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .document import Document +from .document import ( + Document, +) from .document_io import ( BatchDocumentsInputConfig, DocumentOutputConfig, @@ -51,9 +53,15 @@ NormalizedVertex, Vertex, ) -from .operation_metadata import CommonOperationMetadata -from .processor import Processor -from .processor_type import ProcessorType +from .operation_metadata import ( + CommonOperationMetadata, +) +from .processor import ( + Processor, +) +from .processor_type import ( + ProcessorType, +) __all__ = ( "Document", diff --git a/samples/generated_samples/snippet_metadata_documentai_v1.json b/samples/generated_samples/snippet_metadata_documentai_v1.json index e32e56f8..5c1b8d92 100644 --- a/samples/generated_samples/snippet_metadata_documentai_v1.json +++ b/samples/generated_samples/snippet_metadata_documentai_v1.json @@ -1,16 +1,61 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.documentai.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-documentai" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceAsyncClient.batch_process_documents", "method": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments", "service": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "BatchProcessDocuments" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1.types.BatchProcessRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "batch_process_documents" }, + "description": "Sample for BatchProcessDocuments", "file": "documentai_v1_generated_document_processor_service_batch_process_documents_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async", "segments": [ { @@ -43,18 +88,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1_generated_document_processor_service_batch_process_documents_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceClient.batch_process_documents", "method": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments", "service": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "BatchProcessDocuments" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1.types.BatchProcessRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "batch_process_documents" }, + "description": "Sample for BatchProcessDocuments", "file": "documentai_v1_generated_document_processor_service_batch_process_documents_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_sync", "segments": [ { @@ -87,19 +168,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1_generated_document_processor_service_batch_process_documents_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceAsyncClient.process_document", "method": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument", "service": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ProcessDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1.types.ProcessRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1.types.ProcessResponse", + "shortName": "process_document" }, + "description": "Sample for ProcessDocument", "file": "documentai_v1_generated_document_processor_service_process_document_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1_generated_DocumentProcessorService_ProcessDocument_async", "segments": [ { @@ -132,18 +249,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1_generated_document_processor_service_process_document_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceClient.process_document", "method": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument", "service": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ProcessDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1.types.ProcessRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1.types.ProcessResponse", + "shortName": "process_document" }, + "description": "Sample for ProcessDocument", "file": "documentai_v1_generated_document_processor_service_process_document_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1_generated_DocumentProcessorService_ProcessDocument_sync", "segments": [ { @@ -176,19 +329,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1_generated_document_processor_service_process_document_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceAsyncClient.review_document", "method": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ReviewDocument", "service": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ReviewDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1.types.ReviewDocumentRequest" + }, + { + "name": "human_review_config", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "review_document" }, + "description": "Sample for ReviewDocument", "file": "documentai_v1_generated_document_processor_service_review_document_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1_generated_DocumentProcessorService_ReviewDocument_async", "segments": [ { @@ -221,18 +410,54 @@ "start": 50, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1_generated_document_processor_service_review_document_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1.DocumentProcessorServiceClient.review_document", "method": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ReviewDocument", "service": { + "fullName": "google.cloud.documentai.v1.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ReviewDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1.types.ReviewDocumentRequest" + }, + { + "name": "human_review_config", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "review_document" }, + "description": "Sample for ReviewDocument", "file": "documentai_v1_generated_document_processor_service_review_document_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1_generated_DocumentProcessorService_ReviewDocument_sync", "segments": [ { @@ -265,7 +490,8 @@ "start": 50, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1_generated_document_processor_service_review_document_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_documentai_v1beta2.json b/samples/generated_samples/snippet_metadata_documentai_v1beta2.json index 1d18b708..ec455c8b 100644 --- a/samples/generated_samples/snippet_metadata_documentai_v1beta2.json +++ b/samples/generated_samples/snippet_metadata_documentai_v1beta2.json @@ -1,16 +1,61 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.documentai.v1beta2", + "version": "v1beta2" + } + ], + "language": "PYTHON", + "name": "google-cloud-documentai" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta2.DocumentUnderstandingServiceAsyncClient", + "shortName": "DocumentUnderstandingServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta2.DocumentUnderstandingServiceAsyncClient.batch_process_documents", "method": { + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.BatchProcessDocuments", "service": { + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService", "shortName": "DocumentUnderstandingService" }, "shortName": "BatchProcessDocuments" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta2.types.BatchProcessDocumentsRequest" + }, + { + "name": "requests", + "type": "Sequence[google.cloud.documentai_v1beta2.types.ProcessDocumentRequest]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "batch_process_documents" }, + "description": "Sample for BatchProcessDocuments", "file": "documentai_v1beta2_generated_document_understanding_service_batch_process_documents_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async", "segments": [ { @@ -43,18 +88,54 @@ "start": 50, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta2_generated_document_understanding_service_batch_process_documents_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta2.DocumentUnderstandingServiceClient", + "shortName": "DocumentUnderstandingServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta2.DocumentUnderstandingServiceClient.batch_process_documents", "method": { + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.BatchProcessDocuments", "service": { + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService", "shortName": "DocumentUnderstandingService" }, "shortName": "BatchProcessDocuments" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta2.types.BatchProcessDocumentsRequest" + }, + { + "name": "requests", + "type": "Sequence[google.cloud.documentai_v1beta2.types.ProcessDocumentRequest]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "batch_process_documents" }, + "description": "Sample for BatchProcessDocuments", "file": "documentai_v1beta2_generated_document_understanding_service_batch_process_documents_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_sync", "segments": [ { @@ -87,19 +168,51 @@ "start": 50, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta2_generated_document_understanding_service_batch_process_documents_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta2.DocumentUnderstandingServiceAsyncClient", + "shortName": "DocumentUnderstandingServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta2.DocumentUnderstandingServiceAsyncClient.process_document", "method": { + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.ProcessDocument", "service": { + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService", "shortName": "DocumentUnderstandingService" }, "shortName": "ProcessDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta2.types.ProcessDocumentRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta2.types.Document", + "shortName": "process_document" }, + "description": "Sample for ProcessDocument", "file": "documentai_v1beta2_generated_document_understanding_service_process_document_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_async", "segments": [ { @@ -132,18 +245,50 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta2_generated_document_understanding_service_process_document_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta2.DocumentUnderstandingServiceClient", + "shortName": "DocumentUnderstandingServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta2.DocumentUnderstandingServiceClient.process_document", "method": { + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.ProcessDocument", "service": { + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService", "shortName": "DocumentUnderstandingService" }, "shortName": "ProcessDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta2.types.ProcessDocumentRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta2.types.Document", + "shortName": "process_document" }, + "description": "Sample for ProcessDocument", "file": "documentai_v1beta2_generated_document_understanding_service_process_document_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_sync", "segments": [ { @@ -176,7 +321,8 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta2_generated_document_understanding_service_process_document_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_documentai_v1beta3.json b/samples/generated_samples/snippet_metadata_documentai_v1beta3.json index 53d92b3d..68d8827d 100644 --- a/samples/generated_samples/snippet_metadata_documentai_v1beta3.json +++ b/samples/generated_samples/snippet_metadata_documentai_v1beta3.json @@ -1,16 +1,61 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.documentai.v1beta3", + "version": "v1beta3" + } + ], + "language": "PYTHON", + "name": "google-cloud-documentai" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient.batch_process_documents", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "BatchProcessDocuments" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.BatchProcessRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "batch_process_documents" }, + "description": "Sample for BatchProcessDocuments", "file": "documentai_v1beta3_generated_document_processor_service_batch_process_documents_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async", "segments": [ { @@ -43,18 +88,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_batch_process_documents_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient.batch_process_documents", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "BatchProcessDocuments" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.BatchProcessRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "batch_process_documents" }, + "description": "Sample for BatchProcessDocuments", "file": "documentai_v1beta3_generated_document_processor_service_batch_process_documents_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_sync", "segments": [ { @@ -87,19 +168,59 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_batch_process_documents_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient.create_processor", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.CreateProcessor", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "CreateProcessor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.CreateProcessorRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "processor", + "type": "google.cloud.documentai_v1beta3.types.Processor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta3.types.Processor", + "shortName": "create_processor" }, + "description": "Sample for CreateProcessor", "file": "documentai_v1beta3_generated_document_processor_service_create_processor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_async", "segments": [ { @@ -132,18 +253,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_create_processor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient.create_processor", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.CreateProcessor", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "CreateProcessor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.CreateProcessorRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "processor", + "type": "google.cloud.documentai_v1beta3.types.Processor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta3.types.Processor", + "shortName": "create_processor" }, + "description": "Sample for CreateProcessor", "file": "documentai_v1beta3_generated_document_processor_service_create_processor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_sync", "segments": [ { @@ -176,19 +337,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_create_processor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient.delete_processor", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessor", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "DeleteProcessor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.DeleteProcessorRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_processor" }, + "description": "Sample for DeleteProcessor", "file": "documentai_v1beta3_generated_document_processor_service_delete_processor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async", "segments": [ { @@ -221,18 +418,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_delete_processor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient.delete_processor", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessor", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "DeleteProcessor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.DeleteProcessorRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_processor" }, + "description": "Sample for DeleteProcessor", "file": "documentai_v1beta3_generated_document_processor_service_delete_processor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_sync", "segments": [ { @@ -265,19 +498,51 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_delete_processor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient.disable_processor", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DisableProcessor", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "DisableProcessor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.DisableProcessorRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "disable_processor" }, + "description": "Sample for DisableProcessor", "file": "documentai_v1beta3_generated_document_processor_service_disable_processor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async", "segments": [ { @@ -310,18 +575,50 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_disable_processor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient.disable_processor", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DisableProcessor", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "DisableProcessor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.DisableProcessorRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "disable_processor" }, + "description": "Sample for DisableProcessor", "file": "documentai_v1beta3_generated_document_processor_service_disable_processor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_sync", "segments": [ { @@ -354,19 +651,51 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_disable_processor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient.enable_processor", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EnableProcessor", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "EnableProcessor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.EnableProcessorRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "enable_processor" }, + "description": "Sample for EnableProcessor", "file": "documentai_v1beta3_generated_document_processor_service_enable_processor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async", "segments": [ { @@ -399,18 +728,50 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_enable_processor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient.enable_processor", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EnableProcessor", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "EnableProcessor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.EnableProcessorRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "enable_processor" }, + "description": "Sample for EnableProcessor", "file": "documentai_v1beta3_generated_document_processor_service_enable_processor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_sync", "segments": [ { @@ -443,19 +804,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_enable_processor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient.fetch_processor_types", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.FetchProcessorTypes", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "FetchProcessorTypes" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.FetchProcessorTypesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta3.types.FetchProcessorTypesResponse", + "shortName": "fetch_processor_types" }, + "description": "Sample for FetchProcessorTypes", "file": "documentai_v1beta3_generated_document_processor_service_fetch_processor_types_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_async", "segments": [ { @@ -488,18 +885,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_fetch_processor_types_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient.fetch_processor_types", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.FetchProcessorTypes", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "FetchProcessorTypes" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.FetchProcessorTypesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta3.types.FetchProcessorTypesResponse", + "shortName": "fetch_processor_types" }, + "description": "Sample for FetchProcessorTypes", "file": "documentai_v1beta3_generated_document_processor_service_fetch_processor_types_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_sync", "segments": [ { @@ -532,19 +965,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_fetch_processor_types_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient.list_processors", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessors", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ListProcessors" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.ListProcessorsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta3.services.document_processor_service.pagers.ListProcessorsAsyncPager", + "shortName": "list_processors" }, + "description": "Sample for ListProcessors", "file": "documentai_v1beta3_generated_document_processor_service_list_processors_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_async", "segments": [ { @@ -577,18 +1046,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_list_processors_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient.list_processors", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessors", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ListProcessors" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.ListProcessorsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta3.services.document_processor_service.pagers.ListProcessorsPager", + "shortName": "list_processors" }, + "description": "Sample for ListProcessors", "file": "documentai_v1beta3_generated_document_processor_service_list_processors_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_sync", "segments": [ { @@ -621,19 +1126,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_list_processors_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient.process_document", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ProcessDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.ProcessRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta3.types.ProcessResponse", + "shortName": "process_document" }, + "description": "Sample for ProcessDocument", "file": "documentai_v1beta3_generated_document_processor_service_process_document_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_async", "segments": [ { @@ -666,18 +1207,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_process_document_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient.process_document", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ProcessDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.ProcessRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.documentai_v1beta3.types.ProcessResponse", + "shortName": "process_document" }, + "description": "Sample for ProcessDocument", "file": "documentai_v1beta3_generated_document_processor_service_process_document_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_sync", "segments": [ { @@ -710,19 +1287,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_process_document_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient", + "shortName": "DocumentProcessorServiceAsyncClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceAsyncClient.review_document", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ReviewDocument", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ReviewDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.ReviewDocumentRequest" + }, + { + "name": "human_review_config", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "review_document" }, + "description": "Sample for ReviewDocument", "file": "documentai_v1beta3_generated_document_processor_service_review_document_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async", "segments": [ { @@ -755,18 +1368,54 @@ "start": 50, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_review_document_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient", + "shortName": "DocumentProcessorServiceClient" + }, + "fullName": "google.cloud.documentai_v1beta3.DocumentProcessorServiceClient.review_document", "method": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ReviewDocument", "service": { + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService", "shortName": "DocumentProcessorService" }, "shortName": "ReviewDocument" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.documentai_v1beta3.types.ReviewDocumentRequest" + }, + { + "name": "human_review_config", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "review_document" }, + "description": "Sample for ReviewDocument", "file": "documentai_v1beta3_generated_document_processor_service_review_document_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_sync", "segments": [ { @@ -799,7 +1448,8 @@ "start": 50, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "documentai_v1beta3_generated_document_processor_service_review_document_sync.py" } ] } diff --git a/tests/unit/gapic/documentai_v1/test_document_processor_service.py b/tests/unit/gapic/documentai_v1/test_document_processor_service.py index f462a23e..98e42976 100644 --- a/tests/unit/gapic/documentai_v1/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1/test_document_processor_service.py @@ -107,24 +107,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DocumentProcessorServiceClient, - DocumentProcessorServiceAsyncClient, + (DocumentProcessorServiceClient, "grpc"), + (DocumentProcessorServiceAsyncClient, "grpc_asyncio"), ], ) -def test_document_processor_service_client_from_service_account_info(client_class): +def test_document_processor_service_client_from_service_account_info( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "documentai.googleapis.com:443" + assert client.transport._host == ("documentai.googleapis.com:443") @pytest.mark.parametrize( @@ -153,27 +155,33 @@ def test_document_processor_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DocumentProcessorServiceClient, - DocumentProcessorServiceAsyncClient, + (DocumentProcessorServiceClient, "grpc"), + (DocumentProcessorServiceAsyncClient, "grpc_asyncio"), ], ) -def test_document_processor_service_client_from_service_account_file(client_class): +def test_document_processor_service_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "documentai.googleapis.com:443" + assert client.transport._host == ("documentai.googleapis.com:443") def test_document_processor_service_client_get_transport_class(): @@ -1474,6 +1482,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = DocumentProcessorServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = DocumentProcessorServiceClient( @@ -1523,6 +1544,14 @@ def test_document_processor_service_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_document_processor_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1672,24 +1701,40 @@ def test_document_processor_service_grpc_transport_client_cert_source_for_mtls( ) -def test_document_processor_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_document_processor_service_host_no_port(transport_name): client = DocumentProcessorServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="documentai.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "documentai.googleapis.com:443" + assert client.transport._host == ("documentai.googleapis.com:443") -def test_document_processor_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_document_processor_service_host_with_port(transport_name): client = DocumentProcessorServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="documentai.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "documentai.googleapis.com:8000" + assert client.transport._host == ("documentai.googleapis.com:8000") def test_document_processor_service_grpc_transport_channel(): diff --git a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py index 6b3e2775..33eabf06 100644 --- a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py +++ b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py @@ -101,24 +101,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DocumentUnderstandingServiceClient, - DocumentUnderstandingServiceAsyncClient, + (DocumentUnderstandingServiceClient, "grpc"), + (DocumentUnderstandingServiceAsyncClient, "grpc_asyncio"), ], ) -def test_document_understanding_service_client_from_service_account_info(client_class): +def test_document_understanding_service_client_from_service_account_info( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "documentai.googleapis.com:443" + assert client.transport._host == ("documentai.googleapis.com:443") @pytest.mark.parametrize( @@ -147,27 +149,33 @@ def test_document_understanding_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DocumentUnderstandingServiceClient, - DocumentUnderstandingServiceAsyncClient, + (DocumentUnderstandingServiceClient, "grpc"), + (DocumentUnderstandingServiceAsyncClient, "grpc_asyncio"), ], ) -def test_document_understanding_service_client_from_service_account_file(client_class): +def test_document_understanding_service_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "documentai.googleapis.com:443" + assert client.transport._host == ("documentai.googleapis.com:443") def test_document_understanding_service_client_get_transport_class(): @@ -1180,6 +1188,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = DocumentUnderstandingServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = DocumentUnderstandingServiceClient( @@ -1228,6 +1249,14 @@ def test_document_understanding_service_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_document_understanding_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1380,24 +1409,40 @@ def test_document_understanding_service_grpc_transport_client_cert_source_for_mt ) -def test_document_understanding_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_document_understanding_service_host_no_port(transport_name): client = DocumentUnderstandingServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="documentai.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "documentai.googleapis.com:443" + assert client.transport._host == ("documentai.googleapis.com:443") -def test_document_understanding_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_document_understanding_service_host_with_port(transport_name): client = DocumentUnderstandingServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="documentai.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "documentai.googleapis.com:8000" + assert client.transport._host == ("documentai.googleapis.com:8000") def test_document_understanding_service_grpc_transport_channel(): diff --git a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py index e996223b..8b3dd42a 100644 --- a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py @@ -113,24 +113,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DocumentProcessorServiceClient, - DocumentProcessorServiceAsyncClient, + (DocumentProcessorServiceClient, "grpc"), + (DocumentProcessorServiceAsyncClient, "grpc_asyncio"), ], ) -def test_document_processor_service_client_from_service_account_info(client_class): +def test_document_processor_service_client_from_service_account_info( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "documentai.googleapis.com:443" + assert client.transport._host == ("documentai.googleapis.com:443") @pytest.mark.parametrize( @@ -159,27 +161,33 @@ def test_document_processor_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DocumentProcessorServiceClient, - DocumentProcessorServiceAsyncClient, + (DocumentProcessorServiceClient, "grpc"), + (DocumentProcessorServiceAsyncClient, "grpc_asyncio"), ], ) -def test_document_processor_service_client_from_service_account_file(client_class): +def test_document_processor_service_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "documentai.googleapis.com:443" + assert client.transport._host == ("documentai.googleapis.com:443") def test_document_processor_service_client_get_transport_class(): @@ -1776,7 +1784,7 @@ async def test_list_processors_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1822,7 +1830,9 @@ async def test_list_processors_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_processors(request={})).pages: + async for page_ in ( + await client.list_processors(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -2940,6 +2950,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = DocumentProcessorServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = DocumentProcessorServiceClient( @@ -2995,6 +3018,14 @@ def test_document_processor_service_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_document_processor_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -3144,24 +3175,40 @@ def test_document_processor_service_grpc_transport_client_cert_source_for_mtls( ) -def test_document_processor_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_document_processor_service_host_no_port(transport_name): client = DocumentProcessorServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="documentai.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "documentai.googleapis.com:443" + assert client.transport._host == ("documentai.googleapis.com:443") -def test_document_processor_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_document_processor_service_host_with_port(transport_name): client = DocumentProcessorServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="documentai.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "documentai.googleapis.com:8000" + assert client.transport._host == ("documentai.googleapis.com:8000") def test_document_processor_service_grpc_transport_channel(): From 22bd957b0041b98504d54dc04cf4700245a90fce Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 20:48:24 -0400 Subject: [PATCH 11/16] chore(python): add nox session to sort python imports (#312) Source-Link: https://github.com/googleapis/synthtool/commit/1b71c10e20de7ed3f97f692f99a0e3399b67049f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 4 +- docs/conf.py | 2 +- google/cloud/documentai/__init__.py | 45 +++++------- google/cloud/documentai_v1/__init__.py | 45 ++++++------ .../document_processor_service/__init__.py | 2 +- .../async_client.py | 13 ++-- .../document_processor_service/client.py | 11 +-- .../transports/__init__.py | 1 - .../transports/base.py | 9 ++- .../transports/grpc.py | 12 ++-- .../transports/grpc_asyncio.py | 12 ++-- google/cloud/documentai_v1/types/__init__.py | 14 +--- google/cloud/documentai_v1/types/document.py | 5 +- .../cloud/documentai_v1/types/document_io.py | 1 - .../types/document_processor_service.py | 8 +-- google/cloud/documentai_v1/types/geometry.py | 1 - .../documentai_v1/types/operation_metadata.py | 4 +- google/cloud/documentai_v1beta2/__init__.py | 41 ++++++----- .../__init__.py | 2 +- .../async_client.py | 13 ++-- .../document_understanding_service/client.py | 11 +-- .../transports/__init__.py | 1 - .../transports/base.py | 12 ++-- .../transports/grpc.py | 15 ++-- .../transports/grpc_asyncio.py | 15 ++-- .../documentai_v1beta2/types/__init__.py | 10 +-- .../documentai_v1beta2/types/document.py | 5 +- .../types/document_understanding.py | 3 +- .../documentai_v1beta2/types/geometry.py | 1 - google/cloud/documentai_v1beta3/__init__.py | 71 ++++++++++--------- .../document_processor_service/__init__.py | 2 +- .../async_client.py | 17 ++--- .../document_processor_service/client.py | 15 ++-- .../document_processor_service/pagers.py | 7 +- .../transports/__init__.py | 1 - .../transports/base.py | 9 ++- .../transports/grpc.py | 12 ++-- .../transports/grpc_asyncio.py | 12 ++-- .../documentai_v1beta3/types/__init__.py | 22 ++---- .../documentai_v1beta3/types/document.py | 5 +- .../documentai_v1beta3/types/document_io.py | 1 - .../types/document_processor_service.py | 8 +-- .../documentai_v1beta3/types/geometry.py | 1 - .../types/operation_metadata.py | 4 +- .../documentai_v1beta3/types/processor.py | 4 +- .../types/processor_type.py | 1 - noxfile.py | 28 +++++++- .../snippets/batch_parse_form_v1beta2_test.py | 3 - .../batch_parse_table_v1beta2_test.py | 3 - .../batch_process_documents_sample_test.py | 2 - samples/snippets/noxfile.py | 23 +++++- samples/snippets/parse_form_v1beta2_test.py | 1 - samples/snippets/parse_table_v1beta2_test.py | 1 - .../snippets/parse_with_model_v1beta2_test.py | 1 - .../process_document_form_sample_test.py | 1 - .../process_document_quality_sample_test.py | 1 - .../snippets/process_document_sample_test.py | 1 - ...rocess_document_specialized_sample_test.py | 1 - .../process_document_splitter_sample_test.py | 1 - samples/snippets/quickstart_v1beta2_test.py | 1 - samples/snippets/set_endpoint_v1beta2_test.py | 1 - setup.py | 1 + .../test_document_processor_service.py | 55 +++++++------- .../test_document_understanding_service.py | 51 +++++++------ .../test_document_processor_service.py | 65 +++++++++-------- 65 files changed, 355 insertions(+), 396 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index bc893c97..7c454abf 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 -# created: 2022-04-06T10:30:21.687684602Z + digest: sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 +# created: 2022-04-20T23:42:53.970438194Z diff --git a/docs/conf.py b/docs/conf.py index baf004e8..bc32283e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,9 +24,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os import shlex +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/google/cloud/documentai/__init__.py b/google/cloud/documentai/__init__.py index 0687f19b..13b35504 100644 --- a/google/cloud/documentai/__init__.py +++ b/google/cloud/documentai/__init__.py @@ -14,46 +14,37 @@ # limitations under the License. # -from google.cloud.documentai_v1.services.document_processor_service.client import ( - DocumentProcessorServiceClient, -) from google.cloud.documentai_v1.services.document_processor_service.async_client import ( DocumentProcessorServiceAsyncClient, ) - +from google.cloud.documentai_v1.services.document_processor_service.client import ( + DocumentProcessorServiceClient, +) from google.cloud.documentai_v1.types.document import Document -from google.cloud.documentai_v1.types.document_io import BatchDocumentsInputConfig -from google.cloud.documentai_v1.types.document_io import DocumentOutputConfig -from google.cloud.documentai_v1.types.document_io import GcsDocument -from google.cloud.documentai_v1.types.document_io import GcsDocuments -from google.cloud.documentai_v1.types.document_io import GcsPrefix -from google.cloud.documentai_v1.types.document_io import RawDocument -from google.cloud.documentai_v1.types.document_processor_service import ( - BatchProcessMetadata, +from google.cloud.documentai_v1.types.document_io import ( + BatchDocumentsInputConfig, + DocumentOutputConfig, + GcsDocument, + GcsDocuments, + GcsPrefix, + RawDocument, ) from google.cloud.documentai_v1.types.document_processor_service import ( + BatchProcessMetadata, BatchProcessRequest, -) -from google.cloud.documentai_v1.types.document_processor_service import ( BatchProcessResponse, -) -from google.cloud.documentai_v1.types.document_processor_service import ( HumanReviewStatus, -) -from google.cloud.documentai_v1.types.document_processor_service import ProcessRequest -from google.cloud.documentai_v1.types.document_processor_service import ProcessResponse -from google.cloud.documentai_v1.types.document_processor_service import ( + ProcessRequest, + ProcessResponse, ReviewDocumentOperationMetadata, -) -from google.cloud.documentai_v1.types.document_processor_service import ( ReviewDocumentRequest, -) -from google.cloud.documentai_v1.types.document_processor_service import ( ReviewDocumentResponse, ) -from google.cloud.documentai_v1.types.geometry import BoundingPoly -from google.cloud.documentai_v1.types.geometry import NormalizedVertex -from google.cloud.documentai_v1.types.geometry import Vertex +from google.cloud.documentai_v1.types.geometry import ( + BoundingPoly, + NormalizedVertex, + Vertex, +) from google.cloud.documentai_v1.types.operation_metadata import CommonOperationMetadata __all__ = ( diff --git a/google/cloud/documentai_v1/__init__.py b/google/cloud/documentai_v1/__init__.py index 2b683bd7..735cb126 100644 --- a/google/cloud/documentai_v1/__init__.py +++ b/google/cloud/documentai_v1/__init__.py @@ -14,28 +14,31 @@ # limitations under the License. # -from .services.document_processor_service import DocumentProcessorServiceClient -from .services.document_processor_service import DocumentProcessorServiceAsyncClient - +from .services.document_processor_service import ( + DocumentProcessorServiceAsyncClient, + DocumentProcessorServiceClient, +) from .types.document import Document -from .types.document_io import BatchDocumentsInputConfig -from .types.document_io import DocumentOutputConfig -from .types.document_io import GcsDocument -from .types.document_io import GcsDocuments -from .types.document_io import GcsPrefix -from .types.document_io import RawDocument -from .types.document_processor_service import BatchProcessMetadata -from .types.document_processor_service import BatchProcessRequest -from .types.document_processor_service import BatchProcessResponse -from .types.document_processor_service import HumanReviewStatus -from .types.document_processor_service import ProcessRequest -from .types.document_processor_service import ProcessResponse -from .types.document_processor_service import ReviewDocumentOperationMetadata -from .types.document_processor_service import ReviewDocumentRequest -from .types.document_processor_service import ReviewDocumentResponse -from .types.geometry import BoundingPoly -from .types.geometry import NormalizedVertex -from .types.geometry import Vertex +from .types.document_io import ( + BatchDocumentsInputConfig, + DocumentOutputConfig, + GcsDocument, + GcsDocuments, + GcsPrefix, + RawDocument, +) +from .types.document_processor_service import ( + BatchProcessMetadata, + BatchProcessRequest, + BatchProcessResponse, + HumanReviewStatus, + ProcessRequest, + ProcessResponse, + ReviewDocumentOperationMetadata, + ReviewDocumentRequest, + ReviewDocumentResponse, +) +from .types.geometry import BoundingPoly, NormalizedVertex, Vertex from .types.operation_metadata import CommonOperationMetadata __all__ = ( diff --git a/google/cloud/documentai_v1/services/document_processor_service/__init__.py b/google/cloud/documentai_v1/services/document_processor_service/__init__.py index d454baaa..a16bb495 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/__init__.py +++ b/google/cloud/documentai_v1/services/document_processor_service/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import DocumentProcessorServiceClient from .async_client import DocumentProcessorServiceAsyncClient +from .client import DocumentProcessorServiceClient __all__ = ( "DocumentProcessorServiceClient", diff --git a/google/cloud/documentai_v1/services/document_processor_service/async_client.py b/google/cloud/documentai_v1/services/document_processor_service/async_client.py index 0a2eae32..178f0ebb 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/async_client.py @@ -17,14 +17,14 @@ import functools import re from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -33,11 +33,12 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.documentai_v1.types import document -from google.cloud.documentai_v1.types import document_processor_service -from .transports.base import DocumentProcessorServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import DocumentProcessorServiceGrpcAsyncIOTransport + +from google.cloud.documentai_v1.types import document, document_processor_service + from .client import DocumentProcessorServiceClient +from .transports.base import DEFAULT_CLIENT_INFO, DocumentProcessorServiceTransport +from .transports.grpc_asyncio import DocumentProcessorServiceGrpcAsyncIOTransport class DocumentProcessorServiceAsyncClient: diff --git a/google/cloud/documentai_v1/services/document_processor_service/client.py b/google/cloud/documentai_v1/services/document_processor_service/client.py index 472fed92..be7729ba 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/client.py @@ -17,17 +17,17 @@ import os import re from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -36,9 +36,10 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.documentai_v1.types import document -from google.cloud.documentai_v1.types import document_processor_service -from .transports.base import DocumentProcessorServiceTransport, DEFAULT_CLIENT_INFO + +from google.cloud.documentai_v1.types import document, document_processor_service + +from .transports.base import DEFAULT_CLIENT_INFO, DocumentProcessorServiceTransport from .transports.grpc import DocumentProcessorServiceGrpcTransport from .transports.grpc_asyncio import DocumentProcessorServiceGrpcAsyncIOTransport diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/__init__.py b/google/cloud/documentai_v1/services/document_processor_service/transports/__init__.py index edfa7d68..e4955876 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/__init__.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import DocumentProcessorServiceGrpcTransport from .grpc_asyncio import DocumentProcessorServiceGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = ( OrderedDict() diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/base.py b/google/cloud/documentai_v1/services/document_processor_service/transports/base.py index 41f453b7..96dc7558 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/base.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/base.py @@ -15,19 +15,18 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, operations_v1 from google.api_core import retry as retries -from google.api_core import operations_v1 +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources from google.cloud.documentai_v1.types import document_processor_service -from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py index 15fd5ea2..445d30d3 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py @@ -13,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers, operations_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.documentai_v1.types import document_processor_service -from google.longrunning import operations_pb2 # type: ignore -from .base import DocumentProcessorServiceTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, DocumentProcessorServiceTransport class DocumentProcessorServiceGrpcTransport(DocumentProcessorServiceTransport): diff --git a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc_asyncio.py b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc_asyncio.py index 759c82fd..6d76af32 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/transports/grpc_asyncio.py +++ b/google/cloud/documentai_v1/services/document_processor_service/transports/grpc_asyncio.py @@ -13,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 +from google.api_core import gapic_v1, grpc_helpers_async, operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.documentai_v1.types import document_processor_service -from google.longrunning import operations_pb2 # type: ignore -from .base import DocumentProcessorServiceTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, DocumentProcessorServiceTransport from .grpc import DocumentProcessorServiceGrpcTransport diff --git a/google/cloud/documentai_v1/types/__init__.py b/google/cloud/documentai_v1/types/__init__.py index 10edbb6d..f1918d3f 100644 --- a/google/cloud/documentai_v1/types/__init__.py +++ b/google/cloud/documentai_v1/types/__init__.py @@ -13,9 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .document import ( - Document, -) +from .document import Document from .document_io import ( BatchDocumentsInputConfig, DocumentOutputConfig, @@ -35,14 +33,8 @@ ReviewDocumentRequest, ReviewDocumentResponse, ) -from .geometry import ( - BoundingPoly, - NormalizedVertex, - Vertex, -) -from .operation_metadata import ( - CommonOperationMetadata, -) +from .geometry import BoundingPoly, NormalizedVertex, Vertex +from .operation_metadata import CommonOperationMetadata __all__ = ( "Document", diff --git a/google/cloud/documentai_v1/types/document.py b/google/cloud/documentai_v1/types/document.py index a1ee8350..25b2cc21 100644 --- a/google/cloud/documentai_v1/types/document.py +++ b/google/cloud/documentai_v1/types/document.py @@ -13,9 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.documentai_v1.types import geometry from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore from google.type import color_pb2 # type: ignore @@ -23,7 +20,9 @@ from google.type import datetime_pb2 # type: ignore from google.type import money_pb2 # type: ignore from google.type import postal_address_pb2 # type: ignore +import proto # type: ignore +from google.cloud.documentai_v1.types import geometry __protobuf__ = proto.module( package="google.cloud.documentai.v1", diff --git a/google/cloud/documentai_v1/types/document_io.py b/google/cloud/documentai_v1/types/document_io.py index cb8bc982..a5d5e69e 100644 --- a/google/cloud/documentai_v1/types/document_io.py +++ b/google/cloud/documentai_v1/types/document_io.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.documentai.v1", manifest={ diff --git a/google/cloud/documentai_v1/types/document_processor_service.py b/google/cloud/documentai_v1/types/document_processor_service.py index 44c6a781..8ebe0d46 100644 --- a/google/cloud/documentai_v1/types/document_processor_service.py +++ b/google/cloud/documentai_v1/types/document_processor_service.py @@ -13,14 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.documentai_v1.types import document as gcd_document -from google.cloud.documentai_v1.types import document_io -from google.cloud.documentai_v1.types import operation_metadata from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore +import proto # type: ignore +from google.cloud.documentai_v1.types import document as gcd_document +from google.cloud.documentai_v1.types import document_io, operation_metadata __protobuf__ = proto.module( package="google.cloud.documentai.v1", diff --git a/google/cloud/documentai_v1/types/geometry.py b/google/cloud/documentai_v1/types/geometry.py index 3d0c665a..4794fcda 100644 --- a/google/cloud/documentai_v1/types/geometry.py +++ b/google/cloud/documentai_v1/types/geometry.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.documentai.v1", manifest={ diff --git a/google/cloud/documentai_v1/types/operation_metadata.py b/google/cloud/documentai_v1/types/operation_metadata.py index e6037b71..d207bde3 100644 --- a/google/cloud/documentai_v1/types/operation_metadata.py +++ b/google/cloud/documentai_v1/types/operation_metadata.py @@ -13,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - from google.protobuf import timestamp_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( package="google.cloud.documentai.v1", diff --git a/google/cloud/documentai_v1beta2/__init__.py b/google/cloud/documentai_v1beta2/__init__.py index f73206c8..8d12c25c 100644 --- a/google/cloud/documentai_v1beta2/__init__.py +++ b/google/cloud/documentai_v1beta2/__init__.py @@ -14,31 +14,30 @@ # limitations under the License. # -from .services.document_understanding_service import DocumentUnderstandingServiceClient from .services.document_understanding_service import ( DocumentUnderstandingServiceAsyncClient, + DocumentUnderstandingServiceClient, ) - from .types.document import Document -from .types.document_understanding import AutoMlParams -from .types.document_understanding import BatchProcessDocumentsRequest -from .types.document_understanding import BatchProcessDocumentsResponse -from .types.document_understanding import EntityExtractionParams -from .types.document_understanding import FormExtractionParams -from .types.document_understanding import GcsDestination -from .types.document_understanding import GcsSource -from .types.document_understanding import InputConfig -from .types.document_understanding import KeyValuePairHint -from .types.document_understanding import OcrParams -from .types.document_understanding import OperationMetadata -from .types.document_understanding import OutputConfig -from .types.document_understanding import ProcessDocumentRequest -from .types.document_understanding import ProcessDocumentResponse -from .types.document_understanding import TableBoundHint -from .types.document_understanding import TableExtractionParams -from .types.geometry import BoundingPoly -from .types.geometry import NormalizedVertex -from .types.geometry import Vertex +from .types.document_understanding import ( + AutoMlParams, + BatchProcessDocumentsRequest, + BatchProcessDocumentsResponse, + EntityExtractionParams, + FormExtractionParams, + GcsDestination, + GcsSource, + InputConfig, + KeyValuePairHint, + OcrParams, + OperationMetadata, + OutputConfig, + ProcessDocumentRequest, + ProcessDocumentResponse, + TableBoundHint, + TableExtractionParams, +) +from .types.geometry import BoundingPoly, NormalizedVertex, Vertex __all__ = ( "DocumentUnderstandingServiceAsyncClient", diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/__init__.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/__init__.py index 17f69842..223bdbd2 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/__init__.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import DocumentUnderstandingServiceClient from .async_client import DocumentUnderstandingServiceAsyncClient +from .client import DocumentUnderstandingServiceClient __all__ = ( "DocumentUnderstandingServiceClient", diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py index 31386906..7a59f55b 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py @@ -17,14 +17,14 @@ import functools import re from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -33,12 +33,13 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.documentai_v1beta2.types import document -from google.cloud.documentai_v1beta2.types import document_understanding from google.rpc import status_pb2 # type: ignore -from .transports.base import DocumentUnderstandingServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import DocumentUnderstandingServiceGrpcAsyncIOTransport + +from google.cloud.documentai_v1beta2.types import document, document_understanding + from .client import DocumentUnderstandingServiceClient +from .transports.base import DEFAULT_CLIENT_INFO, DocumentUnderstandingServiceTransport +from .transports.grpc_asyncio import DocumentUnderstandingServiceGrpcAsyncIOTransport class DocumentUnderstandingServiceAsyncClient: diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py index edd95067..65902516 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py @@ -17,17 +17,17 @@ import os import re from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -36,10 +36,11 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.documentai_v1beta2.types import document -from google.cloud.documentai_v1beta2.types import document_understanding from google.rpc import status_pb2 # type: ignore -from .transports.base import DocumentUnderstandingServiceTransport, DEFAULT_CLIENT_INFO + +from google.cloud.documentai_v1beta2.types import document, document_understanding + +from .transports.base import DEFAULT_CLIENT_INFO, DocumentUnderstandingServiceTransport from .transports.grpc import DocumentUnderstandingServiceGrpcTransport from .transports.grpc_asyncio import DocumentUnderstandingServiceGrpcAsyncIOTransport diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/__init__.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/__init__.py index c4d38059..07aaeb7c 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/__init__.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import DocumentUnderstandingServiceGrpcTransport from .grpc_asyncio import DocumentUnderstandingServiceGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = ( OrderedDict() diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py index 096e7dae..db46f8b6 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py @@ -15,20 +15,18 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, operations_v1 from google.api_core import retry as retries -from google.api_core import operations_v1 +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources -from google.cloud.documentai_v1beta2.types import document -from google.cloud.documentai_v1beta2.types import document_understanding -from google.longrunning import operations_pb2 # type: ignore +from google.cloud.documentai_v1beta2.types import document, document_understanding try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py index 6ff7a880..cee76f48 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py @@ -13,22 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers, operations_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore -from google.cloud.documentai_v1beta2.types import document -from google.cloud.documentai_v1beta2.types import document_understanding -from google.longrunning import operations_pb2 # type: ignore -from .base import DocumentUnderstandingServiceTransport, DEFAULT_CLIENT_INFO +from google.cloud.documentai_v1beta2.types import document, document_understanding + +from .base import DEFAULT_CLIENT_INFO, DocumentUnderstandingServiceTransport class DocumentUnderstandingServiceGrpcTransport(DocumentUnderstandingServiceTransport): diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc_asyncio.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc_asyncio.py index 82d18beb..0633f38b 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc_asyncio.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc_asyncio.py @@ -13,22 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 +from google.api_core import gapic_v1, grpc_helpers_async, operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore -from google.cloud.documentai_v1beta2.types import document -from google.cloud.documentai_v1beta2.types import document_understanding -from google.longrunning import operations_pb2 # type: ignore -from .base import DocumentUnderstandingServiceTransport, DEFAULT_CLIENT_INFO +from google.cloud.documentai_v1beta2.types import document, document_understanding + +from .base import DEFAULT_CLIENT_INFO, DocumentUnderstandingServiceTransport from .grpc import DocumentUnderstandingServiceGrpcTransport diff --git a/google/cloud/documentai_v1beta2/types/__init__.py b/google/cloud/documentai_v1beta2/types/__init__.py index 7a26ae1f..27b50c0d 100644 --- a/google/cloud/documentai_v1beta2/types/__init__.py +++ b/google/cloud/documentai_v1beta2/types/__init__.py @@ -13,9 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .document import ( - Document, -) +from .document import Document from .document_understanding import ( AutoMlParams, BatchProcessDocumentsRequest, @@ -34,11 +32,7 @@ TableBoundHint, TableExtractionParams, ) -from .geometry import ( - BoundingPoly, - NormalizedVertex, - Vertex, -) +from .geometry import BoundingPoly, NormalizedVertex, Vertex __all__ = ( "Document", diff --git a/google/cloud/documentai_v1beta2/types/document.py b/google/cloud/documentai_v1beta2/types/document.py index 5c425ffe..4a10f97f 100644 --- a/google/cloud/documentai_v1beta2/types/document.py +++ b/google/cloud/documentai_v1beta2/types/document.py @@ -13,12 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.documentai_v1beta2.types import geometry from google.rpc import status_pb2 # type: ignore from google.type import color_pb2 # type: ignore +import proto # type: ignore +from google.cloud.documentai_v1beta2.types import geometry __protobuf__ = proto.module( package="google.cloud.documentai.v1beta2", diff --git a/google/cloud/documentai_v1beta2/types/document_understanding.py b/google/cloud/documentai_v1beta2/types/document_understanding.py index e655eabd..ddf0e80e 100644 --- a/google/cloud/documentai_v1beta2/types/document_understanding.py +++ b/google/cloud/documentai_v1beta2/types/document_understanding.py @@ -13,11 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore from google.cloud.documentai_v1beta2.types import geometry -from google.protobuf import timestamp_pb2 # type: ignore - __protobuf__ = proto.module( package="google.cloud.documentai.v1beta2", diff --git a/google/cloud/documentai_v1beta2/types/geometry.py b/google/cloud/documentai_v1beta2/types/geometry.py index 6f983474..b5e2b887 100644 --- a/google/cloud/documentai_v1beta2/types/geometry.py +++ b/google/cloud/documentai_v1beta2/types/geometry.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.documentai.v1beta2", manifest={ diff --git a/google/cloud/documentai_v1beta3/__init__.py b/google/cloud/documentai_v1beta3/__init__.py index 06ce2fce..acb85bdc 100644 --- a/google/cloud/documentai_v1beta3/__init__.py +++ b/google/cloud/documentai_v1beta3/__init__.py @@ -14,41 +14,44 @@ # limitations under the License. # -from .services.document_processor_service import DocumentProcessorServiceClient -from .services.document_processor_service import DocumentProcessorServiceAsyncClient - +from .services.document_processor_service import ( + DocumentProcessorServiceAsyncClient, + DocumentProcessorServiceClient, +) from .types.document import Document -from .types.document_io import BatchDocumentsInputConfig -from .types.document_io import DocumentOutputConfig -from .types.document_io import GcsDocument -from .types.document_io import GcsDocuments -from .types.document_io import GcsPrefix -from .types.document_io import RawDocument -from .types.document_processor_service import BatchProcessMetadata -from .types.document_processor_service import BatchProcessRequest -from .types.document_processor_service import BatchProcessResponse -from .types.document_processor_service import CreateProcessorRequest -from .types.document_processor_service import DeleteProcessorMetadata -from .types.document_processor_service import DeleteProcessorRequest -from .types.document_processor_service import DisableProcessorMetadata -from .types.document_processor_service import DisableProcessorRequest -from .types.document_processor_service import DisableProcessorResponse -from .types.document_processor_service import EnableProcessorMetadata -from .types.document_processor_service import EnableProcessorRequest -from .types.document_processor_service import EnableProcessorResponse -from .types.document_processor_service import FetchProcessorTypesRequest -from .types.document_processor_service import FetchProcessorTypesResponse -from .types.document_processor_service import HumanReviewStatus -from .types.document_processor_service import ListProcessorsRequest -from .types.document_processor_service import ListProcessorsResponse -from .types.document_processor_service import ProcessRequest -from .types.document_processor_service import ProcessResponse -from .types.document_processor_service import ReviewDocumentOperationMetadata -from .types.document_processor_service import ReviewDocumentRequest -from .types.document_processor_service import ReviewDocumentResponse -from .types.geometry import BoundingPoly -from .types.geometry import NormalizedVertex -from .types.geometry import Vertex +from .types.document_io import ( + BatchDocumentsInputConfig, + DocumentOutputConfig, + GcsDocument, + GcsDocuments, + GcsPrefix, + RawDocument, +) +from .types.document_processor_service import ( + BatchProcessMetadata, + BatchProcessRequest, + BatchProcessResponse, + CreateProcessorRequest, + DeleteProcessorMetadata, + DeleteProcessorRequest, + DisableProcessorMetadata, + DisableProcessorRequest, + DisableProcessorResponse, + EnableProcessorMetadata, + EnableProcessorRequest, + EnableProcessorResponse, + FetchProcessorTypesRequest, + FetchProcessorTypesResponse, + HumanReviewStatus, + ListProcessorsRequest, + ListProcessorsResponse, + ProcessRequest, + ProcessResponse, + ReviewDocumentOperationMetadata, + ReviewDocumentRequest, + ReviewDocumentResponse, +) +from .types.geometry import BoundingPoly, NormalizedVertex, Vertex from .types.operation_metadata import CommonOperationMetadata from .types.processor import Processor from .types.processor_type import ProcessorType diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/__init__.py b/google/cloud/documentai_v1beta3/services/document_processor_service/__init__.py index d454baaa..a16bb495 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/__init__.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import DocumentProcessorServiceClient from .async_client import DocumentProcessorServiceAsyncClient +from .client import DocumentProcessorServiceClient __all__ = ( "DocumentProcessorServiceClient", diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py index f7a9cdf3..e178f44e 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py @@ -17,14 +17,14 @@ import functools import re from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -33,17 +33,18 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + from google.cloud.documentai_v1beta3.services.document_processor_service import pagers -from google.cloud.documentai_v1beta3.types import document -from google.cloud.documentai_v1beta3.types import document_processor_service +from google.cloud.documentai_v1beta3.types import document, document_processor_service from google.cloud.documentai_v1beta3.types import processor from google.cloud.documentai_v1beta3.types import processor as gcd_processor from google.cloud.documentai_v1beta3.types import processor_type -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import DocumentProcessorServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import DocumentProcessorServiceGrpcAsyncIOTransport + from .client import DocumentProcessorServiceClient +from .transports.base import DEFAULT_CLIENT_INFO, DocumentProcessorServiceTransport +from .transports.grpc_asyncio import DocumentProcessorServiceGrpcAsyncIOTransport class DocumentProcessorServiceAsyncClient: diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py index c4337919..6d6fb5da 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py @@ -17,17 +17,17 @@ import os import re from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -36,15 +36,16 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + from google.cloud.documentai_v1beta3.services.document_processor_service import pagers -from google.cloud.documentai_v1beta3.types import document -from google.cloud.documentai_v1beta3.types import document_processor_service +from google.cloud.documentai_v1beta3.types import document, document_processor_service from google.cloud.documentai_v1beta3.types import processor from google.cloud.documentai_v1beta3.types import processor as gcd_processor from google.cloud.documentai_v1beta3.types import processor_type -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import DocumentProcessorServiceTransport, DEFAULT_CLIENT_INFO + +from .transports.base import DEFAULT_CLIENT_INFO, DocumentProcessorServiceTransport from .transports.grpc import DocumentProcessorServiceGrpcTransport from .transports.grpc_asyncio import DocumentProcessorServiceGrpcAsyncIOTransport diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/pagers.py b/google/cloud/documentai_v1beta3/services/document_processor_service/pagers.py index 6f1a2e48..d2a145a4 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/pagers.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/pagers.py @@ -18,14 +18,13 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) -from google.cloud.documentai_v1beta3.types import document_processor_service -from google.cloud.documentai_v1beta3.types import processor +from google.cloud.documentai_v1beta3.types import document_processor_service, processor class ListProcessorsPager: diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/__init__.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/__init__.py index edfa7d68..e4955876 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/__init__.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import DocumentProcessorServiceGrpcTransport from .grpc_asyncio import DocumentProcessorServiceGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = ( OrderedDict() diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py index 541e713b..43945a98 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py @@ -15,20 +15,19 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, operations_v1 from google.api_core import retry as retries -from google.api_core import operations_v1 +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources from google.cloud.documentai_v1beta3.types import document_processor_service from google.cloud.documentai_v1beta3.types import processor as gcd_processor -from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py index a84d7fb2..6b7426a0 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py @@ -13,22 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers, operations_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.documentai_v1beta3.types import document_processor_service from google.cloud.documentai_v1beta3.types import processor as gcd_processor -from google.longrunning import operations_pb2 # type: ignore -from .base import DocumentProcessorServiceTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, DocumentProcessorServiceTransport class DocumentProcessorServiceGrpcTransport(DocumentProcessorServiceTransport): diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py index 0dc5696e..e9632828 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py @@ -13,22 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 +from google.api_core import gapic_v1, grpc_helpers_async, operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.documentai_v1beta3.types import document_processor_service from google.cloud.documentai_v1beta3.types import processor as gcd_processor -from google.longrunning import operations_pb2 # type: ignore -from .base import DocumentProcessorServiceTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, DocumentProcessorServiceTransport from .grpc import DocumentProcessorServiceGrpcTransport diff --git a/google/cloud/documentai_v1beta3/types/__init__.py b/google/cloud/documentai_v1beta3/types/__init__.py index 9f91420d..6a5a9076 100644 --- a/google/cloud/documentai_v1beta3/types/__init__.py +++ b/google/cloud/documentai_v1beta3/types/__init__.py @@ -13,9 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .document import ( - Document, -) +from .document import Document from .document_io import ( BatchDocumentsInputConfig, DocumentOutputConfig, @@ -48,20 +46,10 @@ ReviewDocumentRequest, ReviewDocumentResponse, ) -from .geometry import ( - BoundingPoly, - NormalizedVertex, - Vertex, -) -from .operation_metadata import ( - CommonOperationMetadata, -) -from .processor import ( - Processor, -) -from .processor_type import ( - ProcessorType, -) +from .geometry import BoundingPoly, NormalizedVertex, Vertex +from .operation_metadata import CommonOperationMetadata +from .processor import Processor +from .processor_type import ProcessorType __all__ = ( "Document", diff --git a/google/cloud/documentai_v1beta3/types/document.py b/google/cloud/documentai_v1beta3/types/document.py index a963ffb0..b7d0a56d 100644 --- a/google/cloud/documentai_v1beta3/types/document.py +++ b/google/cloud/documentai_v1beta3/types/document.py @@ -13,9 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.documentai_v1beta3.types import geometry from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore from google.type import color_pb2 # type: ignore @@ -23,7 +20,9 @@ from google.type import datetime_pb2 # type: ignore from google.type import money_pb2 # type: ignore from google.type import postal_address_pb2 # type: ignore +import proto # type: ignore +from google.cloud.documentai_v1beta3.types import geometry __protobuf__ = proto.module( package="google.cloud.documentai.v1beta3", diff --git a/google/cloud/documentai_v1beta3/types/document_io.py b/google/cloud/documentai_v1beta3/types/document_io.py index cec64bbe..2fe7f436 100644 --- a/google/cloud/documentai_v1beta3/types/document_io.py +++ b/google/cloud/documentai_v1beta3/types/document_io.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.documentai.v1beta3", manifest={ diff --git a/google/cloud/documentai_v1beta3/types/document_processor_service.py b/google/cloud/documentai_v1beta3/types/document_processor_service.py index 67e2c41d..98bee9fe 100644 --- a/google/cloud/documentai_v1beta3/types/document_processor_service.py +++ b/google/cloud/documentai_v1beta3/types/document_processor_service.py @@ -13,16 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore import proto # type: ignore +from google.cloud.documentai_v1beta3.types import document_io, operation_metadata from google.cloud.documentai_v1beta3.types import document as gcd_document -from google.cloud.documentai_v1beta3.types import document_io -from google.cloud.documentai_v1beta3.types import operation_metadata from google.cloud.documentai_v1beta3.types import processor as gcd_processor from google.cloud.documentai_v1beta3.types import processor_type -from google.protobuf import timestamp_pb2 # type: ignore -from google.rpc import status_pb2 # type: ignore - __protobuf__ = proto.module( package="google.cloud.documentai.v1beta3", diff --git a/google/cloud/documentai_v1beta3/types/geometry.py b/google/cloud/documentai_v1beta3/types/geometry.py index c0d94568..2add8a91 100644 --- a/google/cloud/documentai_v1beta3/types/geometry.py +++ b/google/cloud/documentai_v1beta3/types/geometry.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.documentai.v1beta3", manifest={ diff --git a/google/cloud/documentai_v1beta3/types/operation_metadata.py b/google/cloud/documentai_v1beta3/types/operation_metadata.py index fdd32619..6ea500e2 100644 --- a/google/cloud/documentai_v1beta3/types/operation_metadata.py +++ b/google/cloud/documentai_v1beta3/types/operation_metadata.py @@ -13,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - from google.protobuf import timestamp_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( package="google.cloud.documentai.v1beta3", diff --git a/google/cloud/documentai_v1beta3/types/processor.py b/google/cloud/documentai_v1beta3/types/processor.py index ad801491..2a098537 100644 --- a/google/cloud/documentai_v1beta3/types/processor.py +++ b/google/cloud/documentai_v1beta3/types/processor.py @@ -13,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - from google.protobuf import timestamp_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( package="google.cloud.documentai.v1beta3", diff --git a/google/cloud/documentai_v1beta3/types/processor_type.py b/google/cloud/documentai_v1beta3/types/processor_type.py index 8df603a3..be0a2b8e 100644 --- a/google/cloud/documentai_v1beta3/types/processor_type.py +++ b/google/cloud/documentai_v1beta3/types/processor_type.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.documentai.v1beta3", manifest={ diff --git a/noxfile.py b/noxfile.py index 6ee5e8ab..7c1742d2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,6 +17,7 @@ # Generated by synthtool. DO NOT EDIT! from __future__ import absolute_import + import os import pathlib import shutil @@ -25,7 +26,8 @@ import nox BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -83,7 +85,7 @@ def lint(session): session.run( "black", "--check", - *BLACK_PATHS, + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -94,7 +96,27 @@ def blacken(session): session.install(BLACK_VERSION) session.run( "black", - *BLACK_PATHS, + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) diff --git a/samples/snippets/batch_parse_form_v1beta2_test.py b/samples/snippets/batch_parse_form_v1beta2_test.py index f42cb249..c4bad1ad 100644 --- a/samples/snippets/batch_parse_form_v1beta2_test.py +++ b/samples/snippets/batch_parse_form_v1beta2_test.py @@ -16,12 +16,9 @@ import uuid from google.cloud import storage - import pytest - from samples.snippets import batch_parse_form_v1beta2 - BUCKET = "document-ai-{}".format(uuid.uuid4()) OUTPUT_PREFIX = "TEST_OUTPUT_{}".format(uuid.uuid4()) PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] diff --git a/samples/snippets/batch_parse_table_v1beta2_test.py b/samples/snippets/batch_parse_table_v1beta2_test.py index 0818d8c0..faf26856 100644 --- a/samples/snippets/batch_parse_table_v1beta2_test.py +++ b/samples/snippets/batch_parse_table_v1beta2_test.py @@ -16,12 +16,9 @@ import uuid from google.cloud import storage - import pytest - from samples.snippets import batch_parse_table_v1beta2 - BUCKET = "document-ai-{}".format(uuid.uuid4()) OUTPUT_PREFIX = "TEST_OUTPUT_{}".format(uuid.uuid4()) PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] diff --git a/samples/snippets/batch_process_documents_sample_test.py b/samples/snippets/batch_process_documents_sample_test.py index 7168d5a7..d3018fb6 100644 --- a/samples/snippets/batch_process_documents_sample_test.py +++ b/samples/snippets/batch_process_documents_sample_test.py @@ -18,9 +18,7 @@ from google.cloud import storage from google.cloud.exceptions import NotFound - import pytest - from samples.snippets import batch_process_documents_sample location = "us" diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 25f87a21..3b3ffa5d 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -22,7 +22,6 @@ import nox - # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING # DO NOT EDIT THIS FILE EVER! @@ -30,6 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -168,12 +168,33 @@ def lint(session: nox.sessions.Session) -> None: @nox.session def blacken(session: nox.sessions.Session) -> None: + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) python_files = [path for path in os.listdir(".") if path.endswith(".py")] session.run("black", *python_files) +# +# format = isort + black +# + + +@nox.session +def format(session: nox.sessions.Session) -> None: + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run("isort", "--fss", *python_files) + session.run("black", *python_files) + + # # Sample Tests # diff --git a/samples/snippets/parse_form_v1beta2_test.py b/samples/snippets/parse_form_v1beta2_test.py index 6987612a..c2b33eec 100644 --- a/samples/snippets/parse_form_v1beta2_test.py +++ b/samples/snippets/parse_form_v1beta2_test.py @@ -16,7 +16,6 @@ from samples.snippets import parse_form_v1beta2 - PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] INPUT_URI = "gs://cloud-samples-data/documentai/form.pdf" diff --git a/samples/snippets/parse_table_v1beta2_test.py b/samples/snippets/parse_table_v1beta2_test.py index 4102c926..f59e9a82 100644 --- a/samples/snippets/parse_table_v1beta2_test.py +++ b/samples/snippets/parse_table_v1beta2_test.py @@ -16,7 +16,6 @@ from samples.snippets import parse_table_v1beta2 - PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" diff --git a/samples/snippets/parse_with_model_v1beta2_test.py b/samples/snippets/parse_with_model_v1beta2_test.py index 4b5d3ca5..e3934b65 100644 --- a/samples/snippets/parse_with_model_v1beta2_test.py +++ b/samples/snippets/parse_with_model_v1beta2_test.py @@ -16,7 +16,6 @@ from samples.snippets import parse_with_model_v1beta2 - PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" AUTOML_NL_MODEL_ID = "TCN3472481026502981088" diff --git a/samples/snippets/process_document_form_sample_test.py b/samples/snippets/process_document_form_sample_test.py index da76d6d0..38f722de 100644 --- a/samples/snippets/process_document_form_sample_test.py +++ b/samples/snippets/process_document_form_sample_test.py @@ -17,7 +17,6 @@ from samples.snippets import process_document_form_sample - location = "us" project_id = os.environ["GOOGLE_CLOUD_PROJECT"] processor_id = "90484cfdedb024f6" diff --git a/samples/snippets/process_document_quality_sample_test.py b/samples/snippets/process_document_quality_sample_test.py index b025756e..a0dc52cb 100644 --- a/samples/snippets/process_document_quality_sample_test.py +++ b/samples/snippets/process_document_quality_sample_test.py @@ -17,7 +17,6 @@ from samples.snippets import process_document_quality_sample - location = "us" project_id = os.environ["GOOGLE_CLOUD_PROJECT"] processor_id = "7fcb597c523721b3" diff --git a/samples/snippets/process_document_sample_test.py b/samples/snippets/process_document_sample_test.py index 8fe188d8..48dce8bb 100644 --- a/samples/snippets/process_document_sample_test.py +++ b/samples/snippets/process_document_sample_test.py @@ -17,7 +17,6 @@ from samples.snippets import process_document_sample - location = "us" project_id = os.environ["GOOGLE_CLOUD_PROJECT"] processor_id = "90484cfdedb024f6" diff --git a/samples/snippets/process_document_specialized_sample_test.py b/samples/snippets/process_document_specialized_sample_test.py index 04a7abec..a3156c96 100644 --- a/samples/snippets/process_document_specialized_sample_test.py +++ b/samples/snippets/process_document_specialized_sample_test.py @@ -17,7 +17,6 @@ from samples.snippets import process_document_specialized_sample - location = "us" project_id = os.environ["GOOGLE_CLOUD_PROJECT"] processor_id = "feacd98c28866ede" diff --git a/samples/snippets/process_document_splitter_sample_test.py b/samples/snippets/process_document_splitter_sample_test.py index df0baf26..575edf60 100644 --- a/samples/snippets/process_document_splitter_sample_test.py +++ b/samples/snippets/process_document_splitter_sample_test.py @@ -17,7 +17,6 @@ from samples.snippets import process_document_splitter_sample - location = "us" project_id = os.environ["GOOGLE_CLOUD_PROJECT"] processor_id = "ed55eeb2b276066f" diff --git a/samples/snippets/quickstart_v1beta2_test.py b/samples/snippets/quickstart_v1beta2_test.py index 1868788d..8467b53e 100644 --- a/samples/snippets/quickstart_v1beta2_test.py +++ b/samples/snippets/quickstart_v1beta2_test.py @@ -16,7 +16,6 @@ from samples.snippets import quickstart_v1beta2 - PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" diff --git a/samples/snippets/set_endpoint_v1beta2_test.py b/samples/snippets/set_endpoint_v1beta2_test.py index be535a28..b9811155 100644 --- a/samples/snippets/set_endpoint_v1beta2_test.py +++ b/samples/snippets/set_endpoint_v1beta2_test.py @@ -16,7 +16,6 @@ from samples.snippets import set_endpoint_v1beta2 - PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" diff --git a/setup.py b/setup.py index 0cb82f8d..6895b76a 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ import io import os + import setuptools # type: ignore version = "1.4.0" diff --git a/tests/unit/gapic/documentai_v1/test_document_processor_service.py b/tests/unit/gapic/documentai_v1/test_document_processor_service.py index 98e42976..500f5a4b 100644 --- a/tests/unit/gapic/documentai_v1/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1/test_document_processor_service.py @@ -13,39 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os -import mock - -import grpc -from grpc.experimental import aio import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - +import os +from google.api_core import ( + future, + gapic_v1, + grpc_helpers, + grpc_helpers_async, + operation, + operations_v1, + path_template, +) from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.documentai_v1.services.document_processor_service import ( - DocumentProcessorServiceAsyncClient, -) -from google.cloud.documentai_v1.services.document_processor_service import ( - DocumentProcessorServiceClient, -) -from google.cloud.documentai_v1.services.document_processor_service import transports -from google.cloud.documentai_v1.types import document -from google.cloud.documentai_v1.types import document_io -from google.cloud.documentai_v1.types import document_processor_service -from google.cloud.documentai_v1.types import geometry from google.longrunning import operations_pb2 from google.oauth2 import service_account from google.protobuf import any_pb2 # type: ignore @@ -58,7 +43,23 @@ from google.type import datetime_pb2 # type: ignore from google.type import money_pb2 # type: ignore from google.type import postal_address_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.documentai_v1.services.document_processor_service import ( + DocumentProcessorServiceAsyncClient, + DocumentProcessorServiceClient, + transports, +) +from google.cloud.documentai_v1.types import ( + document, + document_io, + document_processor_service, + geometry, +) def client_cert_source_callback(): diff --git a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py index 33eabf06..119469ce 100644 --- a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py +++ b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py @@ -13,44 +13,43 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os -import mock - -import grpc -from grpc.experimental import aio import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - +import os +from google.api_core import ( + future, + gapic_v1, + grpc_helpers, + grpc_helpers_async, + operation, + operations_v1, + path_template, +) from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.rpc import status_pb2 # type: ignore +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + from google.cloud.documentai_v1beta2.services.document_understanding_service import ( DocumentUnderstandingServiceAsyncClient, -) -from google.cloud.documentai_v1beta2.services.document_understanding_service import ( DocumentUnderstandingServiceClient, -) -from google.cloud.documentai_v1beta2.services.document_understanding_service import ( transports, ) -from google.cloud.documentai_v1beta2.types import document -from google.cloud.documentai_v1beta2.types import document_understanding -from google.cloud.documentai_v1beta2.types import geometry -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.rpc import status_pb2 # type: ignore -import google.auth +from google.cloud.documentai_v1beta2.types import ( + document, + document_understanding, + geometry, +) def client_cert_source_callback(): diff --git a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py index 8b3dd42a..5126618a 100644 --- a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py @@ -13,45 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os -import mock - -import grpc -from grpc.experimental import aio import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - +import os +from google.api_core import ( + future, + gapic_v1, + grpc_helpers, + grpc_helpers_async, + operation, + operations_v1, + path_template, +) from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.documentai_v1beta3.services.document_processor_service import ( - DocumentProcessorServiceAsyncClient, -) -from google.cloud.documentai_v1beta3.services.document_processor_service import ( - DocumentProcessorServiceClient, -) -from google.cloud.documentai_v1beta3.services.document_processor_service import pagers -from google.cloud.documentai_v1beta3.services.document_processor_service import ( - transports, -) -from google.cloud.documentai_v1beta3.types import document -from google.cloud.documentai_v1beta3.types import document_io -from google.cloud.documentai_v1beta3.types import document_processor_service -from google.cloud.documentai_v1beta3.types import geometry -from google.cloud.documentai_v1beta3.types import processor -from google.cloud.documentai_v1beta3.types import processor as gcd_processor -from google.cloud.documentai_v1beta3.types import processor_type from google.longrunning import operations_pb2 from google.oauth2 import service_account from google.protobuf import any_pb2 # type: ignore @@ -64,7 +43,27 @@ from google.type import datetime_pb2 # type: ignore from google.type import money_pb2 # type: ignore from google.type import postal_address_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.documentai_v1beta3.services.document_processor_service import ( + DocumentProcessorServiceAsyncClient, + DocumentProcessorServiceClient, + pagers, + transports, +) +from google.cloud.documentai_v1beta3.types import ( + document, + document_io, + document_processor_service, + geometry, +) +from google.cloud.documentai_v1beta3.types import processor +from google.cloud.documentai_v1beta3.types import processor as gcd_processor +from google.cloud.documentai_v1beta3.types import processor_type def client_cert_source_callback(): From 27c1f01b5c2610b08fc47c8c5b6bf53ba7a56565 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 16:10:17 +0000 Subject: [PATCH 12/16] chore(python): use ubuntu 22.04 in docs image (#314) Source-Link: https://github.com/googleapis/synthtool/commit/f15cc72fb401b4861cedebb10af74afe428fb1f8 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd --- .github/.OwlBot.lock.yaml | 4 ++-- .kokoro/docker/docs/Dockerfile | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7c454abf..64f82d6b 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 -# created: 2022-04-20T23:42:53.970438194Z + digest: sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd +# created: 2022-04-21T15:43:16.246106921Z diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb8..238b87b9 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] From 1a04b9d329edf561ac173cb5fdd984d77c8ce71e Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 25 Apr 2022 17:03:01 +0200 Subject: [PATCH 13/16] chore(deps): update dependency pytest to v7.1.2 (#316) --- samples/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index 4f6bf643..d00689e0 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1 +1 @@ -pytest==7.1.1 +pytest==7.1.2 From eb30549db48b83fad5d1d39c3937108d15ffbf9b Mon Sep 17 00:00:00 2001 From: Gal Zahavi <38544478+galz10@users.noreply.github.com> Date: Tue, 26 Apr 2022 09:22:44 -0700 Subject: [PATCH 14/16] chore: removed v1beta2 samples (#315) --- samples/snippets/batch_parse_form_v1beta2.py | 100 ---------------- .../snippets/batch_parse_form_v1beta2_test.py | 45 -------- samples/snippets/batch_parse_table_v1beta2.py | 108 ------------------ .../batch_parse_table_v1beta2_test.py | 45 -------- samples/snippets/parse_form_v1beta2.py | 92 --------------- samples/snippets/parse_form_v1beta2_test.py | 27 ----- samples/snippets/parse_table_v1beta2.py | 95 --------------- samples/snippets/parse_table_v1beta2_test.py | 27 ----- samples/snippets/parse_with_model_v1beta2.py | 60 ---------- .../snippets/parse_with_model_v1beta2_test.py | 35 ------ samples/snippets/quickstart_v1beta2.py | 65 ----------- samples/snippets/quickstart_v1beta2_test.py | 27 ----- samples/snippets/set_endpoint_v1beta2.py | 48 -------- samples/snippets/set_endpoint_v1beta2_test.py | 26 ----- 14 files changed, 800 deletions(-) delete mode 100644 samples/snippets/batch_parse_form_v1beta2.py delete mode 100644 samples/snippets/batch_parse_form_v1beta2_test.py delete mode 100644 samples/snippets/batch_parse_table_v1beta2.py delete mode 100644 samples/snippets/batch_parse_table_v1beta2_test.py delete mode 100644 samples/snippets/parse_form_v1beta2.py delete mode 100644 samples/snippets/parse_form_v1beta2_test.py delete mode 100644 samples/snippets/parse_table_v1beta2.py delete mode 100644 samples/snippets/parse_table_v1beta2_test.py delete mode 100644 samples/snippets/parse_with_model_v1beta2.py delete mode 100644 samples/snippets/parse_with_model_v1beta2_test.py delete mode 100644 samples/snippets/quickstart_v1beta2.py delete mode 100644 samples/snippets/quickstart_v1beta2_test.py delete mode 100644 samples/snippets/set_endpoint_v1beta2.py delete mode 100644 samples/snippets/set_endpoint_v1beta2_test.py diff --git a/samples/snippets/batch_parse_form_v1beta2.py b/samples/snippets/batch_parse_form_v1beta2.py deleted file mode 100644 index a3220b4a..00000000 --- a/samples/snippets/batch_parse_form_v1beta2.py +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# [START documentai_batch_parse_form_beta] -import re - -from google.cloud import documentai_v1beta2 as documentai -from google.cloud import storage - - -def batch_parse_form( - project_id="YOUR_PROJECT_ID", - input_uri="gs://cloud-samples-data/documentai/form.pdf", - destination_uri="gs://your-bucket-id/path/to/save/results/", - timeout=90, -): - """Parse a form""" - - client = documentai.DocumentUnderstandingServiceClient() - - gcs_source = documentai.types.GcsSource(uri=input_uri) - - # mime_type can be application/pdf, image/tiff, - # and image/gif, or application/json - input_config = documentai.types.InputConfig( - gcs_source=gcs_source, mime_type="application/pdf" - ) - - # where to write results - output_config = documentai.types.OutputConfig( - gcs_destination=documentai.types.GcsDestination(uri=destination_uri), - pages_per_shard=1, # Map one doc page to one output page - ) - - # Improve form parsing results by providing key-value pair hints. - # For each key hint, key is text that is likely to appear in the - # document as a form field name (i.e. "DOB"). - # Value types are optional, but can be one or more of: - # ADDRESS, LOCATION, ORGANIZATION, PERSON, PHONE_NUMBER, ID, - # NUMBER, EMAIL, PRICE, TERMS, DATE, NAME - key_value_pair_hints = [ - documentai.types.KeyValuePairHint( - key="Emergency Contact", value_types=["NAME"] - ), - documentai.types.KeyValuePairHint(key="Referred By"), - ] - - # Setting enabled=True enables form extraction - form_extraction_params = documentai.types.FormExtractionParams( - enabled=True, key_value_pair_hints=key_value_pair_hints - ) - - # Location can be 'us' or 'eu' - parent = "projects/{}/locations/us".format(project_id) - request = documentai.types.ProcessDocumentRequest( - input_config=input_config, - output_config=output_config, - form_extraction_params=form_extraction_params, - ) - - # Add each ProcessDocumentRequest to the batch request - requests = [] - requests.append(request) - - batch_request = documentai.types.BatchProcessDocumentsRequest( - parent=parent, requests=requests - ) - - operation = client.batch_process_documents(batch_request) - - # Wait for the operation to finish - operation.result(timeout) - - # Results are written to GCS. Use a regex to find - # output files - match = re.match(r"gs://([^/]+)/(.+)", destination_uri) - output_bucket = match.group(1) - prefix = match.group(2) - - storage_client = storage.client.Client() - bucket = storage_client.get_bucket(output_bucket) - blob_list = list(bucket.list_blobs(prefix=prefix)) - print("Output files:") - for blob in blob_list: - print(blob.name) - - -# [END documentai_batch_parse_form_beta] diff --git a/samples/snippets/batch_parse_form_v1beta2_test.py b/samples/snippets/batch_parse_form_v1beta2_test.py deleted file mode 100644 index c4bad1ad..00000000 --- a/samples/snippets/batch_parse_form_v1beta2_test.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific ladnguage governing permissions and -# limitations under the License. - -import os -import uuid - -from google.cloud import storage -import pytest -from samples.snippets import batch_parse_form_v1beta2 - -BUCKET = "document-ai-{}".format(uuid.uuid4()) -OUTPUT_PREFIX = "TEST_OUTPUT_{}".format(uuid.uuid4()) -PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] -INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" -BATCH_OUTPUT_URI = "gs://{}/{}/".format(BUCKET, OUTPUT_PREFIX) - - -@pytest.fixture(autouse=True) -def setup_teardown(): - """Create a temporary bucket to store annotation output.""" - storage_client = storage.Client() - bucket = storage_client.create_bucket(BUCKET) - - yield - - bucket.delete(force=True) - - -def test_batch_parse_form(capsys): - batch_parse_form_v1beta2.batch_parse_form( - PROJECT_ID, INPUT_URI, BATCH_OUTPUT_URI, 120 - ) - out, _ = capsys.readouterr() - assert "Output files" in out diff --git a/samples/snippets/batch_parse_table_v1beta2.py b/samples/snippets/batch_parse_table_v1beta2.py deleted file mode 100644 index 16851437..00000000 --- a/samples/snippets/batch_parse_table_v1beta2.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# [START documentai_batch_parse_table_beta] -import re - -from google.cloud import documentai_v1beta2 as documentai -from google.cloud import storage - - -def batch_parse_table( - project_id="YOUR_PROJECT_ID", - input_uri="gs://cloud-samples-data/documentai/form.pdf", - destination_uri="gs://your-bucket-id/path/to/save/results/", - timeout=90, -): - """Parse a form""" - - client = documentai.DocumentUnderstandingServiceClient() - - gcs_source = documentai.types.GcsSource(uri=input_uri) - - # mime_type can be application/pdf, image/tiff, - # and image/gif, or application/json - input_config = documentai.types.InputConfig( - gcs_source=gcs_source, mime_type="application/pdf" - ) - - # where to write results - output_config = documentai.types.OutputConfig( - gcs_destination=documentai.types.GcsDestination(uri=destination_uri), - pages_per_shard=1, # Map one doc page to one output page - ) - - # Improve table parsing results by providing bounding boxes - # specifying where the box appears in the document (optional) - table_bound_hints = [ - documentai.types.TableBoundHint( - page_number=1, - bounding_box=documentai.types.BoundingPoly( - # Define a polygon around tables to detect - # Each vertice coordinate must be a number between 0 and 1 - normalized_vertices=[ - # Top left - documentai.types.geometry.NormalizedVertex(x=0, y=0), - # Top right - documentai.types.geometry.NormalizedVertex(x=1, y=0), - # Bottom right - documentai.types.geometry.NormalizedVertex(x=1, y=1), - # Bottom left - documentai.types.geometry.NormalizedVertex(x=0, y=1), - ] - ), - ) - ] - - # Setting enabled=True enables form extraction - table_extraction_params = documentai.types.TableExtractionParams( - enabled=True, table_bound_hints=table_bound_hints - ) - - # Location can be 'us' or 'eu' - parent = "projects/{}/locations/us".format(project_id) - request = documentai.types.ProcessDocumentRequest( - input_config=input_config, - output_config=output_config, - table_extraction_params=table_extraction_params, - ) - - requests = [] - requests.append(request) - - batch_request = documentai.types.BatchProcessDocumentsRequest( - parent=parent, requests=requests - ) - - operation = client.batch_process_documents(batch_request) - - # Wait for the operation to finish - operation.result(timeout) - - # Results are written to GCS. Use a regex to find - # output files - match = re.match(r"gs://([^/]+)/(.+)", destination_uri) - output_bucket = match.group(1) - prefix = match.group(2) - - storage_client = storage.client.Client() - bucket = storage_client.get_bucket(output_bucket) - blob_list = list(bucket.list_blobs(prefix=prefix)) - print("Output files:") - for blob in blob_list: - print(blob.name) - - -# [END documentai_batch_parse_table_beta] diff --git a/samples/snippets/batch_parse_table_v1beta2_test.py b/samples/snippets/batch_parse_table_v1beta2_test.py deleted file mode 100644 index faf26856..00000000 --- a/samples/snippets/batch_parse_table_v1beta2_test.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific ladnguage governing permissions and -# limitations under the License. - -import os -import uuid - -from google.cloud import storage -import pytest -from samples.snippets import batch_parse_table_v1beta2 - -BUCKET = "document-ai-{}".format(uuid.uuid4()) -OUTPUT_PREFIX = "TEST_OUTPUT_{}".format(uuid.uuid4()) -PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] -INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" -BATCH_OUTPUT_URI = "gs://{}/{}/".format(BUCKET, OUTPUT_PREFIX) - - -@pytest.fixture(autouse=True) -def setup_teardown(): - """Create a temporary bucket to store annotation output.""" - storage_client = storage.Client() - bucket = storage_client.create_bucket(BUCKET) - - yield - - bucket.delete(force=True) - - -def test_batch_parse_table(capsys): - batch_parse_table_v1beta2.batch_parse_table( - PROJECT_ID, INPUT_URI, BATCH_OUTPUT_URI, 120 - ) - out, _ = capsys.readouterr() - assert "Output files:" in out diff --git a/samples/snippets/parse_form_v1beta2.py b/samples/snippets/parse_form_v1beta2.py deleted file mode 100644 index 27c99811..00000000 --- a/samples/snippets/parse_form_v1beta2.py +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the 'License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# [START documentai_parse_form_beta] -from google.cloud import documentai_v1beta2 as documentai - - -def parse_form( - project_id="YOUR_PROJECT_ID", - input_uri="gs://cloud-samples-data/documentai/form.pdf", -): - """Parse a form""" - - client = documentai.DocumentUnderstandingServiceClient() - - gcs_source = documentai.types.GcsSource(uri=input_uri) - - # mime_type can be application/pdf, image/tiff, - # and image/gif, or application/json - input_config = documentai.types.InputConfig( - gcs_source=gcs_source, mime_type="application/pdf" - ) - - # Improve form parsing results by providing key-value pair hints. - # For each key hint, key is text that is likely to appear in the - # document as a form field name (i.e. "DOB"). - # Value types are optional, but can be one or more of: - # ADDRESS, LOCATION, ORGANIZATION, PERSON, PHONE_NUMBER, ID, - # NUMBER, EMAIL, PRICE, TERMS, DATE, NAME - key_value_pair_hints = [ - documentai.types.KeyValuePairHint( - key="Emergency Contact", value_types=["NAME"] - ), - documentai.types.KeyValuePairHint(key="Referred By"), - ] - - # Setting enabled=True enables form extraction - form_extraction_params = documentai.types.FormExtractionParams( - enabled=True, key_value_pair_hints=key_value_pair_hints - ) - - # Location can be 'us' or 'eu' - parent = "projects/{}/locations/us".format(project_id) - request = documentai.types.ProcessDocumentRequest( - parent=parent, - input_config=input_config, - form_extraction_params=form_extraction_params, - ) - - document = client.process_document(request=request) - - def _get_text(el): - """Doc AI identifies form fields by their offsets - in document text. This function converts offsets - to text snippets. - """ - response = "" - # If a text segment spans several lines, it will - # be stored in different text segments. - for segment in el.text_anchor.text_segments: - start_index = segment.start_index - end_index = segment.end_index - response += document.text[start_index:end_index] - return response - - for page in document.pages: - print("Page number: {}".format(page.page_number)) - for form_field in page.form_fields: - print( - "Field Name: {}\tConfidence: {}".format( - _get_text(form_field.field_name), form_field.field_name.confidence - ) - ) - print( - "Field Value: {}\tConfidence: {}".format( - _get_text(form_field.field_value), form_field.field_value.confidence - ) - ) - - -# [END documentai_parse_form_beta] diff --git a/samples/snippets/parse_form_v1beta2_test.py b/samples/snippets/parse_form_v1beta2_test.py deleted file mode 100644 index c2b33eec..00000000 --- a/samples/snippets/parse_form_v1beta2_test.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific ladnguage governing permissions and -# limitations under the License. - -import os - -from samples.snippets import parse_form_v1beta2 - -PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] -INPUT_URI = "gs://cloud-samples-data/documentai/form.pdf" - - -def test_parse_form(capsys): - parse_form_v1beta2.parse_form(PROJECT_ID, INPUT_URI) - out, _ = capsys.readouterr() - assert "Field Name" in out - assert "Field Value" in out diff --git a/samples/snippets/parse_table_v1beta2.py b/samples/snippets/parse_table_v1beta2.py deleted file mode 100644 index ac8f5d11..00000000 --- a/samples/snippets/parse_table_v1beta2.py +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# [START documentai_parse_table_beta] -from google.cloud import documentai_v1beta2 as documentai - - -def parse_table( - project_id="YOUR_PROJECT_ID", - input_uri="gs://cloud-samples-data/documentai/invoice.pdf", -): - """Parse a form""" - - client = documentai.DocumentUnderstandingServiceClient() - - gcs_source = documentai.types.GcsSource(uri=input_uri) - - # mime_type can be application/pdf, image/tiff, - # and image/gif, or application/json - input_config = documentai.types.InputConfig( - gcs_source=gcs_source, mime_type="application/pdf" - ) - - # Improve table parsing results by providing bounding boxes - # specifying where the box appears in the document (optional) - table_bound_hints = [ - documentai.types.TableBoundHint( - page_number=1, - bounding_box=documentai.types.BoundingPoly( - # Define a polygon around tables to detect - # Each vertice coordinate must be a number between 0 and 1 - normalized_vertices=[ - # Top left - documentai.types.geometry.NormalizedVertex(x=0, y=0), - # Top right - documentai.types.geometry.NormalizedVertex(x=1, y=0), - # Bottom right - documentai.types.geometry.NormalizedVertex(x=1, y=1), - # Bottom left - documentai.types.geometry.NormalizedVertex(x=0, y=1), - ] - ), - ) - ] - - # Setting enabled=True enables form extraction - table_extraction_params = documentai.types.TableExtractionParams( - enabled=True, table_bound_hints=table_bound_hints - ) - - # Location can be 'us' or 'eu' - parent = "projects/{}/locations/us".format(project_id) - request = documentai.types.ProcessDocumentRequest( - parent=parent, - input_config=input_config, - table_extraction_params=table_extraction_params, - ) - - document = client.process_document(request=request) - - def _get_text(el): - """Convert text offset indexes into text snippets.""" - response = "" - # If a text segment spans several lines, it will - # be stored in different text segments. - for segment in el.text_anchor.text_segments: - start_index = segment.start_index - end_index = segment.end_index - response += document.text[start_index:end_index] - return response - - for page in document.pages: - print("Page number: {}".format(page.page_number)) - for table_num, table in enumerate(page.tables): - print("Table {}: ".format(table_num)) - for row_num, row in enumerate(table.header_rows): - cells = "\t".join([_get_text(cell.layout) for cell in row.cells]) - print("Header Row {}: {}".format(row_num, cells)) - for row_num, row in enumerate(table.body_rows): - cells = "\t".join([_get_text(cell.layout) for cell in row.cells]) - print("Row {}: {}".format(row_num, cells)) - - -# [END documentai_parse_table_beta] diff --git a/samples/snippets/parse_table_v1beta2_test.py b/samples/snippets/parse_table_v1beta2_test.py deleted file mode 100644 index f59e9a82..00000000 --- a/samples/snippets/parse_table_v1beta2_test.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific ladnguage governing permissions and -# limitations under the License. - -import os - -from samples.snippets import parse_table_v1beta2 - -PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] -INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" - - -def test_parse_table(capsys): - parse_table_v1beta2.parse_table(PROJECT_ID, INPUT_URI) - out, _ = capsys.readouterr() - assert "Table" in out - assert "Header Row" in out diff --git a/samples/snippets/parse_with_model_v1beta2.py b/samples/snippets/parse_with_model_v1beta2.py deleted file mode 100644 index 59265c4f..00000000 --- a/samples/snippets/parse_with_model_v1beta2.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# [START documentai_parse_with_model_beta] -from google.cloud import documentai_v1beta2 as documentai - - -def parse_with_model( - project_id="YOUR_PROJECT_ID", - input_uri="gs://cloud-samples-data/documentai/invoice.pdf", - automl_model_name="YOUR_AUTOML_MODEL_NAME", -): - """Process a single document with the Document AI API. - - Args: - project_id: your Google Cloud project id - input_uri: the Cloud Storage URI of your input PDF - automl_model_name: the AutoML model name formatted as: - `projects/[PROJECT_ID]/locations/[LOCATION]/models/[MODEL_ID] - where LOCATION is a Compute Engine region, e.g. `us-central1` - """ - - client = documentai.DocumentUnderstandingServiceClient() - - gcs_source = documentai.types.GcsSource(uri=input_uri) - - # mime_type can be application/pdf, image/tiff, - # and image/gif, or application/json - input_config = documentai.types.InputConfig( - gcs_source=gcs_source, mime_type="application/pdf" - ) - - automl_params = documentai.types.AutoMlParams(model=automl_model_name) - - # Location can be 'us' or 'eu' - parent = "projects/{}/locations/us".format(project_id) - request = documentai.types.ProcessDocumentRequest( - parent=parent, input_config=input_config, automl_params=automl_params - ) - - document = client.process_document(request=request) - - for label in document.labels: - print("Label detected: {}".format(label.name)) - print("Confidence: {}".format(label.confidence)) - - -# [END documentai_parse_with_model_beta] diff --git a/samples/snippets/parse_with_model_v1beta2_test.py b/samples/snippets/parse_with_model_v1beta2_test.py deleted file mode 100644 index e3934b65..00000000 --- a/samples/snippets/parse_with_model_v1beta2_test.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific ladnguage governing permissions and -# limitations under the License. - -import os - -from samples.snippets import parse_with_model_v1beta2 - -PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] -INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" -AUTOML_NL_MODEL_ID = "TCN3472481026502981088" - -if "AUTOML_NL_MODEL_ID" in os.environ: - AUTOML_NL_MODEL_ID = os.environ["AUTOML_NL_MODEL_ID"] - -MODEL_NAME = "projects/{}/locations/us-central1/models/{}".format( - PROJECT_ID, AUTOML_NL_MODEL_ID -) - - -def test_parse_with_model(capsys): - parse_with_model_v1beta2.parse_with_model(PROJECT_ID, INPUT_URI, MODEL_NAME) - out, _ = capsys.readouterr() - assert "Label detected" in out - assert "Confidence" in out diff --git a/samples/snippets/quickstart_v1beta2.py b/samples/snippets/quickstart_v1beta2.py deleted file mode 100644 index 34f58820..00000000 --- a/samples/snippets/quickstart_v1beta2.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# [START documentai_quickstart_beta] -from google.cloud import documentai_v1beta2 as documentai - - -def main( - project_id="YOUR_PROJECT_ID", - input_uri="gs://cloud-samples-data/documentai/invoice.pdf", -): - """Process a single document with the Document AI API, including - text extraction and entity extraction.""" - - client = documentai.DocumentUnderstandingServiceClient() - - gcs_source = documentai.types.GcsSource(uri=input_uri) - - # mime_type can be application/pdf, image/tiff, - # and image/gif, or application/json - input_config = documentai.types.InputConfig( - gcs_source=gcs_source, mime_type="application/pdf" - ) - - # Location can be 'us' or 'eu' - parent = "projects/{}/locations/us".format(project_id) - request = documentai.types.ProcessDocumentRequest( - parent=parent, input_config=input_config - ) - - document = client.process_document(request=request) - - # All text extracted from the document - print("Document Text: {}".format(document.text)) - - def _get_text(el): - """Convert text offset indexes into text snippets.""" - response = "" - # If a text segment spans several lines, it will - # be stored in different text segments. - for segment in el.text_anchor.text_segments: - start_index = segment.start_index - end_index = segment.end_index - response += document.text[start_index:end_index] - return response - - for entity in document.entities: - print("Entity type: {}".format(entity.type_)) - print("Text: {}".format(_get_text(entity))) - print("Mention text: {}\n".format(entity.mention_text)) - - -# [END documentai_quickstart_beta] diff --git a/samples/snippets/quickstart_v1beta2_test.py b/samples/snippets/quickstart_v1beta2_test.py deleted file mode 100644 index 8467b53e..00000000 --- a/samples/snippets/quickstart_v1beta2_test.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific ladnguage governing permissions and -# limitations under the License. - -import os - -from samples.snippets import quickstart_v1beta2 - -PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] -INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" - - -def test_quickstart(capsys): - quickstart_v1beta2.main(PROJECT_ID, INPUT_URI) - out, _ = capsys.readouterr() - assert "Entity type" in out - assert "Mention text" in out diff --git a/samples/snippets/set_endpoint_v1beta2.py b/samples/snippets/set_endpoint_v1beta2.py deleted file mode 100644 index 0fa9921b..00000000 --- a/samples/snippets/set_endpoint_v1beta2.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -def set_endpoint( - project_id="YOUR_PROJECT_ID", - input_uri="gs://cloud-samples-data/documentai/invoice.pdf", -): - """Process a single document with the Document AI API, including - text extraction and entity extraction.""" - - # [START documentai_set_endpoint_beta] - from google.cloud import documentai_v1beta2 as documentai - - client = documentai.DocumentUnderstandingServiceClient( - client_options={"api_endpoint": "eu-documentai.googleapis.com"} - ) - # [END documentai_set_endpoint_beta] - - gcs_source = documentai.types.GcsSource(uri=input_uri) - - # mime_type can be application/pdf, image/tiff, - # and image/gif, or application/json - input_config = documentai.types.InputConfig( - gcs_source=gcs_source, mime_type="application/pdf" - ) - - # Location can be 'us' or 'eu' - parent = "projects/{}/locations/eu".format(project_id) - request = documentai.types.ProcessDocumentRequest( - parent=parent, input_config=input_config - ) - - document = client.process_document(request=request) - - # All text extracted from the document - print("Document Text: {}".format(document.text)) diff --git a/samples/snippets/set_endpoint_v1beta2_test.py b/samples/snippets/set_endpoint_v1beta2_test.py deleted file mode 100644 index b9811155..00000000 --- a/samples/snippets/set_endpoint_v1beta2_test.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific ladnguage governing permissions and -# limitations under the License. - -import os - -from samples.snippets import set_endpoint_v1beta2 - -PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] -INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf" - - -def test_set_endpoint(capsys): - set_endpoint_v1beta2.set_endpoint(PROJECT_ID, INPUT_URI) - out, _ = capsys.readouterr() - assert "Document Text" in out From 2d82c64b5034bb6315031c31a11198a6f3b7f393 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 28 Apr 2022 12:12:13 +0000 Subject: [PATCH 15/16] fix: mark Document.Entity.type as REQUIRED in all versions (#317) - [ ] Regenerate this pull request now. fix: remove Document.Entity.bounding_poly_for_demo_frontend from v1beta2 PiperOrigin-RevId: 444656928 Source-Link: https://github.com/googleapis/googleapis/commit/a0d4c5c2a714a7317714ba6f0066a74ec8a9c10b Source-Link: https://github.com/googleapis/googleapis-gen/commit/d3a3f6dde18ec3721fceba933e4327a7b6dd2c2d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDNhM2Y2ZGRlMThlYzM3MjFmY2ViYTkzM2U0MzI3YTdiNmRkMmMyZCJ9 chore: use gapic-generator-python 0.65.2 PiperOrigin-RevId: 444333013 Source-Link: https://github.com/googleapis/googleapis/commit/f91b6cf82e929280f6562f6110957c654bd9e2e6 Source-Link: https://github.com/googleapis/googleapis-gen/commit/16eb36095c294e712c74a1bf23550817b42174e5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTZlYjM2MDk1YzI5NGU3MTJjNzRhMWJmMjM1NTA4MTdiNDIxNzRlNSJ9 --- .../async_client.py | 18 ++--- google/cloud/documentai_v1/types/document.py | 2 +- .../async_client.py | 12 +-- .../documentai_v1beta2/types/document.py | 12 +-- .../async_client.py | 54 +++++++------- .../documentai_v1beta3/types/document.py | 2 +- .../test_document_processor_service.py | 24 +++--- .../test_document_understanding_service.py | 16 ++-- .../test_document_processor_service.py | 74 +++++++++---------- 9 files changed, 102 insertions(+), 112 deletions(-) diff --git a/google/cloud/documentai_v1/services/document_processor_service/async_client.py b/google/cloud/documentai_v1/services/document_processor_service/async_client.py index 178f0ebb..de3c45ed 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/async_client.py @@ -238,9 +238,9 @@ async def process_document( from google.cloud import documentai_v1 - def sample_process_document(): + async def sample_process_document(): # Create a client - client = documentai_v1.DocumentProcessorServiceClient() + client = documentai_v1.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) inline_document = documentai_v1.Document() @@ -252,7 +252,7 @@ def sample_process_document(): ) # Make the request - response = client.process_document(request=request) + response = await client.process_document(request=request) # Handle the response print(response) @@ -348,9 +348,9 @@ async def batch_process_documents( from google.cloud import documentai_v1 - def sample_batch_process_documents(): + async def sample_batch_process_documents(): # Create a client - client = documentai_v1.DocumentProcessorServiceClient() + client = documentai_v1.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) request = documentai_v1.BatchProcessRequest( @@ -362,7 +362,7 @@ def sample_batch_process_documents(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -469,9 +469,9 @@ async def review_document( from google.cloud import documentai_v1 - def sample_review_document(): + async def sample_review_document(): # Create a client - client = documentai_v1.DocumentProcessorServiceClient() + client = documentai_v1.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) inline_document = documentai_v1.Document() @@ -487,7 +487,7 @@ def sample_review_document(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) diff --git a/google/cloud/documentai_v1/types/document.py b/google/cloud/documentai_v1/types/document.py index 25b2cc21..5aa2a42e 100644 --- a/google/cloud/documentai_v1/types/document.py +++ b/google/cloud/documentai_v1/types/document.py @@ -875,7 +875,7 @@ class Entity(proto.Message): into the [Document.text][google.cloud.documentai.v1.Document.text]. type_ (str): - Entity type from a schema e.g. ``Address``. + Required. Entity type from a schema e.g. ``Address``. mention_text (str): Optional. Text value in the document e.g. ``1600 Amphitheatre Pkwy``. If the entity is not present in diff --git a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py index 7a59f55b..9dd7fc49 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py @@ -232,9 +232,9 @@ async def batch_process_documents( from google.cloud import documentai_v1beta2 - def sample_batch_process_documents(): + async def sample_batch_process_documents(): # Create a client - client = documentai_v1beta2.DocumentUnderstandingServiceClient() + client = documentai_v1beta2.DocumentUnderstandingServiceAsyncClient() # Initialize request argument(s) requests = documentai_v1beta2.ProcessDocumentRequest() @@ -250,7 +250,7 @@ def sample_batch_process_documents(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -355,9 +355,9 @@ async def process_document( from google.cloud import documentai_v1beta2 - def sample_process_document(): + async def sample_process_document(): # Create a client - client = documentai_v1beta2.DocumentUnderstandingServiceClient() + client = documentai_v1beta2.DocumentUnderstandingServiceAsyncClient() # Initialize request argument(s) input_config = documentai_v1beta2.InputConfig() @@ -369,7 +369,7 @@ def sample_process_document(): ) # Make the request - response = client.process_document(request=request) + response = await client.process_document(request=request) # Handle the response print(response) diff --git a/google/cloud/documentai_v1beta2/types/document.py b/google/cloud/documentai_v1beta2/types/document.py index 4a10f97f..92e50574 100644 --- a/google/cloud/documentai_v1beta2/types/document.py +++ b/google/cloud/documentai_v1beta2/types/document.py @@ -773,7 +773,7 @@ class Entity(proto.Message): Provenance of the entity. Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta2.Document.text]. type_ (str): - Entity type from a schema e.g. ``Address``. + Required. Entity type from a schema e.g. ``Address``. mention_text (str): Text value in the document e.g. ``1600 Amphitheatre Pkwy``. mention_id (str): @@ -788,11 +788,6 @@ class Entity(proto.Message): id (str): Optional. Canonical id. This will be a unique value in the entity list for this document. - bounding_poly_for_demo_frontend (google.cloud.documentai_v1beta2.types.BoundingPoly): - Optional. Temporary field to store the - bounding poly for short-term POCs. Used by the - frontend only. Do not use before you talk to - ybo@ and lukasr@. """ text_anchor = proto.Field( @@ -825,11 +820,6 @@ class Entity(proto.Message): proto.STRING, number=7, ) - bounding_poly_for_demo_frontend = proto.Field( - proto.MESSAGE, - number=8, - message=geometry.BoundingPoly, - ) class EntityRelation(proto.Message): r"""Relationship between diff --git a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py index e178f44e..2e479598 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/async_client.py @@ -250,9 +250,9 @@ async def process_document( from google.cloud import documentai_v1beta3 - def sample_process_document(): + async def sample_process_document(): # Create a client - client = documentai_v1beta3.DocumentProcessorServiceClient() + client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) inline_document = documentai_v1beta3.Document() @@ -264,7 +264,7 @@ def sample_process_document(): ) # Make the request - response = client.process_document(request=request) + response = await client.process_document(request=request) # Handle the response print(response) @@ -360,9 +360,9 @@ async def batch_process_documents( from google.cloud import documentai_v1beta3 - def sample_batch_process_documents(): + async def sample_batch_process_documents(): # Create a client - client = documentai_v1beta3.DocumentProcessorServiceClient() + client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) request = documentai_v1beta3.BatchProcessRequest( @@ -374,7 +374,7 @@ def sample_batch_process_documents(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -482,9 +482,9 @@ async def fetch_processor_types( from google.cloud import documentai_v1beta3 - def sample_fetch_processor_types(): + async def sample_fetch_processor_types(): # Create a client - client = documentai_v1beta3.DocumentProcessorServiceClient() + client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) request = documentai_v1beta3.FetchProcessorTypesRequest( @@ -492,7 +492,7 @@ def sample_fetch_processor_types(): ) # Make the request - response = client.fetch_processor_types(request=request) + response = await client.fetch_processor_types(request=request) # Handle the response print(response) @@ -578,9 +578,9 @@ async def list_processors( from google.cloud import documentai_v1beta3 - def sample_list_processors(): + async def sample_list_processors(): # Create a client - client = documentai_v1beta3.DocumentProcessorServiceClient() + client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) request = documentai_v1beta3.ListProcessorsRequest( @@ -591,7 +591,7 @@ def sample_list_processors(): page_result = client.list_processors(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -690,9 +690,9 @@ async def create_processor( from google.cloud import documentai_v1beta3 - def sample_create_processor(): + async def sample_create_processor(): # Create a client - client = documentai_v1beta3.DocumentProcessorServiceClient() + client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) request = documentai_v1beta3.CreateProcessorRequest( @@ -700,7 +700,7 @@ def sample_create_processor(): ) # Make the request - response = client.create_processor(request=request) + response = await client.create_processor(request=request) # Handle the response print(response) @@ -803,9 +803,9 @@ async def delete_processor( from google.cloud import documentai_v1beta3 - def sample_delete_processor(): + async def sample_delete_processor(): # Create a client - client = documentai_v1beta3.DocumentProcessorServiceClient() + client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) request = documentai_v1beta3.DeleteProcessorRequest( @@ -817,7 +817,7 @@ def sample_delete_processor(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -922,9 +922,9 @@ async def enable_processor( from google.cloud import documentai_v1beta3 - def sample_enable_processor(): + async def sample_enable_processor(): # Create a client - client = documentai_v1beta3.DocumentProcessorServiceClient() + client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) request = documentai_v1beta3.EnableProcessorRequest( @@ -936,7 +936,7 @@ def sample_enable_processor(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -1010,9 +1010,9 @@ async def disable_processor( from google.cloud import documentai_v1beta3 - def sample_disable_processor(): + async def sample_disable_processor(): # Create a client - client = documentai_v1beta3.DocumentProcessorServiceClient() + client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) request = documentai_v1beta3.DisableProcessorRequest( @@ -1024,7 +1024,7 @@ def sample_disable_processor(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -1100,9 +1100,9 @@ async def review_document( from google.cloud import documentai_v1beta3 - def sample_review_document(): + async def sample_review_document(): # Create a client - client = documentai_v1beta3.DocumentProcessorServiceClient() + client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() # Initialize request argument(s) inline_document = documentai_v1beta3.Document() @@ -1118,7 +1118,7 @@ def sample_review_document(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) diff --git a/google/cloud/documentai_v1beta3/types/document.py b/google/cloud/documentai_v1beta3/types/document.py index b7d0a56d..f945df4a 100644 --- a/google/cloud/documentai_v1beta3/types/document.py +++ b/google/cloud/documentai_v1beta3/types/document.py @@ -880,7 +880,7 @@ class Entity(proto.Message): into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. type_ (str): - Entity type from a schema e.g. ``Address``. + Required. Entity type from a schema e.g. ``Address``. mention_text (str): Optional. Text value in the document e.g. ``1600 Amphitheatre Pkwy``. If the entity is not present in diff --git a/tests/unit/gapic/documentai_v1/test_document_processor_service.py b/tests/unit/gapic/documentai_v1/test_document_processor_service.py index 500f5a4b..82d570f2 100644 --- a/tests/unit/gapic/documentai_v1/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1/test_document_processor_service.py @@ -790,7 +790,7 @@ def test_process_document_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.ProcessRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.process_document), "__call__") as call: @@ -806,7 +806,7 @@ def test_process_document_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -820,7 +820,7 @@ async def test_process_document_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.ProcessRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.process_document), "__call__") as call: @@ -838,7 +838,7 @@ async def test_process_document_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1023,7 +1023,7 @@ def test_batch_process_documents_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.BatchProcessRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1041,7 +1041,7 @@ def test_batch_process_documents_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1055,7 +1055,7 @@ async def test_batch_process_documents_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.BatchProcessRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1075,7 +1075,7 @@ async def test_batch_process_documents_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1258,7 +1258,7 @@ def test_review_document_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.ReviewDocumentRequest() - request.human_review_config = "human_review_config/value" + request.human_review_config = "human_review_config_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.review_document), "__call__") as call: @@ -1274,7 +1274,7 @@ def test_review_document_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "human_review_config=human_review_config/value", + "human_review_config=human_review_config_value", ) in kw["metadata"] @@ -1288,7 +1288,7 @@ async def test_review_document_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.ReviewDocumentRequest() - request.human_review_config = "human_review_config/value" + request.human_review_config = "human_review_config_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.review_document), "__call__") as call: @@ -1306,7 +1306,7 @@ async def test_review_document_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "human_review_config=human_review_config/value", + "human_review_config=human_review_config_value", ) in kw["metadata"] diff --git a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py index 119469ce..3acba2d8 100644 --- a/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py +++ b/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py @@ -788,7 +788,7 @@ def test_batch_process_documents_field_headers(): # a field header. Set these to a non-empty value. request = document_understanding.BatchProcessDocumentsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -806,7 +806,7 @@ def test_batch_process_documents_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -820,7 +820,7 @@ async def test_batch_process_documents_field_headers_async(): # a field header. Set these to a non-empty value. request = document_understanding.BatchProcessDocumentsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -840,7 +840,7 @@ async def test_batch_process_documents_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1046,7 +1046,7 @@ def test_process_document_field_headers(): # a field header. Set these to a non-empty value. request = document_understanding.ProcessDocumentRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.process_document), "__call__") as call: @@ -1062,7 +1062,7 @@ def test_process_document_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1076,7 +1076,7 @@ async def test_process_document_field_headers_async(): # a field header. Set these to a non-empty value. request = document_understanding.ProcessDocumentRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.process_document), "__call__") as call: @@ -1092,7 +1092,7 @@ async def test_process_document_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] diff --git a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py index 5126618a..458fc7a9 100644 --- a/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py +++ b/tests/unit/gapic/documentai_v1beta3/test_document_processor_service.py @@ -800,7 +800,7 @@ def test_process_document_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.ProcessRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.process_document), "__call__") as call: @@ -816,7 +816,7 @@ def test_process_document_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -830,7 +830,7 @@ async def test_process_document_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.ProcessRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.process_document), "__call__") as call: @@ -848,7 +848,7 @@ async def test_process_document_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1033,7 +1033,7 @@ def test_batch_process_documents_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.BatchProcessRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1051,7 +1051,7 @@ def test_batch_process_documents_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1065,7 +1065,7 @@ async def test_batch_process_documents_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.BatchProcessRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1085,7 +1085,7 @@ async def test_batch_process_documents_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1274,7 +1274,7 @@ def test_fetch_processor_types_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.FetchProcessorTypesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1292,7 +1292,7 @@ def test_fetch_processor_types_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1306,7 +1306,7 @@ async def test_fetch_processor_types_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.FetchProcessorTypesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1326,7 +1326,7 @@ async def test_fetch_processor_types_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1515,7 +1515,7 @@ def test_list_processors_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.ListProcessorsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_processors), "__call__") as call: @@ -1531,7 +1531,7 @@ def test_list_processors_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1545,7 +1545,7 @@ async def test_list_processors_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.ListProcessorsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_processors), "__call__") as call: @@ -1563,7 +1563,7 @@ async def test_list_processors_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1694,7 +1694,7 @@ def test_list_processors_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, processor.Processor) for i in results) @@ -1960,7 +1960,7 @@ def test_create_processor_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.CreateProcessorRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_processor), "__call__") as call: @@ -1976,7 +1976,7 @@ def test_create_processor_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1990,7 +1990,7 @@ async def test_create_processor_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.CreateProcessorRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_processor), "__call__") as call: @@ -2008,7 +2008,7 @@ async def test_create_processor_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -2197,7 +2197,7 @@ def test_delete_processor_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.DeleteProcessorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_processor), "__call__") as call: @@ -2213,7 +2213,7 @@ def test_delete_processor_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2227,7 +2227,7 @@ async def test_delete_processor_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.DeleteProcessorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_processor), "__call__") as call: @@ -2245,7 +2245,7 @@ async def test_delete_processor_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2424,7 +2424,7 @@ def test_enable_processor_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.EnableProcessorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.enable_processor), "__call__") as call: @@ -2440,7 +2440,7 @@ def test_enable_processor_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2454,7 +2454,7 @@ async def test_enable_processor_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.EnableProcessorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.enable_processor), "__call__") as call: @@ -2472,7 +2472,7 @@ async def test_enable_processor_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2575,7 +2575,7 @@ def test_disable_processor_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.DisableProcessorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2593,7 +2593,7 @@ def test_disable_processor_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2607,7 +2607,7 @@ async def test_disable_processor_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.DisableProcessorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2627,7 +2627,7 @@ async def test_disable_processor_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2724,7 +2724,7 @@ def test_review_document_field_headers(): # a field header. Set these to a non-empty value. request = document_processor_service.ReviewDocumentRequest() - request.human_review_config = "human_review_config/value" + request.human_review_config = "human_review_config_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.review_document), "__call__") as call: @@ -2740,7 +2740,7 @@ def test_review_document_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "human_review_config=human_review_config/value", + "human_review_config=human_review_config_value", ) in kw["metadata"] @@ -2754,7 +2754,7 @@ async def test_review_document_field_headers_async(): # a field header. Set these to a non-empty value. request = document_processor_service.ReviewDocumentRequest() - request.human_review_config = "human_review_config/value" + request.human_review_config = "human_review_config_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.review_document), "__call__") as call: @@ -2772,7 +2772,7 @@ async def test_review_document_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "human_review_config=human_review_config/value", + "human_review_config=human_review_config_value", ) in kw["metadata"] From fb7778cdf5869a341d632f42ed3d6655918865f9 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 28 Apr 2022 15:34:41 -0400 Subject: [PATCH 16/16] chore(main): release 1.4.1 (#318) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ setup.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d952f926..e4e3ef3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +### [1.4.1](https://github.com/googleapis/python-documentai/compare/v1.4.0...v1.4.1) (2022-04-28) + + +### Bug Fixes + +* mark Document.Entity.type as REQUIRED in all versions ([#317](https://github.com/googleapis/python-documentai/issues/317)) ([2d82c64](https://github.com/googleapis/python-documentai/commit/2d82c64b5034bb6315031c31a11198a6f3b7f393)) +* remove Document.Entity.bounding_poly_for_demo_frontend from v1beta2 ([2d82c64](https://github.com/googleapis/python-documentai/commit/2d82c64b5034bb6315031c31a11198a6f3b7f393)) + ## [1.4.0](https://github.com/googleapis/python-documentai/compare/v1.3.0...v1.4.0) (2022-03-19) diff --git a/setup.py b/setup.py index 6895b76a..6392f42e 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ import setuptools # type: ignore -version = "1.4.0" +version = "1.4.1" package_root = os.path.abspath(os.path.dirname(__file__))