Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Commit 94a7d75

Browse files
authored
Vision: pick up fixes to GAPIC generator. (#6632)
Includes fixes from these PRs: - googleapis/gapic-generator#2407 - googleapis/gapic-generator#2396 Includes changes to generated tests. Closes #6475.
1 parent c470abf commit 94a7d75

21 files changed

Lines changed: 600 additions & 227 deletions

google/cloud/vision_v1/gapic/image_annotator_client.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(self,
8181
transport=None,
8282
channel=None,
8383
credentials=None,
84-
client_config=image_annotator_client_config.config,
84+
client_config=None,
8585
client_info=None):
8686
"""Constructor.
8787
@@ -114,13 +114,20 @@ def __init__(self,
114114
your own client library.
115115
"""
116116
# Raise deprecation warnings for things we want to go away.
117-
if client_config:
118-
warnings.warn('The `client_config` argument is deprecated.',
119-
PendingDeprecationWarning)
117+
if client_config is not None:
118+
warnings.warn(
119+
'The `client_config` argument is deprecated.',
120+
PendingDeprecationWarning,
121+
stacklevel=2)
122+
else:
123+
client_config = image_annotator_client_config.config
124+
120125
if channel:
121126
warnings.warn(
122127
'The `channel` argument is deprecated; use '
123-
'`transport` instead.', PendingDeprecationWarning)
128+
'`transport` instead.',
129+
PendingDeprecationWarning,
130+
stacklevel=2)
124131

125132
# Instantiate the transport.
126133
# The transport is responsible for handling serialization and

google/cloud/vision_v1/gapic/product_search_client.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,41 +99,41 @@ def location_path(cls, project, location):
9999
)
100100

101101
@classmethod
102-
def product_path(cls, project, location, product):
103-
"""Return a fully-qualified product string."""
102+
def product_set_path(cls, project, location, product_set):
103+
"""Return a fully-qualified product_set string."""
104104
return google.api_core.path_template.expand(
105-
'projects/{project}/locations/{location}/products/{product}',
105+
'projects/{project}/locations/{location}/productSets/{product_set}',
106106
project=project,
107107
location=location,
108-
product=product,
108+
product_set=product_set,
109109
)
110110

111111
@classmethod
112-
def product_set_path(cls, project, location, product_set):
113-
"""Return a fully-qualified product_set string."""
112+
def product_path(cls, project, location, product):
113+
"""Return a fully-qualified product string."""
114114
return google.api_core.path_template.expand(
115-
'projects/{project}/locations/{location}/productSets/{product_set}',
115+
'projects/{project}/locations/{location}/products/{product}',
116116
project=project,
117117
location=location,
118-
product_set=product_set,
118+
product=product,
119119
)
120120

121121
@classmethod
122-
def image_path(cls, project, location, product, image):
123-
"""Return a fully-qualified image string."""
122+
def reference_image_path(cls, project, location, product, reference_image):
123+
"""Return a fully-qualified reference_image string."""
124124
return google.api_core.path_template.expand(
125-
'projects/{project}/locations/{location}/products/{product}/referenceImages/{image}',
125+
'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}',
126126
project=project,
127127
location=location,
128128
product=product,
129-
image=image,
129+
reference_image=reference_image,
130130
)
131131

132132
def __init__(self,
133133
transport=None,
134134
channel=None,
135135
credentials=None,
136-
client_config=product_search_client_config.config,
136+
client_config=None,
137137
client_info=None):
138138
"""Constructor.
139139
@@ -166,13 +166,20 @@ def __init__(self,
166166
your own client library.
167167
"""
168168
# Raise deprecation warnings for things we want to go away.
169-
if client_config:
170-
warnings.warn('The `client_config` argument is deprecated.',
171-
PendingDeprecationWarning)
169+
if client_config is not None:
170+
warnings.warn(
171+
'The `client_config` argument is deprecated.',
172+
PendingDeprecationWarning,
173+
stacklevel=2)
174+
else:
175+
client_config = product_search_client_config.config
176+
172177
if channel:
173178
warnings.warn(
174179
'The `channel` argument is deprecated; use '
175-
'`transport` instead.', PendingDeprecationWarning)
180+
'`transport` instead.',
181+
PendingDeprecationWarning,
182+
stacklevel=2)
176183

