Skip to content

Commit

Permalink
feat: [google-cloud-documentai] Updated the exponential backoff setti…
Browse files Browse the repository at this point in the history
…ngs for the Document AI ProcessDocument and BatchProcessDocuments methods (#13182)

- [ ] Regenerate this pull request now.

BEGIN_COMMIT_OVERRIDE
feat: Add RESOURCE_EXHAUSTED to retryable status codes for
ProcessDocument method
feat: Updated the exponential backoff settings for the Document AI
ProcessDocument and BatchProcessDocuments methods
END_COMMIT_OVERRIDE



PiperOrigin-RevId: 687393779

Source-Link:
googleapis/googleapis@211a72f

Source-Link:
googleapis/googleapis-gen@7546101
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6Ijc1NDYxMDFkNTM0YzRlNmJjMzA2OWQ4ZjFjM2JlNGVmM2FiYjRiMmUifQ==

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Oct 19, 2024
1 parent 046e080 commit 98a4a8d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ def _prep_wrapped_messages(self, client_info):
self.process_document: gapic_v1.method.wrap_method(
self.process_document,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
initial=1.0,
maximum=90.0,
multiplier=9.0,
predicate=retries.if_exception_type(
core_exceptions.DeadlineExceeded,
core_exceptions.ResourceExhausted,
core_exceptions.ServiceUnavailable,
),
deadline=300.0,
Expand All @@ -151,9 +152,9 @@ def _prep_wrapped_messages(self, client_info):
self.batch_process_documents: gapic_v1.method.wrap_method(
self.batch_process_documents,
default_retry=retries.Retry(
initial=0.1,
initial=1.0,
maximum=60.0,
multiplier=1.3,
multiplier=1.5,
predicate=retries.if_exception_type(
core_exceptions.DeadlineExceeded,
core_exceptions.ServiceUnavailable,
Expand Down Expand Up @@ -246,9 +247,9 @@ def _prep_wrapped_messages(self, client_info):
self.review_document: gapic_v1.method.wrap_method(
self.review_document,
default_retry=retries.Retry(
initial=0.1,
initial=1.0,
maximum=60.0,
multiplier=1.3,
multiplier=1.5,
predicate=retries.if_exception_type(
core_exceptions.DeadlineExceeded,
core_exceptions.ServiceUnavailable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,11 +966,12 @@ def _prep_wrapped_messages(self, client_info):
self.process_document: self._wrap_method(
self.process_document,
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
initial=1.0,
maximum=90.0,
multiplier=9.0,
predicate=retries.if_exception_type(
core_exceptions.DeadlineExceeded,
core_exceptions.ResourceExhausted,
core_exceptions.ServiceUnavailable,
),
deadline=300.0,
Expand All @@ -981,9 +982,9 @@ def _prep_wrapped_messages(self, client_info):
self.batch_process_documents: self._wrap_method(
self.batch_process_documents,
default_retry=retries.AsyncRetry(
initial=0.1,
initial=1.0,
maximum=60.0,
multiplier=1.3,
multiplier=1.5,
predicate=retries.if_exception_type(
core_exceptions.DeadlineExceeded,
core_exceptions.ServiceUnavailable,
Expand Down Expand Up @@ -1076,9 +1077,9 @@ def _prep_wrapped_messages(self, client_info):
self.review_document: self._wrap_method(
self.review_document,
default_retry=retries.AsyncRetry(
initial=0.1,
initial=1.0,
maximum=60.0,
multiplier=1.3,
multiplier=1.5,
predicate=retries.if_exception_type(
core_exceptions.DeadlineExceeded,
core_exceptions.ServiceUnavailable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ class DatasetSchema(proto.Message):
``projects/{project}/locations/{location}/processors/{processor}/dataset/datasetSchema``
document_schema (google.cloud.documentai_v1beta3.types.DocumentSchema):
Optional. Schema of the dataset.
satisfies_pzs (bool):
Output only. Reserved for future use.
satisfies_pzi (bool):
Output only. Reserved for future use.
"""

name: str = proto.Field(
Expand All @@ -290,6 +294,14 @@ class DatasetSchema(proto.Message):
number=3,
message=gcd_document_schema.DocumentSchema,
)
satisfies_pzs: bool = proto.Field(
proto.BOOL,
number=4,
)
satisfies_pzi: bool = proto.Field(
proto.BOOL,
number=5,
)


class BatchDatasetDocuments(proto.Message):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3091,6 +3091,8 @@ def test_get_dataset_schema(request_type, transport: str = "grpc"):
# Designate an appropriate return value for the call.
call.return_value = dataset.DatasetSchema(
name="name_value",
satisfies_pzs=True,
satisfies_pzi=True,
)
response = client.get_dataset_schema(request)

Expand All @@ -3103,6 +3105,8 @@ def test_get_dataset_schema(request_type, transport: str = "grpc"):
# Establish that the response is the type that we expect.
assert isinstance(response, dataset.DatasetSchema)
assert response.name == "name_value"
assert response.satisfies_pzs is True
assert response.satisfies_pzi is True


def test_get_dataset_schema_non_empty_request_with_auto_populated_field():
Expand Down Expand Up @@ -3238,6 +3242,8 @@ async def test_get_dataset_schema_async(
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
dataset.DatasetSchema(
name="name_value",
satisfies_pzs=True,
satisfies_pzi=True,
)
)
response = await client.get_dataset_schema(request)
Expand All @@ -3251,6 +3257,8 @@ async def test_get_dataset_schema_async(
# Establish that the response is the type that we expect.
assert isinstance(response, dataset.DatasetSchema)
assert response.name == "name_value"
assert response.satisfies_pzs is True
assert response.satisfies_pzi is True


@pytest.mark.asyncio
Expand Down Expand Up @@ -3433,6 +3441,8 @@ def test_update_dataset_schema(request_type, transport: str = "grpc"):
# Designate an appropriate return value for the call.
call.return_value = dataset.DatasetSchema(
name="name_value",
satisfies_pzs=True,
satisfies_pzi=True,
)
response = client.update_dataset_schema(request)

Expand All @@ -3445,6 +3455,8 @@ def test_update_dataset_schema(request_type, transport: str = "grpc"):
# Establish that the response is the type that we expect.
assert isinstance(response, dataset.DatasetSchema)
assert response.name == "name_value"
assert response.satisfies_pzs is True
assert response.satisfies_pzi is True


def test_update_dataset_schema_non_empty_request_with_auto_populated_field():
Expand Down Expand Up @@ -3577,6 +3589,8 @@ async def test_update_dataset_schema_async(
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
dataset.DatasetSchema(
name="name_value",
satisfies_pzs=True,
satisfies_pzi=True,
)
)
response = await client.update_dataset_schema(request)
Expand All @@ -3590,6 +3604,8 @@ async def test_update_dataset_schema_async(
# Establish that the response is the type that we expect.
assert isinstance(response, dataset.DatasetSchema)
assert response.name == "name_value"
assert response.satisfies_pzs is True
assert response.satisfies_pzi is True


@pytest.mark.asyncio
Expand Down Expand Up @@ -5561,6 +5577,8 @@ async def test_get_dataset_schema_empty_call_grpc_asyncio():
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
dataset.DatasetSchema(
name="name_value",
satisfies_pzs=True,
satisfies_pzi=True,
)
)
await client.get_dataset_schema(request=None)
Expand Down Expand Up @@ -5590,6 +5608,8 @@ async def test_update_dataset_schema_empty_call_grpc_asyncio():
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
dataset.DatasetSchema(
name="name_value",
satisfies_pzs=True,
satisfies_pzi=True,
)
)
await client.update_dataset_schema(request=None)
Expand Down Expand Up @@ -6350,6 +6370,8 @@ def test_get_dataset_schema_rest_call_success(request_type):
# Designate an appropriate value for the returned response.
return_value = dataset.DatasetSchema(
name="name_value",
satisfies_pzs=True,
satisfies_pzi=True,
)

# Wrap the value into a proper Response obj
Expand All @@ -6366,6 +6388,8 @@ def test_get_dataset_schema_rest_call_success(request_type):
# Establish that the response is the type that we expect.
assert isinstance(response, dataset.DatasetSchema)
assert response.name == "name_value"
assert response.satisfies_pzs is True
assert response.satisfies_pzi is True


@pytest.mark.parametrize("null_interceptor", [True, False])
Expand Down Expand Up @@ -6507,6 +6531,8 @@ def test_update_dataset_schema_rest_call_success(request_type):
"skip_naming_validation": True,
},
},
"satisfies_pzs": True,
"satisfies_pzi": True,
}
# The version of a generated dependency at test runtime may differ from the version used during generation.
# Delete any fields which are not present in the current runtime dependency
Expand Down Expand Up @@ -6584,6 +6610,8 @@ def get_message_fields(field):
# Designate an appropriate value for the returned response.
return_value = dataset.DatasetSchema(
name="name_value",
satisfies_pzs=True,
satisfies_pzi=True,
)

# Wrap the value into a proper Response obj
Expand All @@ -6600,6 +6628,8 @@ def get_message_fields(field):
# Establish that the response is the type that we expect.
assert isinstance(response, dataset.DatasetSchema)
assert response.name == "name_value"
assert response.satisfies_pzs is True
assert response.satisfies_pzi is True


@pytest.mark.parametrize("null_interceptor", [True, False])
Expand Down

0 comments on commit 98a4a8d

Please sign in to comment.