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

fix: remove gRPC send/recv limits; add enums to __init__.py #94

Merged
merged 3 commits into from Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -30,7 +30,6 @@
_transport_registry["grpc"] = VideoIntelligenceServiceGrpcTransport
_transport_registry["grpc_asyncio"] = VideoIntelligenceServiceGrpcAsyncIOTransport


__all__ = (
"VideoIntelligenceServiceTransport",
"VideoIntelligenceServiceGrpcTransport",
Expand Down
Expand Up @@ -148,6 +148,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 @@ -166,9 +170,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 @@ -192,7 +201,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 @@ -239,13 +248,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 annotate_video(
Expand Down
Expand Up @@ -193,6 +193,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 @@ -211,6 +215,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 @@ -224,6 +232,7 @@ def __init__(
)

self._stubs = {}
self._operations_client = None

@property
def grpc_channel(self) -> aio.Channel:
Expand All @@ -243,13 +252,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 annotate_video(
Expand Down
7 changes: 6 additions & 1 deletion google/cloud/videointelligence_v1/types/__init__.py
Expand Up @@ -59,9 +59,11 @@
ObjectTrackingFrame,
ObjectTrackingAnnotation,
LogoRecognitionAnnotation,
Feature,
LabelDetectionMode,
Likelihood,
)


__all__ = (
"AnnotateVideoRequest",
"VideoContext",
Expand Down Expand Up @@ -106,4 +108,7 @@
"ObjectTrackingFrame",
"ObjectTrackingAnnotation",
"LogoRecognitionAnnotation",
"Feature",
"LabelDetectionMode",
"Likelihood",
)
Expand Up @@ -30,7 +30,6 @@
_transport_registry["grpc"] = VideoIntelligenceServiceGrpcTransport
_transport_registry["grpc_asyncio"] = VideoIntelligenceServiceGrpcAsyncIOTransport


__all__ = (
"VideoIntelligenceServiceTransport",
"VideoIntelligenceServiceGrpcTransport",
Expand Down
Expand Up @@ -148,6 +148,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 @@ -166,9 +170,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 @@ -192,7 +201,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 @@ -239,13 +248,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 annotate_video(
Expand Down
Expand Up @@ -193,6 +193,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 @@ -211,6 +215,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 @@ -224,6 +232,7 @@ def __init__(
)

self._stubs = {}
self._operations_client = None

@property
def grpc_channel(self) -> aio.Channel:
Expand All @@ -243,13 +252,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 annotate_video(
Expand Down
7 changes: 6 additions & 1 deletion google/cloud/videointelligence_v1beta2/types/__init__.py
Expand Up @@ -37,9 +37,11 @@
AnnotateVideoResponse,
VideoAnnotationProgress,
AnnotateVideoProgress,
Feature,
LabelDetectionMode,
Likelihood,
)


__all__ = (
"AnnotateVideoRequest",
"VideoContext",
Expand All @@ -62,4 +64,7 @@
"AnnotateVideoResponse",
"VideoAnnotationProgress",
"AnnotateVideoProgress",
"Feature",
"LabelDetectionMode",
"Likelihood",
)
Expand Up @@ -30,7 +30,6 @@
_transport_registry["grpc"] = VideoIntelligenceServiceGrpcTransport
_transport_registry["grpc_asyncio"] = VideoIntelligenceServiceGrpcAsyncIOTransport


__all__ = (
"VideoIntelligenceServiceTransport",
"VideoIntelligenceServiceGrpcTransport",
Expand Down
Expand Up @@ -148,6 +148,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 @@ -166,9 +170,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 @@ -192,7 +201,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 @@ -239,13 +248,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 annotate_video(
Expand Down
Expand Up @@ -193,6 +193,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 @@ -211,6 +215,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 @@ -224,6 +232,7 @@ def __init__(
)

self._stubs = {}
self._operations_client = None

@property
def grpc_channel(self) -> aio.Channel:
Expand All @@ -243,13 +252,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 annotate_video(
Expand Down
7 changes: 6 additions & 1 deletion google/cloud/videointelligence_v1p1beta1/types/__init__.py
Expand Up @@ -37,9 +37,11 @@
SpeechTranscription,
SpeechRecognitionAlternative,
WordInfo,
Feature,
LabelDetectionMode,
Likelihood,
)


__all__ = (
"AnnotateVideoRequest",
"VideoContext",
Expand All @@ -62,4 +64,7 @@
"SpeechTranscription",
"SpeechRecognitionAlternative",
"WordInfo",
"Feature",
"LabelDetectionMode",
"Likelihood",
)
Expand Up @@ -30,7 +30,6 @@
_transport_registry["grpc"] = VideoIntelligenceServiceGrpcTransport
_transport_registry["grpc_asyncio"] = VideoIntelligenceServiceGrpcAsyncIOTransport


__all__ = (
"VideoIntelligenceServiceTransport",
"VideoIntelligenceServiceGrpcTransport",
Expand Down