From e7e9263c2b5e684d1232a7772cb77472b6e41aea Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Fri, 2 Dec 2022 16:50:24 +0100 Subject: [PATCH 1/4] chore(deps): update dependency google-cloud-documentai to v2.4.0 (#423) --- 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 c497f7e6..cb18a665 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-documentai==2.3.0 +google-cloud-documentai==2.4.0 google-cloud-storage==2.6.0 From 6b917f4084d13ddaae0f2f8a0669ab163cc22344 Mon Sep 17 00:00:00 2001 From: Holt Skinner <13262395+holtskinner@users.noreply.github.com> Date: Wed, 7 Dec 2022 13:23:26 -0600 Subject: [PATCH 2/4] chore(deps): update dependency google-cloud-storage to v2.7.0 (#426) * chore(deps): update dependency google-cloud-storage to v2.7.0 * docs(samples): removed batch_process_documents_sample_bad_input_test Co-authored-by: Renovate Bot --- ...process_documents_sample_bad_input_test.py | 49 ------------------- samples/snippets/requirements.txt | 2 +- 2 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 samples/snippets/batch_process_documents_sample_bad_input_test.py diff --git a/samples/snippets/batch_process_documents_sample_bad_input_test.py b/samples/snippets/batch_process_documents_sample_bad_input_test.py deleted file mode 100644 index 78c40bd6..00000000 --- a/samples/snippets/batch_process_documents_sample_bad_input_test.py +++ /dev/null @@ -1,49 +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. -# - -import os -from uuid import uuid4 - -from google.api_core.exceptions import InternalServerError, RetryError -from samples.snippets import batch_process_documents_sample - -location = "us" -project_id = os.getenv("GOOGLE_CLOUD_PROJECT") -processor_id = "90484cfdedb024f6" -gcs_input_uri = "gs://cloud-samples-data/documentai/invoice.pdf" -input_mime_type = "application/pdf" -# following bucket contains .csv file which will cause the sample to fail. -gcs_output_full_uri_with_wrong_type = "gs://documentai-beta-samples" -gcs_output_uri_prefix = "test/" -BUCKET_NAME = f"document-ai-python-{uuid4()}" - - -def test_batch_process_documents_with_bad_input(capsys): - try: - batch_process_documents_sample.batch_process_documents( - project_id=project_id, - location=location, - processor_id=processor_id, - gcs_input_uri=gcs_input_uri, - input_mime_type=input_mime_type, - gcs_output_bucket=gcs_output_full_uri_with_wrong_type, - gcs_output_uri_prefix=gcs_output_uri_prefix, - timeout=450, - ) - except ValueError: - out, _ = capsys.readouterr() - assert "Failed" in out or "error" in out - except (InternalServerError, RetryError) as e: - assert "error" in e.message diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index cb18a665..9e5470d6 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,2 +1,2 @@ google-cloud-documentai==2.4.0 -google-cloud-storage==2.6.0 +google-cloud-storage==2.7.0 From ea874a73c6ab98e4096dc49dada4c10e6f1f0731 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 12:22:40 -0800 Subject: [PATCH 3/4] fix(deps): Require google-api-core >=1.34.0, >=2.11.0 (#424) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(deps): Require google-api-core >=1.34.0, >=2.11.0 fix: Drop usage of pkg_resources fix: Fix timeout default values docs(samples): Snippetgen should call await on the operation coroutine before calling result PiperOrigin-RevId: 493260409 Source-Link: https://github.com/googleapis/googleapis/commit/fea43879f83a8d0dacc9353b3f75f8f46d37162f Source-Link: https://github.com/googleapis/googleapis-gen/commit/387b7344c7529ee44be84e613b19a820508c612b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzg3YjczNDRjNzUyOWVlNDRiZTg0ZTYxM2IxOWE4MjA1MDhjNjEyYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add gapic_version.py * fix(deps): require google-api-core>=1.34.0,>=2.11.0 * chore: use templated setup.py and owlbot.py * update version in gapic_version.py * work around generator bug Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .coveragerc | 5 -- .github/release-please.yml | 1 + .release-please-manifest.json | 3 + google/cloud/documentai/gapic_version.py | 2 +- google/cloud/documentai_v1/gapic_version.py | 16 ++++ .../async_client.py | 76 ++++++++-------- .../document_processor_service/client.py | 58 ++++++------ .../transports/base.py | 13 +-- .../cloud/documentai_v1beta2/gapic_version.py | 16 ++++ .../async_client.py | 20 ++--- .../document_understanding_service/client.py | 18 ++-- .../transports/base.py | 13 +-- .../cloud/documentai_v1beta3/gapic_version.py | 16 ++++ .../async_client.py | 88 +++++++++---------- .../document_processor_service/client.py | 66 +++++++------- .../transports/base.py | 13 +-- owlbot.py | 56 ++++++++++++ release-please-config.json | 36 ++++++++ ...r_service_batch_process_documents_async.py | 2 +- ...rocessor_service_delete_processor_async.py | 2 +- ..._service_delete_processor_version_async.py | 2 +- ..._service_deploy_processor_version_async.py | 2 +- ...ocessor_service_disable_processor_async.py | 2 +- ...rocessor_service_enable_processor_async.py | 2 +- ...processor_service_review_document_async.py | 2 +- ...ice_set_default_processor_version_async.py | 2 +- ...ervice_undeploy_processor_version_async.py | 2 +- ...g_service_batch_process_documents_async.py | 2 +- ...r_service_batch_process_documents_async.py | 2 +- ...rocessor_service_delete_processor_async.py | 2 +- ..._service_delete_processor_version_async.py | 2 +- ..._service_deploy_processor_version_async.py | 2 +- ...ocessor_service_disable_processor_async.py | 2 +- ...rocessor_service_enable_processor_async.py | 2 +- ...ervice_evaluate_processor_version_async.py | 2 +- ...processor_service_review_document_async.py | 2 +- ...ice_set_default_processor_version_async.py | 2 +- ...r_service_train_processor_version_async.py | 2 +- ...ervice_undeploy_processor_version_async.py | 2 +- setup.py | 68 +++++++++----- testing/constraints-3.7.txt | 2 +- 41 files changed, 375 insertions(+), 253 deletions(-) create mode 100644 .release-please-manifest.json create mode 100644 google/cloud/documentai_v1/gapic_version.py create mode 100644 google/cloud/documentai_v1beta2/gapic_version.py create mode 100644 google/cloud/documentai_v1beta3/gapic_version.py create mode 100644 owlbot.py create mode 100644 release-please-config.json diff --git a/.coveragerc b/.coveragerc index ef619357..f54a6900 100644 --- a/.coveragerc +++ b/.coveragerc @@ -10,8 +10,3 @@ exclude_lines = pragma: NO COVER # Ignore debug-only repr def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/.github/release-please.yml b/.github/release-please.yml index 29601ad4..fe749ff6 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,5 +1,6 @@ releaseType: python handleGHRelease: true +manifest: true # NOTE: this section is generated by synthtool.languages.python # See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py branches: diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..edb1d1b6 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "2.4.0" +} diff --git a/google/cloud/documentai/gapic_version.py b/google/cloud/documentai/gapic_version.py index 35859c3f..9d82f136 100644 --- a/google/cloud/documentai/gapic_version.py +++ b/google/cloud/documentai/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.0" +__version__ = "2.4.0" # {x-release-please-version} diff --git a/google/cloud/documentai_v1/gapic_version.py b/google/cloud/documentai_v1/gapic_version.py new file mode 100644 index 00000000..9d82f136 --- /dev/null +++ b/google/cloud/documentai_v1/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# 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. +# +__version__ = "2.4.0" # {x-release-please-version} 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 b08da39e..223b9b81 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 @@ -34,7 +34,8 @@ 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 + +from google.cloud.documentai_v1 import gapic_version as package_version try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -265,7 +266,7 @@ async def process_document( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document_processor_service.ProcessResponse: r"""Processes a single document. @@ -392,7 +393,7 @@ async def batch_process_documents( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""LRO endpoint to batch process many documents. The output is @@ -423,7 +424,7 @@ async def sample_batch_process_documents(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -527,7 +528,7 @@ async def fetch_processor_types( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document_processor_service.FetchProcessorTypesResponse: r"""Fetches processor types. Note that we do not use @@ -634,7 +635,7 @@ async def list_processor_types( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorTypesAsyncPager: r"""Lists the processor types that exist. @@ -753,7 +754,7 @@ async def list_processors( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorsAsyncPager: r"""Lists all processors which belong to this project. @@ -870,7 +871,7 @@ async def get_processor( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> processor.Processor: r"""Gets a processor detail. @@ -975,7 +976,7 @@ async def get_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> processor.ProcessorVersion: r"""Gets a processor version detail. @@ -1086,7 +1087,7 @@ async def list_processor_versions( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorVersionsAsyncPager: r"""Lists all versions of a processor. @@ -1203,7 +1204,7 @@ async def delete_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the processor version, all artifacts under @@ -1234,7 +1235,7 @@ async def sample_delete_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1330,7 +1331,7 @@ async def deploy_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deploys the processor version. @@ -1360,7 +1361,7 @@ async def sample_deploy_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1450,7 +1451,7 @@ async def undeploy_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Undeploys the processor version. @@ -1480,7 +1481,7 @@ async def sample_undeploy_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1571,7 +1572,7 @@ async def create_processor( parent: Optional[str] = None, processor: Optional[gcd_processor.Processor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_processor.Processor: r"""Creates a processor from the type processor that the @@ -1692,7 +1693,7 @@ async def delete_processor( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the processor, unloads all deployed model @@ -1724,7 +1725,7 @@ async def sample_delete_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1819,7 +1820,7 @@ async def enable_processor( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Enables a processor @@ -1849,7 +1850,7 @@ async def sample_enable_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1916,7 +1917,7 @@ async def disable_processor( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Disables a processor @@ -1946,7 +1947,7 @@ async def sample_disable_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -2013,7 +2014,7 @@ async def set_default_processor_version( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Set the default (active) version of a @@ -2049,7 +2050,7 @@ async def sample_set_default_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -2120,7 +2121,7 @@ async def review_document( *, human_review_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Send a document for Human Review. The input document @@ -2155,7 +2156,7 @@ async def sample_review_document(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -2254,7 +2255,7 @@ async def list_operations( request: Optional[operations_pb2.ListOperationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2308,7 +2309,7 @@ async def get_operation( request: Optional[operations_pb2.GetOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2362,7 +2363,7 @@ async def cancel_operation( request: Optional[operations_pb2.CancelOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2416,7 +2417,7 @@ async def get_location( request: Optional[locations_pb2.GetLocationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2470,7 +2471,7 @@ async def list_locations( request: Optional[locations_pb2.ListLocationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2526,14 +2527,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-documentai", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("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 f861ba72..d5d8da44 100644 --- a/google/cloud/documentai_v1/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1/services/document_processor_service/client.py @@ -38,7 +38,8 @@ from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.oauth2 import service_account # type: ignore -import pkg_resources + +from google.cloud.documentai_v1 import gapic_version as package_version try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -535,7 +536,7 @@ def process_document( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document_processor_service.ProcessResponse: r"""Processes a single document. @@ -652,7 +653,7 @@ def batch_process_documents( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""LRO endpoint to batch process many documents. The output is @@ -777,7 +778,7 @@ def fetch_processor_types( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document_processor_service.FetchProcessorTypesResponse: r"""Fetches processor types. Note that we do not use @@ -886,7 +887,7 @@ def list_processor_types( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorTypesPager: r"""Lists the processor types that exist. @@ -1007,7 +1008,7 @@ def list_processors( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorsPager: r"""Lists all processors which belong to this project. @@ -1124,7 +1125,7 @@ def get_processor( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> processor.Processor: r"""Gets a processor detail. @@ -1229,7 +1230,7 @@ def get_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> processor.ProcessorVersion: r"""Gets a processor version detail. @@ -1342,7 +1343,7 @@ def list_processor_versions( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorVersionsPager: r"""Lists all versions of a processor. @@ -1461,7 +1462,7 @@ def delete_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deletes the processor version, all artifacts under @@ -1590,7 +1591,7 @@ def deploy_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deploys the processor version. @@ -1712,7 +1713,7 @@ def undeploy_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Undeploys the processor version. @@ -1839,7 +1840,7 @@ def create_processor( parent: Optional[str] = None, processor: Optional[gcd_processor.Processor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_processor.Processor: r"""Creates a processor from the type processor that the @@ -1960,7 +1961,7 @@ def delete_processor( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deletes the processor, unloads all deployed model @@ -2087,7 +2088,7 @@ def enable_processor( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Enables a processor @@ -2185,7 +2186,7 @@ def disable_processor( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Disables a processor @@ -2283,7 +2284,7 @@ def set_default_processor_version( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Set the default (active) version of a @@ -2397,7 +2398,7 @@ def review_document( *, human_review_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Send a document for Human Review. The input document @@ -2534,7 +2535,7 @@ def list_operations( request: Optional[operations_pb2.ListOperationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2588,7 +2589,7 @@ def get_operation( request: Optional[operations_pb2.GetOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2642,7 +2643,7 @@ def cancel_operation( request: Optional[operations_pb2.CancelOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2696,7 +2697,7 @@ def get_location( request: Optional[locations_pb2.GetLocationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2750,7 +2751,7 @@ def list_locations( request: Optional[locations_pb2.ListLocationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2800,14 +2801,9 @@ def list_locations( return response -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-documentai", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("DocumentProcessorServiceClient",) 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 70a6139c..f613cb57 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 @@ -25,20 +25,15 @@ from google.cloud.location import locations_pb2 # 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 import gapic_version as package_version from google.cloud.documentai_v1.types import document_processor_service from google.cloud.documentai_v1.types import processor from google.cloud.documentai_v1.types import processor as gcd_processor -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-documentai", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class DocumentProcessorServiceTransport(abc.ABC): diff --git a/google/cloud/documentai_v1beta2/gapic_version.py b/google/cloud/documentai_v1beta2/gapic_version.py new file mode 100644 index 00000000..9d82f136 --- /dev/null +++ b/google/cloud/documentai_v1beta2/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# 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. +# +__version__ = "2.4.0" # {x-release-please-version} 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 d69ab1ac..079b4ed8 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 @@ -34,7 +34,8 @@ 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 + +from google.cloud.documentai_v1beta2 import gapic_version as package_version try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -234,7 +235,7 @@ async def batch_process_documents( MutableSequence[document_understanding.ProcessDocumentRequest] ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""LRO endpoint to batch process many documents. The output is @@ -269,7 +270,7 @@ async def sample_batch_process_documents(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -367,7 +368,7 @@ async def process_document( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document.Document: r"""Processes a single document. @@ -467,14 +468,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-documentai", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("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 a3dbf341..473a26aa 100644 --- a/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py +++ b/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py @@ -38,7 +38,8 @@ from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.oauth2 import service_account # type: ignore -import pkg_resources + +from google.cloud.documentai_v1beta2 import gapic_version as package_version try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -438,7 +439,7 @@ def batch_process_documents( MutableSequence[document_understanding.ProcessDocumentRequest] ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""LRO endpoint to batch process many documents. The output is @@ -561,7 +562,7 @@ def process_document( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document.Document: r"""Processes a single document. @@ -659,14 +660,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-documentai", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("DocumentUnderstandingServiceClient",) 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 cd1dd55b..bfbee62e 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 @@ -24,18 +24,13 @@ 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 import gapic_version as package_version from google.cloud.documentai_v1beta2.types import document, document_understanding -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-documentai", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class DocumentUnderstandingServiceTransport(abc.ABC): diff --git a/google/cloud/documentai_v1beta3/gapic_version.py b/google/cloud/documentai_v1beta3/gapic_version.py new file mode 100644 index 00000000..9d82f136 --- /dev/null +++ b/google/cloud/documentai_v1beta3/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# 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. +# +__version__ = "2.4.0" # {x-release-please-version} 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 54ab219e..2a6366e9 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 @@ -34,7 +34,8 @@ 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 + +from google.cloud.documentai_v1beta3 import gapic_version as package_version try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -270,7 +271,7 @@ async def process_document( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document_processor_service.ProcessResponse: r"""Processes a single document. @@ -398,7 +399,7 @@ async def batch_process_documents( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""LRO endpoint to batch process many documents. The output is @@ -429,7 +430,7 @@ async def sample_batch_process_documents(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -534,7 +535,7 @@ async def fetch_processor_types( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document_processor_service.FetchProcessorTypesResponse: r"""Fetches processor types. Note that we do not use @@ -641,7 +642,7 @@ async def list_processor_types( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorTypesAsyncPager: r"""Lists the processor types that exist. @@ -760,7 +761,7 @@ async def list_processors( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorsAsyncPager: r"""Lists all processors which belong to this project. @@ -877,7 +878,7 @@ async def get_processor( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> processor.Processor: r"""Gets a processor detail. @@ -983,7 +984,7 @@ async def train_processor_version( parent: Optional[str] = None, processor_version: Optional[processor.ProcessorVersion] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Trains a new processor version. Operation metadata is returned @@ -1014,7 +1015,7 @@ async def sample_train_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1113,7 +1114,7 @@ async def get_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> processor.ProcessorVersion: r"""Gets a processor version detail. @@ -1224,7 +1225,7 @@ async def list_processor_versions( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorVersionsAsyncPager: r"""Lists all versions of a processor. @@ -1341,7 +1342,7 @@ async def delete_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the processor version, all artifacts under @@ -1372,7 +1373,7 @@ async def sample_delete_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1468,7 +1469,7 @@ async def deploy_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deploys the processor version. @@ -1498,7 +1499,7 @@ async def sample_deploy_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1588,7 +1589,7 @@ async def undeploy_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Undeploys the processor version. @@ -1618,7 +1619,7 @@ async def sample_undeploy_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1709,7 +1710,7 @@ async def create_processor( parent: Optional[str] = None, processor: Optional[gcd_processor.Processor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_processor.Processor: r"""Creates a processor from the type processor that the @@ -1830,7 +1831,7 @@ async def delete_processor( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the processor, unloads all deployed model @@ -1862,7 +1863,7 @@ async def sample_delete_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -1957,7 +1958,7 @@ async def enable_processor( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Enables a processor @@ -1987,7 +1988,7 @@ async def sample_enable_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -2054,7 +2055,7 @@ async def disable_processor( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Disables a processor @@ -2084,7 +2085,7 @@ async def sample_disable_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -2151,7 +2152,7 @@ async def set_default_processor_version( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Set the default (active) version of a @@ -2187,7 +2188,7 @@ async def sample_set_default_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -2258,7 +2259,7 @@ async def review_document( *, human_review_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Send a document for Human Review. The input document @@ -2293,7 +2294,7 @@ async def sample_review_document(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -2395,7 +2396,7 @@ async def evaluate_processor_version( *, processor_version: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Evaluates a ProcessorVersion against annotated @@ -2426,7 +2427,7 @@ async def sample_evaluate_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -2519,7 +2520,7 @@ async def get_evaluation( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> evaluation.Evaluation: r"""Retrieves a specific evaluation. @@ -2624,7 +2625,7 @@ async def list_evaluations( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListEvaluationsAsyncPager: r"""Retrieves a set of evaluations for a given processor @@ -2740,7 +2741,7 @@ async def list_operations( request: Optional[operations_pb2.ListOperationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2794,7 +2795,7 @@ async def get_operation( request: Optional[operations_pb2.GetOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2848,7 +2849,7 @@ async def cancel_operation( request: Optional[operations_pb2.CancelOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2902,7 +2903,7 @@ async def get_location( request: Optional[locations_pb2.GetLocationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2956,7 +2957,7 @@ async def list_locations( request: Optional[locations_pb2.ListLocationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3012,14 +3013,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-documentai", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("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 acae0661..0c2980c8 100644 --- a/google/cloud/documentai_v1beta3/services/document_processor_service/client.py +++ b/google/cloud/documentai_v1beta3/services/document_processor_service/client.py @@ -38,7 +38,8 @@ from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.oauth2 import service_account # type: ignore -import pkg_resources + +from google.cloud.documentai_v1beta3 import gapic_version as package_version try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -562,7 +563,7 @@ def process_document( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document_processor_service.ProcessResponse: r"""Processes a single document. @@ -680,7 +681,7 @@ def batch_process_documents( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""LRO endpoint to batch process many documents. The output is @@ -806,7 +807,7 @@ def fetch_processor_types( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> document_processor_service.FetchProcessorTypesResponse: r"""Fetches processor types. Note that we do not use @@ -915,7 +916,7 @@ def list_processor_types( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorTypesPager: r"""Lists the processor types that exist. @@ -1036,7 +1037,7 @@ def list_processors( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorsPager: r"""Lists all processors which belong to this project. @@ -1153,7 +1154,7 @@ def get_processor( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> processor.Processor: r"""Gets a processor detail. @@ -1259,7 +1260,7 @@ def train_processor_version( parent: Optional[str] = None, processor_version: Optional[processor.ProcessorVersion] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Trains a new processor version. Operation metadata is returned @@ -1391,7 +1392,7 @@ def get_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> processor.ProcessorVersion: r"""Gets a processor version detail. @@ -1504,7 +1505,7 @@ def list_processor_versions( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListProcessorVersionsPager: r"""Lists all versions of a processor. @@ -1623,7 +1624,7 @@ def delete_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deletes the processor version, all artifacts under @@ -1752,7 +1753,7 @@ def deploy_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deploys the processor version. @@ -1874,7 +1875,7 @@ def undeploy_processor_version( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Undeploys the processor version. @@ -2001,7 +2002,7 @@ def create_processor( parent: Optional[str] = None, processor: Optional[gcd_processor.Processor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_processor.Processor: r"""Creates a processor from the type processor that the @@ -2122,7 +2123,7 @@ def delete_processor( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deletes the processor, unloads all deployed model @@ -2249,7 +2250,7 @@ def enable_processor( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Enables a processor @@ -2347,7 +2348,7 @@ def disable_processor( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Disables a processor @@ -2445,7 +2446,7 @@ def set_default_processor_version( ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Set the default (active) version of a @@ -2559,7 +2560,7 @@ def review_document( *, human_review_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Send a document for Human Review. The input document @@ -2686,7 +2687,7 @@ def evaluate_processor_version( *, processor_version: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Evaluates a ProcessorVersion against annotated @@ -2816,7 +2817,7 @@ def get_evaluation( *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> evaluation.Evaluation: r"""Retrieves a specific evaluation. @@ -2921,7 +2922,7 @@ def list_evaluations( *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListEvaluationsPager: r"""Retrieves a set of evaluations for a given processor @@ -3050,7 +3051,7 @@ def list_operations( request: Optional[operations_pb2.ListOperationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3104,7 +3105,7 @@ def get_operation( request: Optional[operations_pb2.GetOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3158,7 +3159,7 @@ def cancel_operation( request: Optional[operations_pb2.CancelOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3212,7 +3213,7 @@ def get_location( request: Optional[locations_pb2.GetLocationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3266,7 +3267,7 @@ def list_locations( request: Optional[locations_pb2.ListLocationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3316,14 +3317,9 @@ def list_locations( return response -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-documentai", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("DocumentProcessorServiceClient",) 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 92033dfd..ed4c7110 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 @@ -25,20 +25,15 @@ from google.cloud.location import locations_pb2 # 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 import gapic_version as package_version from google.cloud.documentai_v1beta3.types import document_processor_service, evaluation from google.cloud.documentai_v1beta3.types import processor from google.cloud.documentai_v1beta3.types import processor as gcd_processor -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-documentai", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class DocumentProcessorServiceTransport(abc.ABC): diff --git a/owlbot.py b/owlbot.py new file mode 100644 index 00000000..59344fad --- /dev/null +++ b/owlbot.py @@ -0,0 +1,56 @@ +# 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. + +import json +from pathlib import Path +import shutil + +import synthtool as s +import synthtool.gcp as gcp +from synthtool.languages import python + +# ---------------------------------------------------------------------------- +# Copy the generated client from the owl-bot staging directory +# ---------------------------------------------------------------------------- + +clean_up_generated_samples = True + +# Load the default version defined in .repo-metadata.json. +default_version = json.load(open(".repo-metadata.json", "rt")).get( + "default_version" +) + +for library in s.get_staging_dirs(default_version): + if clean_up_generated_samples: + shutil.rmtree("samples/generated_samples", ignore_errors=True) + clean_up_generated_samples = False + s.move([library], excludes=["**/gapic_version.py", "setup.py", "testing/constraints-3.7.txt"]) +s.remove_staging_dirs() + +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- + +templated_files = gcp.CommonTemplates().py_library( + cov_level=100, + microgenerator=True, + versions=gcp.common.detect_versions(path="./google", default_first=True), +) +s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"]) + +python.py_samples(skip_readmes=True) + +# run format session for all directories which have a noxfile +for noxfile in Path(".").glob("**/noxfile.py"): + s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False) diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..e24b254d --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "python", + "extra-files": [ + "google/cloud/documentai_v1/gapic_version.py", + "google/cloud/documentai_v1beta3/gapic_version.py", + "google/cloud/documentai_v1beta2/gapic_version.py", + "google/cloud/documentai/gapic_version.py", + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.cloud.documentai.v1.json", + "jsonpath": "$.clientLibrary.version" + }, + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta2.json", + "jsonpath": "$.clientLibrary.version" + }, + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta3.json", + "jsonpath": "$.clientLibrary.version" + } + ] + } + }, + "release-type": "python", + "plugins": [ + { + "type": "sentence-case" + } + ], + "initial-version": "0.1.0" +} diff --git a/samples/generated_samples/documentai_v1_generated_document_processor_service_batch_process_documents_async.py b/samples/generated_samples/documentai_v1_generated_document_processor_service_batch_process_documents_async.py index ab05d521..5801f218 100644 --- a/samples/generated_samples/documentai_v1_generated_document_processor_service_batch_process_documents_async.py +++ b/samples/generated_samples/documentai_v1_generated_document_processor_service_batch_process_documents_async.py @@ -48,7 +48,7 @@ async def sample_batch_process_documents(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1_generated_document_processor_service_delete_processor_async.py b/samples/generated_samples/documentai_v1_generated_document_processor_service_delete_processor_async.py index d5e09e0b..e72258a3 100644 --- a/samples/generated_samples/documentai_v1_generated_document_processor_service_delete_processor_async.py +++ b/samples/generated_samples/documentai_v1_generated_document_processor_service_delete_processor_async.py @@ -48,7 +48,7 @@ async def sample_delete_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1_generated_document_processor_service_delete_processor_version_async.py b/samples/generated_samples/documentai_v1_generated_document_processor_service_delete_processor_version_async.py index 432fa835..e760dbd7 100644 --- a/samples/generated_samples/documentai_v1_generated_document_processor_service_delete_processor_version_async.py +++ b/samples/generated_samples/documentai_v1_generated_document_processor_service_delete_processor_version_async.py @@ -48,7 +48,7 @@ async def sample_delete_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1_generated_document_processor_service_deploy_processor_version_async.py b/samples/generated_samples/documentai_v1_generated_document_processor_service_deploy_processor_version_async.py index d1db083a..af78c036 100644 --- a/samples/generated_samples/documentai_v1_generated_document_processor_service_deploy_processor_version_async.py +++ b/samples/generated_samples/documentai_v1_generated_document_processor_service_deploy_processor_version_async.py @@ -48,7 +48,7 @@ async def sample_deploy_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1_generated_document_processor_service_disable_processor_async.py b/samples/generated_samples/documentai_v1_generated_document_processor_service_disable_processor_async.py index 06ee5d32..17653881 100644 --- a/samples/generated_samples/documentai_v1_generated_document_processor_service_disable_processor_async.py +++ b/samples/generated_samples/documentai_v1_generated_document_processor_service_disable_processor_async.py @@ -48,7 +48,7 @@ async def sample_disable_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1_generated_document_processor_service_enable_processor_async.py b/samples/generated_samples/documentai_v1_generated_document_processor_service_enable_processor_async.py index 12c59704..83554c7a 100644 --- a/samples/generated_samples/documentai_v1_generated_document_processor_service_enable_processor_async.py +++ b/samples/generated_samples/documentai_v1_generated_document_processor_service_enable_processor_async.py @@ -48,7 +48,7 @@ async def sample_enable_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1_generated_document_processor_service_review_document_async.py b/samples/generated_samples/documentai_v1_generated_document_processor_service_review_document_async.py index 4700daab..cc3a8df1 100644 --- a/samples/generated_samples/documentai_v1_generated_document_processor_service_review_document_async.py +++ b/samples/generated_samples/documentai_v1_generated_document_processor_service_review_document_async.py @@ -52,7 +52,7 @@ async def sample_review_document(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1_generated_document_processor_service_set_default_processor_version_async.py b/samples/generated_samples/documentai_v1_generated_document_processor_service_set_default_processor_version_async.py index a5169b81..97cfcb35 100644 --- a/samples/generated_samples/documentai_v1_generated_document_processor_service_set_default_processor_version_async.py +++ b/samples/generated_samples/documentai_v1_generated_document_processor_service_set_default_processor_version_async.py @@ -49,7 +49,7 @@ async def sample_set_default_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1_generated_document_processor_service_undeploy_processor_version_async.py b/samples/generated_samples/documentai_v1_generated_document_processor_service_undeploy_processor_version_async.py index 008f9516..b25557e8 100644 --- a/samples/generated_samples/documentai_v1_generated_document_processor_service_undeploy_processor_version_async.py +++ b/samples/generated_samples/documentai_v1_generated_document_processor_service_undeploy_processor_version_async.py @@ -48,7 +48,7 @@ async def sample_undeploy_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta2_generated_document_understanding_service_batch_process_documents_async.py b/samples/generated_samples/documentai_v1beta2_generated_document_understanding_service_batch_process_documents_async.py index f7e34352..366d8b41 100644 --- a/samples/generated_samples/documentai_v1beta2_generated_document_understanding_service_batch_process_documents_async.py +++ b/samples/generated_samples/documentai_v1beta2_generated_document_understanding_service_batch_process_documents_async.py @@ -52,7 +52,7 @@ async def sample_batch_process_documents(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_batch_process_documents_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_batch_process_documents_async.py index dd97b90e..9a52ef4a 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_batch_process_documents_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_batch_process_documents_async.py @@ -48,7 +48,7 @@ async def sample_batch_process_documents(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_delete_processor_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_delete_processor_async.py index b8397493..54141136 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_delete_processor_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_delete_processor_async.py @@ -48,7 +48,7 @@ async def sample_delete_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_delete_processor_version_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_delete_processor_version_async.py index 229084ec..16913bec 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_delete_processor_version_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_delete_processor_version_async.py @@ -48,7 +48,7 @@ async def sample_delete_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_deploy_processor_version_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_deploy_processor_version_async.py index 9f279130..e5b67ec9 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_deploy_processor_version_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_deploy_processor_version_async.py @@ -48,7 +48,7 @@ async def sample_deploy_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_disable_processor_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_disable_processor_async.py index 2038e476..2bc67064 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_disable_processor_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_disable_processor_async.py @@ -48,7 +48,7 @@ async def sample_disable_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_enable_processor_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_enable_processor_async.py index 2ad6428a..8d4dfd9e 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_enable_processor_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_enable_processor_async.py @@ -48,7 +48,7 @@ async def sample_enable_processor(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_evaluate_processor_version_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_evaluate_processor_version_async.py index 4d8177fc..8290b418 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_evaluate_processor_version_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_evaluate_processor_version_async.py @@ -48,7 +48,7 @@ async def sample_evaluate_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_review_document_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_review_document_async.py index 719b19ae..ddafdd90 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_review_document_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_review_document_async.py @@ -52,7 +52,7 @@ async def sample_review_document(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_set_default_processor_version_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_set_default_processor_version_async.py index b1b1fa67..bf49fea1 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_set_default_processor_version_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_set_default_processor_version_async.py @@ -49,7 +49,7 @@ async def sample_set_default_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_train_processor_version_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_train_processor_version_async.py index 38c225e2..e1c21207 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_train_processor_version_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_train_processor_version_async.py @@ -48,7 +48,7 @@ async def sample_train_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_undeploy_processor_version_async.py b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_undeploy_processor_version_async.py index 0aa0e74f..fbbc23db 100644 --- a/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_undeploy_processor_version_async.py +++ b/samples/generated_samples/documentai_v1beta3_generated_document_processor_service_undeploy_processor_version_async.py @@ -48,7 +48,7 @@ async def sample_undeploy_processor_version(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) diff --git a/setup.py b/setup.py index a027c9d6..309b6760 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -# Copyright (C) 2019 Google LLC +# 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. @@ -14,13 +13,34 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import io import os import setuptools # type: ignore -version = "2.4.0" +package_root = os.path.abspath(os.path.dirname(__file__)) + +name = "google-cloud-documentai" + + +description = "Google Cloud Documentai API client library" + +version = {} +with open(os.path.join(package_root, "google/cloud/documentai/gapic_version.py")) as fp: + exec(fp.read(), version) +version = version["__version__"] + +if version[0] == "0": + release_status = "Development Status :: 4 - Beta" +else: + release_status = "Development Status :: 5 - Production/Stable" + +dependencies = [ + "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", + "proto-plus >= 1.22.0, <2.0.0dev", + "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", +] +url = "https://github.com/googleapis/python-documentai" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -28,41 +48,43 @@ with io.open(readme_filename, encoding="utf-8") as readme_file: readme = readme_file.read() +packages = [ + package + for package in setuptools.PEP420PackageFinder.find() + if package.startswith("google") +] + +namespaces = ["google"] +if "google.cloud" in packages: + namespaces.append("google.cloud") setuptools.setup( - name="google-cloud-documentai", + name=name, version=version, + description=description, long_description=readme, author="Google LLC", author_email="googleapis-packages@google.com", license="Apache 2.0", - url="https://github.com/googleapis/python-documentai", - packages=[ - package - for package in setuptools.PEP420PackageFinder.find() - if package.startswith("google") - ], - namespace_packages=("google", "google.cloud"), - platforms="Posix; MacOS X; Windows", - include_package_data=True, - install_requires=( - "google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", - "proto-plus >= 1.22.0, <2.0.0dev", - "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", - ), - python_requires=">=3.7", + url=url, classifiers=[ - "Development Status :: 5 - Production/Stable", + release_status, "Intended Audience :: Developers", - "Operating System :: OS Independent", + "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Operating System :: OS Independent", "Topic :: Internet", - "Topic :: Software Development :: Libraries :: Python Modules", ], + platforms="Posix; MacOS X; Windows", + packages=packages, + python_requires=">=3.7", + namespace_packages=namespaces, + install_requires=dependencies, + include_package_data=True, zip_safe=False, ) diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index 6f3158cc..6c44adfe 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -4,6 +4,6 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.33.2 +google-api-core==1.34.0 proto-plus==1.22.0 protobuf==3.19.5 From 546b8077260b9e1f56c9e94a653888502f754919 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 17:04:59 -0600 Subject: [PATCH 4/4] chore(main): release 2.4.1 (#427) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 7 +++++++ google/cloud/documentai/gapic_version.py | 2 +- google/cloud/documentai_v1/gapic_version.py | 2 +- google/cloud/documentai_v1beta2/gapic_version.py | 2 +- google/cloud/documentai_v1beta3/gapic_version.py | 2 +- .../snippet_metadata_google.cloud.documentai.v1.json | 2 +- .../snippet_metadata_google.cloud.documentai.v1beta2.json | 2 +- .../snippet_metadata_google.cloud.documentai.v1beta3.json | 2 +- 9 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index edb1d1b6..5ae02a9c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.4.0" + ".": "2.4.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bd833cd..a81a1c30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [2.4.1](https://github.com/googleapis/python-documentai/compare/v2.4.0...v2.4.1) (2022-12-07) + + +### Bug Fixes + +* **deps:** Require google-api-core >=1.34.0, >=2.11.0 ([#424](https://github.com/googleapis/python-documentai/issues/424)) ([ea874a7](https://github.com/googleapis/python-documentai/commit/ea874a73c6ab98e4096dc49dada4c10e6f1f0731)) + ## [2.4.0](https://github.com/googleapis/python-documentai/compare/v2.3.0...v2.4.0) (2022-11-27) diff --git a/google/cloud/documentai/gapic_version.py b/google/cloud/documentai/gapic_version.py index 9d82f136..65e61d1c 100644 --- a/google/cloud/documentai/gapic_version.py +++ b/google/cloud/documentai/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.4.0" # {x-release-please-version} +__version__ = "2.4.1" # {x-release-please-version} diff --git a/google/cloud/documentai_v1/gapic_version.py b/google/cloud/documentai_v1/gapic_version.py index 9d82f136..65e61d1c 100644 --- a/google/cloud/documentai_v1/gapic_version.py +++ b/google/cloud/documentai_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.4.0" # {x-release-please-version} +__version__ = "2.4.1" # {x-release-please-version} diff --git a/google/cloud/documentai_v1beta2/gapic_version.py b/google/cloud/documentai_v1beta2/gapic_version.py index 9d82f136..65e61d1c 100644 --- a/google/cloud/documentai_v1beta2/gapic_version.py +++ b/google/cloud/documentai_v1beta2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.4.0" # {x-release-please-version} +__version__ = "2.4.1" # {x-release-please-version} diff --git a/google/cloud/documentai_v1beta3/gapic_version.py b/google/cloud/documentai_v1beta3/gapic_version.py index 9d82f136..65e61d1c 100644 --- a/google/cloud/documentai_v1beta3/gapic_version.py +++ b/google/cloud/documentai_v1beta3/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.4.0" # {x-release-please-version} +__version__ = "2.4.1" # {x-release-please-version} diff --git a/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1.json b/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1.json index 5064960d..2bb605e9 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-documentai", - "version": "0.1.0" + "version": "2.4.1" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta2.json b/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta2.json index ef56bd7e..4dad7146 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta2.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-documentai", - "version": "0.1.0" + "version": "2.4.1" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta3.json b/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta3.json index e88607d5..4b5d387c 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta3.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.documentai.v1beta3.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-documentai", - "version": "0.1.0" + "version": "2.4.1" }, "snippets": [ {