Skip to content

Commit 98a4a8d

Browse files
feat: [google-cloud-documentai] Updated the exponential backoff settings 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>
1 parent 046e080 commit 98a4a8d

4 files changed

Lines changed: 58 additions & 14 deletions

File tree

packages/google-cloud-documentai/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ def _prep_wrapped_messages(self, client_info):
136136
self.process_document: gapic_v1.method.wrap_method(
137137
self.process_document,
138138
default_retry=retries.Retry(
139-
initial=0.1,
140-
maximum=60.0,
141-
multiplier=1.3,
139+
initial=1.0,
140+
maximum=90.0,
141+
multiplier=9.0,
142142
predicate=retries.if_exception_type(
143143
core_exceptions.DeadlineExceeded,
144+
core_exceptions.ResourceExhausted,
144145
core_exceptions.ServiceUnavailable,
145146
),
146147
deadline=300.0,
@@ -151,9 +152,9 @@ def _prep_wrapped_messages(self, client_info):
151152
self.batch_process_documents: gapic_v1.method.wrap_method(
152153
self.batch_process_documents,
153154
default_retry=retries.Retry(
154-
initial=0.1,
155+
initial=1.0,
155156
maximum=60.0,
156-
multiplier=1.3,
157+
multiplier=1.5,
157158
predicate=retries.if_exception_type(
158159
core_exceptions.DeadlineExceeded,
159160
core_exceptions.ServiceUnavailable,
@@ -246,9 +247,9 @@ def _prep_wrapped_messages(self, client_info):
246247
self.review_document: gapic_v1.method.wrap_method(
247248
self.review_document,
248249
default_retry=retries.Retry(
249-
initial=0.1,
250+
initial=1.0,
250251
maximum=60.0,
251-
multiplier=1.3,
252+
multiplier=1.5,
252253
predicate=retries.if_exception_type(
253254
core_exceptions.DeadlineExceeded,
254255
core_exceptions.ServiceUnavailable,

packages/google-cloud-documentai/google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -966,11 +966,12 @@ def _prep_wrapped_messages(self, client_info):
966966
self.process_document: self._wrap_method(
967967
self.process_document,
968968
default_retry=retries.AsyncRetry(
969-
initial=0.1,
970-
maximum=60.0,
971-
multiplier=1.3,
969+
initial=1.0,
970+
maximum=90.0,
971+
multiplier=9.0,
972972
predicate=retries.if_exception_type(
973973
core_exceptions.DeadlineExceeded,
974+
core_exceptions.ResourceExhausted,
974975
core_exceptions.ServiceUnavailable,
975976
),
976977
deadline=300.0,
@@ -981,9 +982,9 @@ def _prep_wrapped_messages(self, client_info):
981982
self.batch_process_documents: self._wrap_method(
982983
self.batch_process_documents,
983984
default_retry=retries.AsyncRetry(
984-
initial=0.1,
985+
initial=1.0,
985986
maximum=60.0,
986-
multiplier=1.3,
987+
multiplier=1.5,
987988
predicate=retries.if_exception_type(
988989
core_exceptions.DeadlineExceeded,
989990
core_exceptions.ServiceUnavailable,
@@ -1076,9 +1077,9 @@ def _prep_wrapped_messages(self, client_info):
10761077
self.review_document: self._wrap_method(
10771078
self.review_document,
10781079
default_retry=retries.AsyncRetry(
1079-
initial=0.1,
1080+
initial=1.0,
10801081
maximum=60.0,
1081-
multiplier=1.3,
1082+
multiplier=1.5,
10821083
predicate=retries.if_exception_type(
10831084
core_exceptions.DeadlineExceeded,
10841085
core_exceptions.ServiceUnavailable,

packages/google-cloud-documentai/google/cloud/documentai_v1beta3/types/dataset.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ class DatasetSchema(proto.Message):
279279
``projects/{project}/locations/{location}/processors/{processor}/dataset/datasetSchema``
280280
document_schema (google.cloud.documentai_v1beta3.types.DocumentSchema):
281281
Optional. Schema of the dataset.
282+
satisfies_pzs (bool):
283+
Output only. Reserved for future use.
284+
satisfies_pzi (bool):
285+
Output only. Reserved for future use.
282286
"""
283287

284288
name: str = proto.Field(
@@ -290,6 +294,14 @@ class DatasetSchema(proto.Message):
290294
number=3,
291295
message=gcd_document_schema.DocumentSchema,
292296
)
297+
satisfies_pzs: bool = proto.Field(
298+
proto.BOOL,
299+
number=4,
300+
)
301+
satisfies_pzi: bool = proto.Field(
302+
proto.BOOL,
303+
number=5,
304+
)
293305

294306

295307
class BatchDatasetDocuments(proto.Message):

packages/google-cloud-documentai/tests/unit/gapic/documentai_v1beta3/test_document_service.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,6 +3091,8 @@ def test_get_dataset_schema(request_type, transport: str = "grpc"):
30913091
# Designate an appropriate return value for the call.
30923092
call.return_value = dataset.DatasetSchema(
30933093
name="name_value",
3094+
satisfies_pzs=True,
3095+
satisfies_pzi=True,
30943096
)
30953097
response = client.get_dataset_schema(request)
30963098

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

31073111

31083112
def test_get_dataset_schema_non_empty_request_with_auto_populated_field():
@@ -3238,6 +3242,8 @@ async def test_get_dataset_schema_async(
32383242
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
32393243
dataset.DatasetSchema(
32403244
name="name_value",
3245+
satisfies_pzs=True,
3246+
satisfies_pzi=True,
32413247
)
32423248
)
32433249
response = await client.get_dataset_schema(request)
@@ -3251,6 +3257,8 @@ async def test_get_dataset_schema_async(
32513257
# Establish that the response is the type that we expect.
32523258
assert isinstance(response, dataset.DatasetSchema)
32533259
assert response.name == "name_value"
3260+
assert response.satisfies_pzs is True
3261+
assert response.satisfies_pzi is True
32543262

32553263

32563264
@pytest.mark.asyncio
@@ -3433,6 +3441,8 @@ def test_update_dataset_schema(request_type, transport: str = "grpc"):
34333441
# Designate an appropriate return value for the call.
34343442
call.return_value = dataset.DatasetSchema(
34353443
name="name_value",
3444+
satisfies_pzs=True,
3445+
satisfies_pzi=True,
34363446
)
34373447
response = client.update_dataset_schema(request)
34383448

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

34493461

34503462
def test_update_dataset_schema_non_empty_request_with_auto_populated_field():
@@ -3577,6 +3589,8 @@ async def test_update_dataset_schema_async(
35773589
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
35783590
dataset.DatasetSchema(
35793591
name="name_value",
3592+
satisfies_pzs=True,
3593+
satisfies_pzi=True,
35803594
)
35813595
)
35823596
response = await client.update_dataset_schema(request)
@@ -3590,6 +3604,8 @@ async def test_update_dataset_schema_async(
35903604
# Establish that the response is the type that we expect.
35913605
assert isinstance(response, dataset.DatasetSchema)
35923606
assert response.name == "name_value"
3607+
assert response.satisfies_pzs is True
3608+
assert response.satisfies_pzi is True
35933609

35943610

35953611
@pytest.mark.asyncio
@@ -5561,6 +5577,8 @@ async def test_get_dataset_schema_empty_call_grpc_asyncio():
55615577
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
55625578
dataset.DatasetSchema(
55635579
name="name_value",
5580+
satisfies_pzs=True,
5581+
satisfies_pzi=True,
55645582
)
55655583
)
55665584
await client.get_dataset_schema(request=None)
@@ -5590,6 +5608,8 @@ async def test_update_dataset_schema_empty_call_grpc_asyncio():
55905608
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
55915609
dataset.DatasetSchema(
55925610
name="name_value",
5611+
satisfies_pzs=True,
5612+
satisfies_pzi=True,
55935613
)
55945614
)
55955615
await client.update_dataset_schema(request=None)
@@ -6350,6 +6370,8 @@ def test_get_dataset_schema_rest_call_success(request_type):
63506370
# Designate an appropriate value for the returned response.
63516371
return_value = dataset.DatasetSchema(
63526372
name="name_value",
6373+
satisfies_pzs=True,
6374+
satisfies_pzi=True,
63536375
)
63546376

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

63706394

63716395
@pytest.mark.parametrize("null_interceptor", [True, False])
@@ -6507,6 +6531,8 @@ def test_update_dataset_schema_rest_call_success(request_type):
65076531
"skip_naming_validation": True,
65086532
},
65096533
},
6534+
"satisfies_pzs": True,
6535+
"satisfies_pzi": True,
65106536
}
65116537
# The version of a generated dependency at test runtime may differ from the version used during generation.
65126538
# Delete any fields which are not present in the current runtime dependency
@@ -6584,6 +6610,8 @@ def get_message_fields(field):
65846610
# Designate an appropriate value for the returned response.
65856611
return_value = dataset.DatasetSchema(
65866612
name="name_value",
6613+
satisfies_pzs=True,
6614+
satisfies_pzi=True,
65876615
)
65886616

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

66046634

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

0 commit comments

Comments
 (0)