Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit c94afd5

Browse files
fix: remove client recv msg limit and add enums to types/__init__.py (#72)
PiperOrigin-RevId: 347055288 Source-Author: Google APIs <noreply@google.com> Source-Date: Fri Dec 11 12:44:37 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: dd372aa22ded7a8ba6f0e03a80e06358a3fa0907 Source-Link: googleapis/googleapis@dd372aa
1 parent d1222a7 commit c94afd5

11 files changed

Lines changed: 69 additions & 25 deletions

File tree

google/cloud/documentai_v1beta2/services/document_understanding_service/transports/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
_transport_registry["grpc"] = DocumentUnderstandingServiceGrpcTransport
3131
_transport_registry["grpc_asyncio"] = DocumentUnderstandingServiceGrpcAsyncIOTransport
3232

33-
3433
__all__ = (
3534
"DocumentUnderstandingServiceTransport",
3635
"DocumentUnderstandingServiceGrpcTransport",

google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ def __init__(
151151
ssl_credentials=ssl_credentials,
152152
scopes=scopes or self.AUTH_SCOPES,
153153
quota_project_id=quota_project_id,
154+
options=[
155+
("grpc.max_send_message_length", -1),
156+
("grpc.max_receive_message_length", -1),
157+
],
154158
)
155159
self._ssl_channel_credentials = ssl_credentials
156160
else:
@@ -169,9 +173,14 @@ def __init__(
169173
ssl_credentials=ssl_channel_credentials,
170174
scopes=scopes or self.AUTH_SCOPES,
171175
quota_project_id=quota_project_id,
176+
options=[
177+
("grpc.max_send_message_length", -1),
178+
("grpc.max_receive_message_length", -1),
179+
],
172180
)
173181

174182
self._stubs = {} # type: Dict[str, Callable]
183+
self._operations_client = None
175184

176185
# Run the base constructor.
177186
super().__init__(
@@ -195,7 +204,7 @@ def create_channel(
195204
) -> grpc.Channel:
196205
"""Create and return a gRPC channel object.
197206
Args:
198-
address (Optionsl[str]): The host for the channel to use.
207+
address (Optional[str]): The host for the channel to use.
199208
credentials (Optional[~.Credentials]): The
200209
authorization credentials to attach to requests. These
201210
credentials identify this application to the service. If
@@ -242,13 +251,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
242251
client.
243252
"""
244253
# Sanity check: Only create a new client if we do not already have one.
245-
if "operations_client" not in self.__dict__:
246-
self.__dict__["operations_client"] = operations_v1.OperationsClient(
247-
self.grpc_channel
248-
)
254+
if self._operations_client is None:
255+
self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
249256

250257
# Return the client from cache.
251-
return self.__dict__["operations_client"]
258+
return self._operations_client
252259

253260
@property
254261
def batch_process_documents(

google/cloud/documentai_v1beta2/services/document_understanding_service/transports/grpc_asyncio.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ def __init__(
198198
ssl_credentials=ssl_credentials,
199199
scopes=scopes or self.AUTH_SCOPES,
200200
quota_project_id=quota_project_id,
201+
options=[
202+
("grpc.max_send_message_length", -1),
203+
("grpc.max_receive_message_length", -1),
204+
],
201205
)
202206
self._ssl_channel_credentials = ssl_credentials
203207
else:
@@ -216,6 +220,10 @@ def __init__(
216220
ssl_credentials=ssl_channel_credentials,
217221
scopes=scopes or self.AUTH_SCOPES,
218222
quota_project_id=quota_project_id,
223+
options=[
224+
("grpc.max_send_message_length", -1),
225+
("grpc.max_receive_message_length", -1),
226+
],
219227
)
220228

221229
# Run the base constructor.
@@ -229,6 +237,7 @@ def __init__(
229237
)
230238

231239
self._stubs = {}
240+
self._operations_client = None
232241

233242
@property
234243
def grpc_channel(self) -> aio.Channel:
@@ -248,13 +257,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
248257
client.
249258
"""
250259
# Sanity check: Only create a new client if we do not already have one.
251-
if "operations_client" not in self.__dict__:
252-
self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
260+
if self._operations_client is None:
261+
self._operations_client = operations_v1.OperationsAsyncClient(
253262
self.grpc_channel
254263
)
255264

256265
# Return the client from cache.
257-
return self.__dict__["operations_client"]
266+
return self._operations_client
258267

259268
@property
260269
def batch_process_documents(

google/cloud/documentai_v1beta2/types/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
OperationMetadata,
4141
)
4242

43-
4443
__all__ = (
4544
"Vertex",
4645
"NormalizedVertex",

google/cloud/documentai_v1beta3/services/document_processor_service/transports/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
_transport_registry["grpc"] = DocumentProcessorServiceGrpcTransport
3131
_transport_registry["grpc_asyncio"] = DocumentProcessorServiceGrpcAsyncIOTransport
3232

33-
3433
__all__ = (
3534
"DocumentProcessorServiceTransport",
3635
"DocumentProcessorServiceGrpcTransport",

google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ def __init__(
152152
ssl_credentials=ssl_credentials,
153153
scopes=scopes or self.AUTH_SCOPES,
154154
quota_project_id=quota_project_id,
155+
options=[
156+
("grpc.max_send_message_length", -1),
157+
("grpc.max_receive_message_length", -1),
158+
],
155159
)
156160
self._ssl_channel_credentials = ssl_credentials
157161
else:
@@ -170,9 +174,14 @@ def __init__(
170174
ssl_credentials=ssl_channel_credentials,
171175
scopes=scopes or self.AUTH_SCOPES,
172176
quota_project_id=quota_project_id,
177+
options=[
178+
("grpc.max_send_message_length", -1),
179+
("grpc.max_receive_message_length", -1),
180+
],
173181
)
174182

175183
self._stubs = {} # type: Dict[str, Callable]
184+
self._operations_client = None
176185

177186
# Run the base constructor.
178187
super().__init__(
@@ -196,7 +205,7 @@ def create_channel(
196205
) -> grpc.Channel:
197206
"""Create and return a gRPC channel object.
198207
Args:
199-
address (Optionsl[str]): The host for the channel to use.
208+
address (Optional[str]): The host for the channel to use.
200209
credentials (Optional[~.Credentials]): The
201210
authorization credentials to attach to requests. These
202211
credentials identify this application to the service. If
@@ -243,13 +252,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
243252
client.
244253
"""
245254
# Sanity check: Only create a new client if we do not already have one.
246-
if "operations_client" not in self.__dict__:
247-
self.__dict__["operations_client"] = operations_v1.OperationsClient(
248-
self.grpc_channel
249-
)
255+
if self._operations_client is None:
256+
self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
250257

251258
# Return the client from cache.
252-
return self.__dict__["operations_client"]
259+
return self._operations_client
253260

254261
@property
255262
def process_document(

google/cloud/documentai_v1beta3/services/document_processor_service/transports/grpc_asyncio.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ def __init__(
197197
ssl_credentials=ssl_credentials,
198198
scopes=scopes or self.AUTH_SCOPES,
199199
quota_project_id=quota_project_id,
200+
options=[
201+
("grpc.max_send_message_length", -1),
202+
("grpc.max_receive_message_length", -1),
203+
],
200204
)
201205
self._ssl_channel_credentials = ssl_credentials
202206
else:
@@ -215,6 +219,10 @@ def __init__(
215219
ssl_credentials=ssl_channel_credentials,
216220
scopes=scopes or self.AUTH_SCOPES,
217221
quota_project_id=quota_project_id,
222+
options=[
223+
("grpc.max_send_message_length", -1),
224+
("grpc.max_receive_message_length", -1),
225+
],
218226
)
219227

220228
# Run the base constructor.
@@ -228,6 +236,7 @@ def __init__(
228236
)
229237

230238
self._stubs = {}
239+
self._operations_client = None
231240

232241
@property
233242
def grpc_channel(self) -> aio.Channel:
@@ -247,13 +256,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
247256
client.
248257
"""
249258
# Sanity check: Only create a new client if we do not already have one.
250-
if "operations_client" not in self.__dict__:
251-
self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
259+
if self._operations_client is None:
260+
self._operations_client = operations_v1.OperationsAsyncClient(
252261
self.grpc_channel
253262
)
254263

255264
# Return the client from cache.
256-
return self.__dict__["operations_client"]
265+
return self._operations_client
257266

258267
@property
259268
def process_document(

google/cloud/documentai_v1beta3/types/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
ReviewDocumentOperationMetadata,
3333
)
3434

35-
3635
__all__ = (
3736
"Vertex",
3837
"NormalizedVertex",

synth.metadata

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/python-documentai.git",
7-
"sha": "4918e62033b4c118bf99ba83730377b4ecc86d17"
7+
"sha": "d1222a796ee71bcdf198660d9742fdaa5f9b0fc9"
88
}
99
},
1010
{
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "e3e7e7ddb0fecd7bc61ca03b5a9ddb29cc9b48d8",
15-
"internalRef": "342967619"
14+
"sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907",
15+
"internalRef": "347055288"
1616
}
1717
},
1818
{

tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,10 @@ def test_document_understanding_service_transport_channel_mtls_with_client_cert_
10981098
scopes=("https://www.googleapis.com/auth/cloud-platform",),
10991099
ssl_credentials=mock_ssl_cred,
11001100
quota_project_id=None,
1101+
options=[
1102+
("grpc.max_send_message_length", -1),
1103+
("grpc.max_receive_message_length", -1),
1104+
],
11011105
)
11021106
assert transport.grpc_channel == mock_grpc_channel
11031107
assert transport._ssl_channel_credentials == mock_ssl_cred
@@ -1141,6 +1145,10 @@ def test_document_understanding_service_transport_channel_mtls_with_adc(
11411145
scopes=("https://www.googleapis.com/auth/cloud-platform",),
11421146
ssl_credentials=mock_ssl_cred,
11431147
quota_project_id=None,
1148+
options=[
1149+
("grpc.max_send_message_length", -1),
1150+
("grpc.max_receive_message_length", -1),
1151+
],
11441152
)
11451153
assert transport.grpc_channel == mock_grpc_channel
11461154

0 commit comments

Comments
 (0)