177184
# Instantiate the transport.
178185
# The transport is responsible for handling serialization and
@@ -707,7 +714,7 @@ def get_reference_image(self,
707714
>>>
708715
>>> client = vision_v1.ProductSearchClient()
709716
>>>
710-
>>> name = client.image_path('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[IMAGE]')
717+
>>> name = client.reference_image_path('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]')
711718
>>>
712719
>>> response = client.get_reference_image(name)
713720
@@ -776,7 +783,7 @@ def delete_reference_image(self,
776783
>>>
777784
>>> client = vision_v1.ProductSearchClient()
778785
>>>
779-
>>> name = client.image_path('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[IMAGE]')
786+
>>> name = client.reference_image_path('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]')
780787
>>>
781788
>>> client.delete_reference_image(name)
782789
@@ -1228,8 +1235,8 @@ def delete_product_set(self,
12281235
timeout=google.api_core.gapic_v1.method.DEFAULT,
12291236
metadata=None):
12301237
"""
1231-
Permanently deletes a ProductSet. All Products and ReferenceImages in
1232-
the ProductSet will be deleted.
1238+
Permanently deletes a ProductSet. Products and ReferenceImages in the
1239+
ProductSet are not deleted.
12331240
12341241
The actual image files are not deleted from Google Cloud Storage.
12351242

google/cloud/vision_v1/gapic/transports/image_annotator_grpc_transport.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def __init__(self,
6666
credentials=credentials,
6767
)
6868

69+
self._channel = channel
70+
6971
# gRPC uses objects called "stubs" that are bound to the
7072
# channel and provide a basic method for each RPC.
7173
self._stubs = {
@@ -102,6 +104,15 @@ def create_channel(cls,
102104
scopes=cls._OAUTH_SCOPES,
103105
)
104106

107+
@property
108+
def channel(self):
109+
"""The gRPC channel used by the transport.
110+
111+
Returns:
112+
grpc.Channel: A gRPC channel object.
113+
"""
114+
return self._channel
115+
105116
@property
106117
def batch_annotate_images(self):
107118
"""Return the gRPC stub for {$apiMethod.name}.

google/cloud/vision_v1/gapic/transports/product_search_grpc_transport.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def __init__(self,
6666
credentials=credentials,
6767
)
6868

69+
self._channel = channel
70+
6971
# gRPC uses objects called "stubs" that are bound to the
7072
# channel and provide a basic method for each RPC.
7173
self._stubs = {
@@ -102,6 +104,15 @@ def create_channel(cls,
102104
scopes=cls._OAUTH_SCOPES,
103105
)
104106

107+
@property
108+
def channel(self):
109+
"""The gRPC channel used by the transport.
110+
111+
Returns:
112+
grpc.Channel: A gRPC channel object.
113+
"""
114+
return self._channel
115+
105116
@property
106117
def create_product(self):
107118
"""Return the gRPC stub for {$apiMethod.name}.
@@ -375,8 +386,8 @@ def update_product_set(self):
375386
def delete_product_set(self):
376387
"""Return the gRPC stub for {$apiMethod.name}.
377388
378-
Permanently deletes a ProductSet. All Products and ReferenceImages in
379-
the ProductSet will be deleted.
389+
Permanently deletes a ProductSet. Products and ReferenceImages in the
390+
ProductSet are not deleted.
380391
381392
The actual image files are not deleted from Google Cloud Storage.
382393

google/cloud/vision_v1/proto/image_annotator_pb2.py

Lines changed: 81 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google/cloud/vision_v1/proto/product_search_service_pb2_grpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ def UpdateProductSet(self, request, context):
188188
raise NotImplementedError('Method not implemented!')
189189

190190
def DeleteProductSet(self, request, context):
191-
"""Permanently deletes a ProductSet. All Products and ReferenceImages in the
192-
ProductSet will be deleted.
191+
"""Permanently deletes a ProductSet. Products and ReferenceImages in the
192+
ProductSet are not deleted.
193193
194194
The actual image files are not deleted from Google Cloud Storage.
195195

google/cloud/vision_v1/proto/text_annotation_pb2.py

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google/cloud/vision_v1p1beta1/gapic/image_annotator_client.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self,
7474
transport=None,
7575
channel=None,
7676
credentials=None,
77-
client_config=image_annotator_client_config.config,
77+
client_config=None,
7878
client_info=None):
7979
"""Constructor.
8080
@@ -107,13 +107,20 @@ def __init__(self,
107107
your own client library.
108108
"""
109109
# Raise deprecation warnings for things we want to go away.
110-
if client_config:
111-
warnings.warn('The `client_config` argument is deprecated.',
112-
PendingDeprecationWarning)
110+
if client_config is not None:
111+
warnings.warn(
112+
'The `client_config` argument is deprecated.',
113+
PendingDeprecationWarning,
114+
stacklevel=2)
115+
else:
116+
client_config = image_annotator_client_config.config
117+
113118
if channel:
114119
warnings.warn(
115120
'The `channel` argument is deprecated; use '
116-
'`transport` instead.', PendingDeprecationWarning)
121+
'`transport` instead.',
122+
PendingDeprecationWarning,
123+
stacklevel=2)
117124

118125
# Instantiate the transport.
119126
# The transport is responsible for handling serialization and

google/cloud/vision_v1p1beta1/gapic/transports/image_annotator_grpc_transport.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def __init__(self,
6565
credentials=credentials,
6666
)
6767

68+
self._channel = channel
69+
6870
# gRPC uses objects called "stubs" that are bound to the
6971
# channel and provide a basic method for each RPC.
7072
self._stubs = {
@@ -95,6 +97,15 @@ def create_channel(cls,
9597
scopes=cls._OAUTH_SCOPES,
9698
)
9799

100+
@property
101+
def channel(self):
102+
"""The gRPC channel used by the transport.
103+
104+
Returns:
105+
grpc.Channel: A gRPC channel object.
106+
"""
107+
return self._channel
108+
98109
@property
99110
def batch_annotate_images(self):
100111
"""Return the gRPC stub for {$apiMethod.name}.

google/cloud/vision_v1p2beta1/gapic/image_annotator_client.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self,
7777
transport=None,
7878
channel=None,
7979
credentials=None,
80-
client_config=image_annotator_client_config.config,
80+
client_config=None,
8181
client_info=None):
8282
"""Constructor.
8383
@@ -110,13 +110,20 @@ def __init__(self,
110110
your own client library.
111111
"""
112112
# Raise deprecation warnings for things we want to go away.
113-
if client_config:
114-
warnings.warn('The `client_config` argument is deprecated.',
115-
PendingDeprecationWarning)
113+
if client_config is not None:
114+
warnings.warn(
115+
'The `client_config` argument is deprecated.',
116+
PendingDeprecationWarning,
117+
stacklevel=2)
118+
else:
119+
client_config = image_annotator_client_config.config
120+
116121
if channel:
117122
warnings.warn(
118123
'The `channel` argument is deprecated; use '
119-
'`transport` instead.', PendingDeprecationWarning)
124+
'`transport` instead.',
125+
PendingDeprecationWarning,
126+
stacklevel=2)
120127

121128
# Instantiate the transport.
122129
# The transport is responsible for handling serialization and

0 commit comments

Comments
 (0)