google-cloud-automl-v1beta1 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +1 -1
- data/README.md +2 -2
- data/lib/google/cloud/automl/v1beta1/annotation_payload_pb.rb +0 -2
- data/lib/google/cloud/automl/v1beta1/annotation_spec_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/automl/client.rb +56 -66
- data/lib/google/cloud/automl/v1beta1/automl/operations.rb +20 -14
- data/lib/google/cloud/automl/v1beta1/automl/rest/client.rb +2222 -0
- data/lib/google/cloud/automl/v1beta1/automl/rest/operations.rb +935 -0
- data/lib/google/cloud/automl/v1beta1/automl/rest/service_stub.rb +1475 -0
- data/lib/google/cloud/automl/v1beta1/automl/rest.rb +66 -0
- data/lib/google/cloud/automl/v1beta1/automl.rb +7 -1
- data/lib/google/cloud/automl/v1beta1/classification_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/column_spec_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/data_items_pb.rb +0 -3
- data/lib/google/cloud/automl/v1beta1/data_stats_pb.rb +0 -2
- data/lib/google/cloud/automl/v1beta1/data_types_pb.rb +0 -2
- data/lib/google/cloud/automl/v1beta1/dataset_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/detection_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/geometry_pb.rb +0 -2
- data/lib/google/cloud/automl/v1beta1/image_pb.rb +0 -3
- data/lib/google/cloud/automl/v1beta1/io_pb.rb +0 -2
- data/lib/google/cloud/automl/v1beta1/model_evaluation_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/model_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/operations_pb.rb +0 -2
- data/lib/google/cloud/automl/v1beta1/prediction_service/client.rb +4 -4
- data/lib/google/cloud/automl/v1beta1/prediction_service/operations.rb +20 -14
- data/lib/google/cloud/automl/v1beta1/prediction_service/rest/client.rb +563 -0
- data/lib/google/cloud/automl/v1beta1/prediction_service/rest/operations.rb +935 -0
- data/lib/google/cloud/automl/v1beta1/prediction_service/rest/service_stub.rb +168 -0
- data/lib/google/cloud/automl/v1beta1/prediction_service/rest.rb +56 -0
- data/lib/google/cloud/automl/v1beta1/prediction_service.rb +7 -1
- data/lib/google/cloud/automl/v1beta1/ranges_pb.rb +0 -2
- data/lib/google/cloud/automl/v1beta1/regression_pb.rb +0 -2
- data/lib/google/cloud/automl/v1beta1/rest.rb +38 -0
- data/lib/google/cloud/automl/v1beta1/table_spec_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/tables_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/temporal_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/text_extraction_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/text_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/text_segment_pb.rb +0 -2
- data/lib/google/cloud/automl/v1beta1/text_sentiment_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/translation_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1/version.rb +1 -1
- data/lib/google/cloud/automl/v1beta1/video_pb.rb +0 -1
- data/lib/google/cloud/automl/v1beta1.rb +7 -2
- data/proto_docs/google/api/client.rb +318 -0
- data/proto_docs/google/api/launch_stage.rb +71 -0
- data/proto_docs/google/protobuf/empty.rb +0 -2
- data/proto_docs/google/rpc/status.rb +4 -2
- metadata +20 -8
@@ -0,0 +1,563 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/errors"
|
20
|
+
require "google/cloud/automl/v1beta1/prediction_service_pb"
|
21
|
+
require "google/cloud/automl/v1beta1/prediction_service/rest/service_stub"
|
22
|
+
|
23
|
+
module Google
|
24
|
+
module Cloud
|
25
|
+
module AutoML
|
26
|
+
module V1beta1
|
27
|
+
module PredictionService
|
28
|
+
module Rest
|
29
|
+
##
|
30
|
+
# REST client for the PredictionService service.
|
31
|
+
#
|
32
|
+
# AutoML Prediction API.
|
33
|
+
#
|
34
|
+
# On any input that is documented to expect a string parameter in
|
35
|
+
# snake_case or kebab-case, either of those cases is accepted.
|
36
|
+
#
|
37
|
+
class Client
|
38
|
+
include Paths
|
39
|
+
|
40
|
+
# @private
|
41
|
+
attr_reader :prediction_service_stub
|
42
|
+
|
43
|
+
##
|
44
|
+
# Configure the PredictionService Client class.
|
45
|
+
#
|
46
|
+
# See {::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Client::Configuration}
|
47
|
+
# for a description of the configuration fields.
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
#
|
51
|
+
# # Modify the configuration for all PredictionService clients
|
52
|
+
# ::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Client.configure do |config|
|
53
|
+
# config.timeout = 10.0
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# @yield [config] Configure the Client client.
|
57
|
+
# @yieldparam config [Client::Configuration]
|
58
|
+
#
|
59
|
+
# @return [Client::Configuration]
|
60
|
+
#
|
61
|
+
def self.configure
|
62
|
+
@configure ||= begin
|
63
|
+
namespace = ["Google", "Cloud", "AutoML", "V1beta1"]
|
64
|
+
parent_config = while namespace.any?
|
65
|
+
parent_name = namespace.join "::"
|
66
|
+
parent_const = const_get parent_name
|
67
|
+
break parent_const.configure if parent_const.respond_to? :configure
|
68
|
+
namespace.pop
|
69
|
+
end
|
70
|
+
default_config = Client::Configuration.new parent_config
|
71
|
+
|
72
|
+
default_config.rpcs.predict.timeout = 60.0
|
73
|
+
|
74
|
+
default_config.rpcs.batch_predict.timeout = 60.0
|
75
|
+
|
76
|
+
default_config
|
77
|
+
end
|
78
|
+
yield @configure if block_given?
|
79
|
+
@configure
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Configure the PredictionService Client instance.
|
84
|
+
#
|
85
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
86
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
87
|
+
# should be made on {Client.configure}.
|
88
|
+
#
|
89
|
+
# See {::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Client::Configuration}
|
90
|
+
# for a description of the configuration fields.
|
91
|
+
#
|
92
|
+
# @yield [config] Configure the Client client.
|
93
|
+
# @yieldparam config [Client::Configuration]
|
94
|
+
#
|
95
|
+
# @return [Client::Configuration]
|
96
|
+
#
|
97
|
+
def configure
|
98
|
+
yield @config if block_given?
|
99
|
+
@config
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# Create a new PredictionService REST client object.
|
104
|
+
#
|
105
|
+
# @example
|
106
|
+
#
|
107
|
+
# # Create a client using the default configuration
|
108
|
+
# client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Client.new
|
109
|
+
#
|
110
|
+
# # Create a client using a custom configuration
|
111
|
+
# client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Client.new do |config|
|
112
|
+
# config.timeout = 10.0
|
113
|
+
# end
|
114
|
+
#
|
115
|
+
# @yield [config] Configure the PredictionService client.
|
116
|
+
# @yieldparam config [Client::Configuration]
|
117
|
+
#
|
118
|
+
def initialize
|
119
|
+
# Create the configuration object
|
120
|
+
@config = Configuration.new Client.configure
|
121
|
+
|
122
|
+
# Yield the configuration if needed
|
123
|
+
yield @config if block_given?
|
124
|
+
|
125
|
+
# Create credentials
|
126
|
+
credentials = @config.credentials
|
127
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
128
|
+
# but only if the default endpoint does not have a region prefix.
|
129
|
+
enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
|
130
|
+
!@config.endpoint.split(".").first.include?("-")
|
131
|
+
credentials ||= Credentials.default scope: @config.scope,
|
132
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
133
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
134
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
135
|
+
end
|
136
|
+
|
137
|
+
@quota_project_id = @config.quota_project
|
138
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
139
|
+
|
140
|
+
@operations_client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Operations.new do |config|
|
141
|
+
config.credentials = credentials
|
142
|
+
config.quota_project = @quota_project_id
|
143
|
+
config.endpoint = @config.endpoint
|
144
|
+
end
|
145
|
+
|
146
|
+
@prediction_service_stub = ::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Get the associated client for long-running operations.
|
151
|
+
#
|
152
|
+
# @return [::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Operations]
|
153
|
+
#
|
154
|
+
attr_reader :operations_client
|
155
|
+
|
156
|
+
# Service calls
|
157
|
+
|
158
|
+
##
|
159
|
+
# Perform an online prediction. The prediction result will be directly
|
160
|
+
# returned in the response.
|
161
|
+
# Available for following ML problems, and their expected request payloads:
|
162
|
+
# * Image Classification - Image in .JPEG, .GIF or .PNG format, image_bytes
|
163
|
+
# up to 30MB.
|
164
|
+
# * Image Object Detection - Image in .JPEG, .GIF or .PNG format, image_bytes
|
165
|
+
# up to 30MB.
|
166
|
+
# * Text Classification - TextSnippet, content up to 60,000 characters,
|
167
|
+
# UTF-8 encoded.
|
168
|
+
# * Text Extraction - TextSnippet, content up to 30,000 characters,
|
169
|
+
# UTF-8 NFC encoded.
|
170
|
+
# * Translation - TextSnippet, content up to 25,000 characters, UTF-8
|
171
|
+
# encoded.
|
172
|
+
# * Tables - Row, with column values matching the columns of the model,
|
173
|
+
# up to 5MB. Not available for FORECASTING
|
174
|
+
#
|
175
|
+
# [prediction_type][google.cloud.automl.v1beta1.TablesModelMetadata.prediction_type].
|
176
|
+
# * Text Sentiment - TextSnippet, content up 500 characters, UTF-8
|
177
|
+
# encoded.
|
178
|
+
#
|
179
|
+
# @overload predict(request, options = nil)
|
180
|
+
# Pass arguments to `predict` via a request object, either of type
|
181
|
+
# {::Google::Cloud::AutoML::V1beta1::PredictRequest} or an equivalent Hash.
|
182
|
+
#
|
183
|
+
# @param request [::Google::Cloud::AutoML::V1beta1::PredictRequest, ::Hash]
|
184
|
+
# A request object representing the call parameters. Required. To specify no
|
185
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
186
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
187
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
188
|
+
#
|
189
|
+
# @overload predict(name: nil, payload: nil, params: nil)
|
190
|
+
# Pass arguments to `predict` via keyword arguments. Note that at
|
191
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
192
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
193
|
+
#
|
194
|
+
# @param name [::String]
|
195
|
+
# Required. Name of the model requested to serve the prediction.
|
196
|
+
# @param payload [::Google::Cloud::AutoML::V1beta1::ExamplePayload, ::Hash]
|
197
|
+
# Required. Payload to perform a prediction on. The payload must match the
|
198
|
+
# problem type that the model was trained to solve.
|
199
|
+
# @param params [::Hash{::String => ::String}]
|
200
|
+
# Additional domain-specific parameters, any string must be up to 25000
|
201
|
+
# characters long.
|
202
|
+
#
|
203
|
+
# * For Image Classification:
|
204
|
+
#
|
205
|
+
# `score_threshold` - (float) A value from 0.0 to 1.0. When the model
|
206
|
+
# makes predictions for an image, it will only produce results that have
|
207
|
+
# at least this confidence score. The default is 0.5.
|
208
|
+
#
|
209
|
+
# * For Image Object Detection:
|
210
|
+
# `score_threshold` - (float) When Model detects objects on the image,
|
211
|
+
# it will only produce bounding boxes which have at least this
|
212
|
+
# confidence score. Value in 0 to 1 range, default is 0.5.
|
213
|
+
# `max_bounding_box_count` - (int64) No more than this number of bounding
|
214
|
+
# boxes will be returned in the response. Default is 100, the
|
215
|
+
# requested value may be limited by server.
|
216
|
+
# * For Tables:
|
217
|
+
# feature_imp<span>ortan</span>ce - (boolean) Whether feature importance
|
218
|
+
# should be populated in the returned TablesAnnotation.
|
219
|
+
# The default is false.
|
220
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
221
|
+
# @yieldparam result [::Google::Cloud::AutoML::V1beta1::PredictResponse]
|
222
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
223
|
+
#
|
224
|
+
# @return [::Google::Cloud::AutoML::V1beta1::PredictResponse]
|
225
|
+
#
|
226
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
227
|
+
def predict request, options = nil
|
228
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
229
|
+
|
230
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AutoML::V1beta1::PredictRequest
|
231
|
+
|
232
|
+
# Converts hash and nil to an options object
|
233
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
234
|
+
|
235
|
+
# Customize the options with defaults
|
236
|
+
call_metadata = @config.rpcs.predict.metadata.to_h
|
237
|
+
|
238
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
239
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
240
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
241
|
+
gapic_version: ::Google::Cloud::AutoML::V1beta1::VERSION,
|
242
|
+
transports_version_send: [:rest]
|
243
|
+
|
244
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
245
|
+
|
246
|
+
options.apply_defaults timeout: @config.rpcs.predict.timeout,
|
247
|
+
metadata: call_metadata,
|
248
|
+
retry_policy: @config.rpcs.predict.retry_policy
|
249
|
+
|
250
|
+
options.apply_defaults timeout: @config.timeout,
|
251
|
+
metadata: @config.metadata,
|
252
|
+
retry_policy: @config.retry_policy
|
253
|
+
|
254
|
+
@prediction_service_stub.predict request, options do |result, operation|
|
255
|
+
yield result, operation if block_given?
|
256
|
+
return result
|
257
|
+
end
|
258
|
+
rescue ::Gapic::Rest::Error => e
|
259
|
+
raise ::Google::Cloud::Error.from_error(e)
|
260
|
+
end
|
261
|
+
|
262
|
+
##
|
263
|
+
# Perform a batch prediction. Unlike the online {::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Client#predict Predict}, batch
|
264
|
+
# prediction result won't be immediately available in the response. Instead,
|
265
|
+
# a long running operation object is returned. User can poll the operation
|
266
|
+
# result via GetOperation
|
267
|
+
# method. Once the operation is done, {::Google::Cloud::AutoML::V1beta1::BatchPredictResult BatchPredictResult} is returned in
|
268
|
+
# the {::Google::Longrunning::Operation#response response} field.
|
269
|
+
# Available for following ML problems:
|
270
|
+
# * Image Classification
|
271
|
+
# * Image Object Detection
|
272
|
+
# * Video Classification
|
273
|
+
# * Video Object Tracking * Text Extraction
|
274
|
+
# * Tables
|
275
|
+
#
|
276
|
+
# @overload batch_predict(request, options = nil)
|
277
|
+
# Pass arguments to `batch_predict` via a request object, either of type
|
278
|
+
# {::Google::Cloud::AutoML::V1beta1::BatchPredictRequest} or an equivalent Hash.
|
279
|
+
#
|
280
|
+
# @param request [::Google::Cloud::AutoML::V1beta1::BatchPredictRequest, ::Hash]
|
281
|
+
# A request object representing the call parameters. Required. To specify no
|
282
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
283
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
284
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
285
|
+
#
|
286
|
+
# @overload batch_predict(name: nil, input_config: nil, output_config: nil, params: nil)
|
287
|
+
# Pass arguments to `batch_predict` via keyword arguments. Note that at
|
288
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
289
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
290
|
+
#
|
291
|
+
# @param name [::String]
|
292
|
+
# Required. Name of the model requested to serve the batch prediction.
|
293
|
+
# @param input_config [::Google::Cloud::AutoML::V1beta1::BatchPredictInputConfig, ::Hash]
|
294
|
+
# Required. The input configuration for batch prediction.
|
295
|
+
# @param output_config [::Google::Cloud::AutoML::V1beta1::BatchPredictOutputConfig, ::Hash]
|
296
|
+
# Required. The Configuration specifying where output predictions should
|
297
|
+
# be written.
|
298
|
+
# @param params [::Hash{::String => ::String}]
|
299
|
+
# Required. Additional domain-specific parameters for the predictions, any string must
|
300
|
+
# be up to 25000 characters long.
|
301
|
+
#
|
302
|
+
# * For Text Classification:
|
303
|
+
#
|
304
|
+
# `score_threshold` - (float) A value from 0.0 to 1.0. When the model
|
305
|
+
# makes predictions for a text snippet, it will only produce results
|
306
|
+
# that have at least this confidence score. The default is 0.5.
|
307
|
+
#
|
308
|
+
# * For Image Classification:
|
309
|
+
#
|
310
|
+
# `score_threshold` - (float) A value from 0.0 to 1.0. When the model
|
311
|
+
# makes predictions for an image, it will only produce results that
|
312
|
+
# have at least this confidence score. The default is 0.5.
|
313
|
+
#
|
314
|
+
# * For Image Object Detection:
|
315
|
+
#
|
316
|
+
# `score_threshold` - (float) When Model detects objects on the image,
|
317
|
+
# it will only produce bounding boxes which have at least this
|
318
|
+
# confidence score. Value in 0 to 1 range, default is 0.5.
|
319
|
+
# `max_bounding_box_count` - (int64) No more than this number of bounding
|
320
|
+
# boxes will be produced per image. Default is 100, the
|
321
|
+
# requested value may be limited by server.
|
322
|
+
#
|
323
|
+
# * For Video Classification :
|
324
|
+
#
|
325
|
+
# `score_threshold` - (float) A value from 0.0 to 1.0. When the model
|
326
|
+
# makes predictions for a video, it will only produce results that
|
327
|
+
# have at least this confidence score. The default is 0.5.
|
328
|
+
# `segment_classification` - (boolean) Set to true to request
|
329
|
+
# segment-level classification. AutoML Video Intelligence returns
|
330
|
+
# labels and their confidence scores for the entire segment of the
|
331
|
+
# video that user specified in the request configuration.
|
332
|
+
# The default is "true".
|
333
|
+
# `shot_classification` - (boolean) Set to true to request shot-level
|
334
|
+
# classification. AutoML Video Intelligence determines the boundaries
|
335
|
+
# for each camera shot in the entire segment of the video that user
|
336
|
+
# specified in the request configuration. AutoML Video Intelligence
|
337
|
+
# then returns labels and their confidence scores for each detected
|
338
|
+
# shot, along with the start and end time of the shot.
|
339
|
+
# WARNING: Model evaluation is not done for this classification type,
|
340
|
+
# the quality of it depends on training data, but there are no metrics
|
341
|
+
# provided to describe that quality. The default is "false".
|
342
|
+
# `1s_interval_classification` - (boolean) Set to true to request
|
343
|
+
# classification for a video at one-second intervals. AutoML Video
|
344
|
+
# Intelligence returns labels and their confidence scores for each
|
345
|
+
# second of the entire segment of the video that user specified in the
|
346
|
+
# request configuration.
|
347
|
+
# WARNING: Model evaluation is not done for this classification
|
348
|
+
# type, the quality of it depends on training data, but there are no
|
349
|
+
# metrics provided to describe that quality. The default is
|
350
|
+
# "false".
|
351
|
+
#
|
352
|
+
# * For Tables:
|
353
|
+
#
|
354
|
+
# feature_imp<span>ortan</span>ce - (boolean) Whether feature importance
|
355
|
+
# should be populated in the returned TablesAnnotations. The
|
356
|
+
# default is false.
|
357
|
+
#
|
358
|
+
# * For Video Object Tracking:
|
359
|
+
#
|
360
|
+
# `score_threshold` - (float) When Model detects objects on video frames,
|
361
|
+
# it will only produce bounding boxes which have at least this
|
362
|
+
# confidence score. Value in 0 to 1 range, default is 0.5.
|
363
|
+
# `max_bounding_box_count` - (int64) No more than this number of bounding
|
364
|
+
# boxes will be returned per frame. Default is 100, the requested
|
365
|
+
# value may be limited by server.
|
366
|
+
# `min_bounding_box_size` - (float) Only bounding boxes with shortest edge
|
367
|
+
# at least that long as a relative value of video frame size will be
|
368
|
+
# returned. Value in 0 to 1 range. Default is 0.
|
369
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
370
|
+
# @yieldparam result [::Gapic::Operation]
|
371
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
372
|
+
#
|
373
|
+
# @return [::Gapic::Operation]
|
374
|
+
#
|
375
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
376
|
+
def batch_predict request, options = nil
|
377
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
378
|
+
|
379
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AutoML::V1beta1::BatchPredictRequest
|
380
|
+
|
381
|
+
# Converts hash and nil to an options object
|
382
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
383
|
+
|
384
|
+
# Customize the options with defaults
|
385
|
+
call_metadata = @config.rpcs.batch_predict.metadata.to_h
|
386
|
+
|
387
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
388
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
389
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
390
|
+
gapic_version: ::Google::Cloud::AutoML::V1beta1::VERSION,
|
391
|
+
transports_version_send: [:rest]
|
392
|
+
|
393
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
394
|
+
|
395
|
+
options.apply_defaults timeout: @config.rpcs.batch_predict.timeout,
|
396
|
+
metadata: call_metadata,
|
397
|
+
retry_policy: @config.rpcs.batch_predict.retry_policy
|
398
|
+
|
399
|
+
options.apply_defaults timeout: @config.timeout,
|
400
|
+
metadata: @config.metadata,
|
401
|
+
retry_policy: @config.retry_policy
|
402
|
+
|
403
|
+
@prediction_service_stub.batch_predict request, options do |result, operation|
|
404
|
+
result = ::Gapic::Operation.new result, @operations_client, options: options
|
405
|
+
yield result, operation if block_given?
|
406
|
+
return result
|
407
|
+
end
|
408
|
+
rescue ::Gapic::Rest::Error => e
|
409
|
+
raise ::Google::Cloud::Error.from_error(e)
|
410
|
+
end
|
411
|
+
|
412
|
+
##
|
413
|
+
# Configuration class for the PredictionService REST API.
|
414
|
+
#
|
415
|
+
# This class represents the configuration for PredictionService REST,
|
416
|
+
# providing control over timeouts, retry behavior, logging, transport
|
417
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
418
|
+
# applied individually to specific RPCs. See
|
419
|
+
# {::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Client::Configuration::Rpcs}
|
420
|
+
# for a list of RPCs that can be configured independently.
|
421
|
+
#
|
422
|
+
# Configuration can be applied globally to all clients, or to a single client
|
423
|
+
# on construction.
|
424
|
+
#
|
425
|
+
# @example
|
426
|
+
#
|
427
|
+
# # Modify the global config, setting the timeout for
|
428
|
+
# # predict to 20 seconds,
|
429
|
+
# # and all remaining timeouts to 10 seconds.
|
430
|
+
# ::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Client.configure do |config|
|
431
|
+
# config.timeout = 10.0
|
432
|
+
# config.rpcs.predict.timeout = 20.0
|
433
|
+
# end
|
434
|
+
#
|
435
|
+
# # Apply the above configuration only to a new client.
|
436
|
+
# client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Rest::Client.new do |config|
|
437
|
+
# config.timeout = 10.0
|
438
|
+
# config.rpcs.predict.timeout = 20.0
|
439
|
+
# end
|
440
|
+
#
|
441
|
+
# @!attribute [rw] endpoint
|
442
|
+
# The hostname or hostname:port of the service endpoint.
|
443
|
+
# Defaults to `"automl.googleapis.com"`.
|
444
|
+
# @return [::String]
|
445
|
+
# @!attribute [rw] credentials
|
446
|
+
# Credentials to send with calls. You may provide any of the following types:
|
447
|
+
# * (`String`) The path to a service account key file in JSON format
|
448
|
+
# * (`Hash`) A service account key as a Hash
|
449
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
450
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
451
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
452
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
453
|
+
# * (`nil`) indicating no credentials
|
454
|
+
# @return [::Object]
|
455
|
+
# @!attribute [rw] scope
|
456
|
+
# The OAuth scopes
|
457
|
+
# @return [::Array<::String>]
|
458
|
+
# @!attribute [rw] lib_name
|
459
|
+
# The library name as recorded in instrumentation and logging
|
460
|
+
# @return [::String]
|
461
|
+
# @!attribute [rw] lib_version
|
462
|
+
# The library version as recorded in instrumentation and logging
|
463
|
+
# @return [::String]
|
464
|
+
# @!attribute [rw] timeout
|
465
|
+
# The call timeout in seconds.
|
466
|
+
# @return [::Numeric]
|
467
|
+
# @!attribute [rw] metadata
|
468
|
+
# Additional headers to be sent with the call.
|
469
|
+
# @return [::Hash{::Symbol=>::String}]
|
470
|
+
# @!attribute [rw] retry_policy
|
471
|
+
# The retry policy. The value is a hash with the following keys:
|
472
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
473
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
474
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
475
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
476
|
+
# trigger a retry.
|
477
|
+
# @return [::Hash]
|
478
|
+
# @!attribute [rw] quota_project
|
479
|
+
# A separate project against which to charge quota.
|
480
|
+
# @return [::String]
|
481
|
+
#
|
482
|
+
class Configuration
|
483
|
+
extend ::Gapic::Config
|
484
|
+
|
485
|
+
config_attr :endpoint, "automl.googleapis.com", ::String
|
486
|
+
config_attr :credentials, nil do |value|
|
487
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
488
|
+
allowed.any? { |klass| klass === value }
|
489
|
+
end
|
490
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
491
|
+
config_attr :lib_name, nil, ::String, nil
|
492
|
+
config_attr :lib_version, nil, ::String, nil
|
493
|
+
config_attr :timeout, nil, ::Numeric, nil
|
494
|
+
config_attr :metadata, nil, ::Hash, nil
|
495
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
496
|
+
config_attr :quota_project, nil, ::String, nil
|
497
|
+
|
498
|
+
# @private
|
499
|
+
def initialize parent_config = nil
|
500
|
+
@parent_config = parent_config unless parent_config.nil?
|
501
|
+
|
502
|
+
yield self if block_given?
|
503
|
+
end
|
504
|
+
|
505
|
+
##
|
506
|
+
# Configurations for individual RPCs
|
507
|
+
# @return [Rpcs]
|
508
|
+
#
|
509
|
+
def rpcs
|
510
|
+
@rpcs ||= begin
|
511
|
+
parent_rpcs = nil
|
512
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
513
|
+
Rpcs.new parent_rpcs
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
517
|
+
##
|
518
|
+
# Configuration RPC class for the PredictionService API.
|
519
|
+
#
|
520
|
+
# Includes fields providing the configuration for each RPC in this service.
|
521
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
522
|
+
# the following configuration fields:
|
523
|
+
#
|
524
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
525
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
|
526
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
527
|
+
# include the following keys:
|
528
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
529
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
530
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
531
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
532
|
+
# trigger a retry.
|
533
|
+
#
|
534
|
+
class Rpcs
|
535
|
+
##
|
536
|
+
# RPC-specific configuration for `predict`
|
537
|
+
# @return [::Gapic::Config::Method]
|
538
|
+
#
|
539
|
+
attr_reader :predict
|
540
|
+
##
|
541
|
+
# RPC-specific configuration for `batch_predict`
|
542
|
+
# @return [::Gapic::Config::Method]
|
543
|
+
#
|
544
|
+
attr_reader :batch_predict
|
545
|
+
|
546
|
+
# @private
|
547
|
+
def initialize parent_rpcs = nil
|
548
|
+
predict_config = parent_rpcs.predict if parent_rpcs.respond_to? :predict
|
549
|
+
@predict = ::Gapic::Config::Method.new predict_config
|
550
|
+
batch_predict_config = parent_rpcs.batch_predict if parent_rpcs.respond_to? :batch_predict
|
551
|
+
@batch_predict = ::Gapic::Config::Method.new batch_predict_config
|
552
|
+
|
553
|
+
yield self if block_given?
|
554
|
+
end
|
555
|
+
end
|
556
|
+
end
|
557
|
+
end
|
558
|
+
end
|
559
|
+
end
|
560
|
+
end
|
561
|
+
end
|
562
|
+
end
|
563
|
+
end
|