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

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: remove gRPC send/recv limit (#12)
  • Loading branch information
yoshi-automation committed Dec 28, 2020
1 parent c636859 commit 8faa7fc
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 15 deletions.
Expand Up @@ -28,7 +28,6 @@
_transport_registry["grpc"] = NotebookServiceGrpcTransport
_transport_registry["grpc_asyncio"] = NotebookServiceGrpcAsyncIOTransport


__all__ = (
"NotebookServiceTransport",
"NotebookServiceGrpcTransport",
Expand Down
Expand Up @@ -150,6 +150,10 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)
self._ssl_channel_credentials = ssl_credentials
else:
Expand All @@ -168,9 +172,14 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)

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

# Run the base constructor.
super().__init__(
Expand All @@ -194,7 +203,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
address (Optionsl[str]): The host for the channel to use.
address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
Expand Down Expand Up @@ -241,13 +250,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
if "operations_client" not in self.__dict__:
self.__dict__["operations_client"] = operations_v1.OperationsClient(
self.grpc_channel
)
if self._operations_client is None:
self._operations_client = operations_v1.OperationsClient(self.grpc_channel)

# Return the client from cache.
return self.__dict__["operations_client"]
return self._operations_client

@property
def list_instances(
Expand Down
Expand Up @@ -195,6 +195,10 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)
self._ssl_channel_credentials = ssl_credentials
else:
Expand All @@ -213,6 +217,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)

# Run the base constructor.
Expand All @@ -226,6 +234,7 @@ def __init__(
)

self._stubs = {}
self._operations_client = None

@property
def grpc_channel(self) -> aio.Channel:
Expand All @@ -245,13 +254,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
if "operations_client" not in self.__dict__:
self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
if self._operations_client is None:
self._operations_client = operations_v1.OperationsAsyncClient(
self.grpc_channel
)

# Return the client from cache.
return self.__dict__["operations_client"]
return self._operations_client

@property
def list_instances(
Expand Down
1 change: 0 additions & 1 deletion google/cloud/notebooks_v1beta1/types/__init__.py
Expand Up @@ -47,7 +47,6 @@
DeleteEnvironmentRequest,
)


__all__ = (
"Environment",
"VmImage",
Expand Down
Empty file removed notebooks-v1beta1-py.tar.gz
Empty file.
7 changes: 3 additions & 4 deletions synth.metadata
Expand Up @@ -4,15 +4,15 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/python-notebooks.git",
"sha": "8e42088da1eb05c053a8255a2ac36790a95b00d2"
"sha": "c636859c53d40e4be9211e1ced0922395a16d880"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "830887bae22f690647a0fd8b5c9eccd8d6858d74",
"internalRef": "345047174"
"sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907",
"internalRef": "347055288"
}
},
{
Expand Down Expand Up @@ -114,7 +114,6 @@
"google/cloud/notebooks_v1beta1/types/instance.py",
"google/cloud/notebooks_v1beta1/types/service.py",
"mypy.ini",
"notebooks-v1beta1-py.tar.gz",
"noxfile.py",
"renovate.json",
"scripts/decrypt-secrets.sh",
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/gapic/notebooks_v1beta1/test_notebook_service.py
Expand Up @@ -3555,6 +3555,10 @@ def test_notebook_service_transport_channel_mtls_with_client_cert_source(
scopes=("https://www.googleapis.com/auth/cloud-platform",),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)
assert transport.grpc_channel == mock_grpc_channel
assert transport._ssl_channel_credentials == mock_ssl_cred
Expand Down Expand Up @@ -3596,6 +3600,10 @@ def test_notebook_service_transport_channel_mtls_with_adc(transport_class):
scopes=("https://www.googleapis.com/auth/cloud-platform",),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)
assert transport.grpc_channel == mock_grpc_channel

Expand Down

0 comments on commit 8faa7fc

Please sign in to comment.