Class: Google::Cloud::AutoML::V1beta1::AutoMLClient

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/automl/v1beta1/automl_client.rb

Overview

AutoML Server API.

The resource names are assigned by the server. The server never reuses names that it has created after the resources with those names are deleted.

An ID of a resource is the last element of the item's resource name. For projects/{project_id}/locations/{location_id}/datasets/{dataset_id}, then the id for the item is {dataset_id}.

Currently the only supported location_id is "us-central1".

On any input that is documented to expect a string parameter in snake_case or kebab-case, either of those cases is accepted.

Defined Under Namespace

Classes: OperationsClient

Constant Summary collapse

SERVICE_ADDRESS =

The default address of the service.

"automl.googleapis.com".freeze
DEFAULT_SERVICE_PORT =

The default port of the service.

443
GRPC_INTERCEPTORS =

The default set of gRPC interceptors.

[]
DEFAULT_TIMEOUT =
30
ALL_SCOPES =

The scopes needed to make gRPC calls to all of the methods defined in this service.

[
  "https://www.googleapis.com/auth/cloud-platform"
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, service_address: nil, service_port: nil, exception_transformer: nil, lib_name: nil, lib_version: "") ⇒ AutoMLClient

Returns a new instance of AutoMLClient.

Parameters:

  • credentials (Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc) (defaults to: nil)

    Provides the means for authenticating requests made by the client. This parameter can be many types. A Google::Auth::Credentials uses a the properties of its represented keyfile for authenticating requests made by this client. A String will be treated as the path to the keyfile to be used for the construction of credentials for this client. A Hash will be treated as the contents of a keyfile to be used for the construction of credentials for this client. A GRPC::Core::Channel will be used to make calls through. A GRPC::Core::ChannelCredentials for the setting up the RPC client. The channel credentials should already be composed with a GRPC::Core::CallCredentials object. A Proc will be used as an updater_proc for the Grpc channel. The proc transforms the metadata for requests, generally, to give OAuth credentials.

  • scopes (Array<String>) (defaults to: ALL_SCOPES)

    The OAuth scopes for this service. This parameter is ignored if an updater_proc is supplied.

  • client_config (Hash) (defaults to: {})

    A Hash for call options for each method. See Google::Gax#construct_settings for the structure of this data. Falls back to the default config if not specified or the specified config is missing data points.

  • timeout (Numeric) (defaults to: DEFAULT_TIMEOUT)

    The default timeout, in seconds, for calls made through this client.

  • metadata (Hash) (defaults to: nil)

    Default metadata to be sent with each request. This can be overridden on a per call basis.

  • service_address (String) (defaults to: nil)

    Override for the service hostname, or nil to leave as the default.

  • service_port (Integer) (defaults to: nil)

    Override for the service port, or nil to leave as the default.

  • exception_transformer (Proc) (defaults to: nil)

    An optional proc that intercepts any exceptions raised during an API call to inject custom error handling.



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 280

def initialize \
    credentials: nil,
    scopes: ALL_SCOPES,
    client_config: {},
    timeout: DEFAULT_TIMEOUT,
    metadata: nil,
    service_address: nil,
    service_port: nil,
    exception_transformer: nil,
    lib_name: nil,
    lib_version: ""
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "google/gax/grpc"
  require "google/cloud/automl/v1beta1/service_services_pb"

  credentials ||= Google::Cloud::AutoML::V1beta1::Credentials.default

  @operations_client = OperationsClient.new(
    credentials: credentials,
    scopes: scopes,
    client_config: client_config,
    timeout: timeout,
    lib_name: lib_name,
    service_address: service_address,
    service_port: service_port,
    lib_version: lib_version,
    metadata: ,
  )

  if credentials.is_a?(String) || credentials.is_a?(Hash)
    updater_proc = Google::Cloud::AutoML::V1beta1::Credentials.new(credentials).updater_proc
  end
  if credentials.is_a?(GRPC::Core::Channel)
    channel = credentials
  end
  if credentials.is_a?(GRPC::Core::ChannelCredentials)
    chan_creds = credentials
  end
  if credentials.is_a?(Proc)
    updater_proc = credentials
  end
  if credentials.is_a?(Google::Auth::Credentials)
    updater_proc = credentials.updater_proc
  end

  package_version = Google::Cloud::AutoML::VERSION

  google_api_client = "gl-ruby/#{RUBY_VERSION}"
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
  google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
  google_api_client << " grpc/#{GRPC::VERSION}"
  google_api_client.freeze

  headers = { :"x-goog-api-client" => google_api_client }
  headers.merge!() unless .nil?
  client_config_file = Pathname.new(__dir__).join(
    "automl_client_config.json"
  )
  defaults = client_config_file.open do |f|
    Google::Gax.construct_settings(
      "google.cloud.automl.v1beta1.AutoMl",
      JSON.parse(f.read),
      client_config,
      Google::Gax::Grpc::STATUS_CODE_NAMES,
      timeout,
      page_descriptors: PAGE_DESCRIPTORS,
      errors: Google::Gax::Grpc::API_ERRORS,
      metadata: headers
    )
  end

  # Allow overriding the service path/port in subclasses.
  service_path = service_address || self.class::SERVICE_ADDRESS
  port = service_port || self.class::DEFAULT_SERVICE_PORT
  interceptors = self.class::GRPC_INTERCEPTORS
  @automl_stub = Google::Gax::Grpc.create_stub(
    service_path,
    port,
    chan_creds: chan_creds,
    channel: channel,
    updater_proc: updater_proc,
    scopes: scopes,
    interceptors: interceptors,
    &Google::Cloud::AutoML::V1beta1::AutoML::Stub.method(:new)
  )

  @create_dataset = Google::Gax.create_api_call(
    @automl_stub.method(:create_dataset),
    defaults["create_dataset"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @update_dataset = Google::Gax.create_api_call(
    @automl_stub.method(:update_dataset),
    defaults["update_dataset"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'dataset.name' => request.dataset.name}
    end
  )
  @get_dataset = Google::Gax.create_api_call(
    @automl_stub.method(:get_dataset),
    defaults["get_dataset"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @list_datasets = Google::Gax.create_api_call(
    @automl_stub.method(:list_datasets),
    defaults["list_datasets"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @delete_dataset = Google::Gax.create_api_call(
    @automl_stub.method(:delete_dataset),
    defaults["delete_dataset"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @import_data = Google::Gax.create_api_call(
    @automl_stub.method(:import_data),
    defaults["import_data"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @export_data = Google::Gax.create_api_call(
    @automl_stub.method(:export_data),
    defaults["export_data"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @create_model = Google::Gax.create_api_call(
    @automl_stub.method(:create_model),
    defaults["create_model"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @get_model = Google::Gax.create_api_call(
    @automl_stub.method(:get_model),
    defaults["get_model"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @list_models = Google::Gax.create_api_call(
    @automl_stub.method(:list_models),
    defaults["list_models"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @delete_model = Google::Gax.create_api_call(
    @automl_stub.method(:delete_model),
    defaults["delete_model"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @deploy_model = Google::Gax.create_api_call(
    @automl_stub.method(:deploy_model),
    defaults["deploy_model"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @undeploy_model = Google::Gax.create_api_call(
    @automl_stub.method(:undeploy_model),
    defaults["undeploy_model"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @get_model_evaluation = Google::Gax.create_api_call(
    @automl_stub.method(:get_model_evaluation),
    defaults["get_model_evaluation"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @export_model = Google::Gax.create_api_call(
    @automl_stub.method(:export_model),
    defaults["export_model"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @export_evaluated_examples = Google::Gax.create_api_call(
    @automl_stub.method(:export_evaluated_examples),
    defaults["export_evaluated_examples"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @list_model_evaluations = Google::Gax.create_api_call(
    @automl_stub.method(:list_model_evaluations),
    defaults["list_model_evaluations"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @get_annotation_spec = Google::Gax.create_api_call(
    @automl_stub.method(:get_annotation_spec),
    defaults["get_annotation_spec"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @get_table_spec = Google::Gax.create_api_call(
    @automl_stub.method(:get_table_spec),
    defaults["get_table_spec"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @list_table_specs = Google::Gax.create_api_call(
    @automl_stub.method(:list_table_specs),
    defaults["list_table_specs"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @update_table_spec = Google::Gax.create_api_call(
    @automl_stub.method(:update_table_spec),
    defaults["update_table_spec"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'table_spec.name' => request.table_spec.name}
    end
  )
  @get_column_spec = Google::Gax.create_api_call(
    @automl_stub.method(:get_column_spec),
    defaults["get_column_spec"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @list_column_specs = Google::Gax.create_api_call(
    @automl_stub.method(:list_column_specs),
    defaults["list_column_specs"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @update_column_spec = Google::Gax.create_api_call(
    @automl_stub.method(:update_column_spec),
    defaults["update_column_spec"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'column_spec.name' => request.column_spec.name}
    end
  )
end

Class Method Details

.annotation_spec_path(project, location, dataset, annotation_spec) ⇒ String

Returns a fully-qualified annotation_spec resource name string.

Parameters:

  • project (String)
  • location (String)
  • dataset (String)
  • annotation_spec (String)

Returns:

  • (String)


154
155
156
157
158
159
160
161
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 154

def self.annotation_spec_path project, location, dataset, annotation_spec
  ANNOTATION_SPEC_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location,
    :"dataset" => dataset,
    :"annotation_spec" => annotation_spec
  )
end

.column_spec_path(project, location, dataset, table_spec, column_spec) ⇒ String

Returns a fully-qualified column_spec resource name string.

Parameters:

  • project (String)
  • location (String)
  • dataset (String)
  • table_spec (String)
  • column_spec (String)

Returns:

  • (String)


170
171
172
173
174
175
176
177
178
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 170

def self.column_spec_path project, location, dataset, table_spec, column_spec
  COLUMN_SPEC_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location,
    :"dataset" => dataset,
    :"table_spec" => table_spec,
    :"column_spec" => column_spec
  )
end

.dataset_path(project, location, dataset) ⇒ String

Returns a fully-qualified dataset resource name string.

Parameters:

  • project (String)
  • location (String)
  • dataset (String)

Returns:

  • (String)


185
186
187
188
189
190
191
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 185

def self.dataset_path project, location, dataset
  DATASET_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location,
    :"dataset" => dataset
  )
end

.location_path(project, location) ⇒ String

Returns a fully-qualified location resource name string.

Parameters:

  • project (String)
  • location (String)

Returns:

  • (String)


197
198
199
200
201
202
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 197

def self.location_path project, location
  LOCATION_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location
  )
end

.model_evaluation_path(project, location, model, model_evaluation) ⇒ String

Returns a fully-qualified model_evaluation resource name string.

Parameters:

  • project (String)
  • location (String)
  • model (String)
  • model_evaluation (String)

Returns:

  • (String)


223
224
225
226
227
228
229
230
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 223

def self.model_evaluation_path project, location, model, model_evaluation
  MODEL_EVALUATION_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location,
    :"model" => model,
    :"model_evaluation" => model_evaluation
  )
end

.model_path(project, location, model) ⇒ String

Returns a fully-qualified model resource name string.

Parameters:

  • project (String)
  • location (String)
  • model (String)

Returns:

  • (String)


209
210
211
212
213
214
215
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 209

def self.model_path project, location, model
  MODEL_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location,
    :"model" => model
  )
end

.table_spec_path(project, location, dataset, table_spec) ⇒ String

Returns a fully-qualified table_spec resource name string.

Parameters:

  • project (String)
  • location (String)
  • dataset (String)
  • table_spec (String)

Returns:

  • (String)


238
239
240
241
242
243
244
245
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 238

def self.table_spec_path project, location, dataset, table_spec
  TABLE_SPEC_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location,
    :"dataset" => dataset,
    :"table_spec" => table_spec
  )
end

Instance Method Details

#create_dataset(parent, dataset, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::Dataset

Creates a dataset.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_parent = Google::Cloud::AutoML::V1beta1::AutoMLClient.location_path("[PROJECT]", "[LOCATION]")

# TODO: Initialize `dataset`:
dataset = {}
response = automl_client.create_dataset(formatted_parent, dataset)

Parameters:

  • parent (String)

    The resource name of the project to create the dataset for.

  • dataset (Google::Cloud::AutoML::V1beta1::Dataset | Hash)

    The dataset to create. A hash of the same form as Google::Cloud::AutoML::V1beta1::Dataset can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



590
591
592
593
594
595
596
597
598
599
600
601
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 590

def create_dataset \
    parent,
    dataset,
    options: nil,
    &block
  req = {
    parent: parent,
    dataset: dataset
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::CreateDatasetRequest)
  @create_dataset.call(req, options, &block)
end

#create_model(parent, model, options: nil) ⇒ Google::Gax::Operation

Creates a model. Returns a Model in the response field when it completes. When you create a model, several model evaluations are created for it: a global evaluation, and one evaluation for each annotation spec.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_parent = Google::Cloud::AutoML::V1beta1::AutoMLClient.location_path("[PROJECT]", "[LOCATION]")

# TODO: Initialize `model`:
model = {}

# Register a callback during the method call.
operation = automl_client.create_model(formatted_parent, model) do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Or use the return value to register a callback.
operation.on_done do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Manually reload the operation.
operation.reload!

# Or block until the operation completes, triggering callbacks on
# completion.
operation.wait_until_done!

Parameters:

  • parent (String)

    Resource name of the parent project where the model is being created.

  • model (Google::Cloud::AutoML::V1beta1::Model | Hash)

    The model to create. A hash of the same form as Google::Cloud::AutoML::V1beta1::Model can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1009

def create_model \
    parent,
    model,
    options: nil
  req = {
    parent: parent,
    model: model
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::CreateModelRequest)
  operation = Google::Gax::Operation.new(
    @create_model.call(req, options),
    @operations_client,
    Google::Cloud::AutoML::V1beta1::Model,
    Google::Cloud::AutoML::V1beta1::OperationMetadata,
    call_options: options
  )
  operation.on_done { |operation| yield(operation) } if block_given?
  operation
end

#delete_dataset(name, options: nil) ⇒ Google::Gax::Operation

Deletes a dataset and all of its contents. Returns empty response in the response field when it completes, and delete_details in the metadata field.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.dataset_path("[PROJECT]", "[LOCATION]", "[DATASET]")

# Register a callback during the method call.
operation = automl_client.delete_dataset(formatted_name) do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Or use the return value to register a callback.
operation.on_done do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Manually reload the operation.
operation.reload!

# Or block until the operation completes, triggering callbacks on
# completion.
operation.wait_until_done!

Parameters:

  • name (String)

    The resource name of the dataset to delete.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 788

def delete_dataset \
    name,
    options: nil
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::DeleteDatasetRequest)
  operation = Google::Gax::Operation.new(
    @delete_dataset.call(req, options),
    @operations_client,
    Google::Protobuf::Empty,
    Google::Cloud::AutoML::V1beta1::OperationMetadata,
    call_options: options
  )
  operation.on_done { |operation| yield(operation) } if block_given?
  operation
end

#delete_model(name, options: nil) ⇒ Google::Gax::Operation

Deletes a model. Returns google.protobuf.Empty in the response field when it completes, and delete_details in the metadata field.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.model_path("[PROJECT]", "[LOCATION]", "[MODEL]")

# Register a callback during the method call.
operation = automl_client.delete_model(formatted_name) do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Or use the return value to register a callback.
operation.on_done do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Manually reload the operation.
operation.reload!

# Or block until the operation completes, triggering callbacks on
# completion.
operation.wait_until_done!

Parameters:

  • name (String)

    Resource name of the model being deleted.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1171

def delete_model \
    name,
    options: nil
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::DeleteModelRequest)
  operation = Google::Gax::Operation.new(
    @delete_model.call(req, options),
    @operations_client,
    Google::Protobuf::Empty,
    Google::Cloud::AutoML::V1beta1::OperationMetadata,
    call_options: options
  )
  operation.on_done { |operation| yield(operation) } if block_given?
  operation
end

#deploy_model(name, image_object_detection_model_deployment_metadata: nil, options: nil) ⇒ Google::Gax::Operation

Deploys a model. If a model is already deployed, deploying it with the same parameters has no effect. Deploying with different parametrs (as e.g. changing

node_number) will reset the deployment state without pausing the model's availability.

Only applicable for Text Classification, Image Object Detection and Tables; all other domains manage deployment automatically.

Returns an empty response in the response field when it completes.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.model_path("[PROJECT]", "[LOCATION]", "[MODEL]")

# Register a callback during the method call.
operation = automl_client.deploy_model(formatted_name) do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Or use the return value to register a callback.
operation.on_done do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Manually reload the operation.
operation.reload!

# Or block until the operation completes, triggering callbacks on
# completion.
operation.wait_until_done!

Parameters:

  • name (String)

    Resource name of the model to deploy.

  • image_object_detection_model_deployment_metadata (Google::Cloud::AutoML::V1beta1::ImageObjectDetectionModelDeploymentMetadata | Hash) (defaults to: nil)

    Model deployment metadata specific to Image Object Detection. A hash of the same form as Google::Cloud::AutoML::V1beta1::ImageObjectDetectionModelDeploymentMetadata can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1246

def deploy_model \
    name,
    image_object_detection_model_deployment_metadata: nil,
    options: nil
  req = {
    name: name,
    image_object_detection_model_deployment_metadata: 
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::DeployModelRequest)
  operation = Google::Gax::Operation.new(
    @deploy_model.call(req, options),
    @operations_client,
    Google::Protobuf::Empty,
    Google::Cloud::AutoML::V1beta1::OperationMetadata,
    call_options: options
  )
  operation.on_done { |operation| yield(operation) } if block_given?
  operation
end

#export_data(name, output_config, options: nil) ⇒ Google::Gax::Operation

Exports dataset's data to the provided output location. Returns an empty response in the response field when it completes.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.dataset_path("[PROJECT]", "[LOCATION]", "[DATASET]")

# TODO: Initialize `output_config`:
output_config = {}

# Register a callback during the method call.
operation = automl_client.export_data(formatted_name, output_config) do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Or use the return value to register a callback.
operation.on_done do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Manually reload the operation.
operation.reload!

# Or block until the operation completes, triggering callbacks on
# completion.
operation.wait_until_done!

Parameters:

  • name (String)

    Required. The resource name of the dataset.

  • output_config (Google::Cloud::AutoML::V1beta1::OutputConfig | Hash)

    Required. The desired output location. A hash of the same form as Google::Cloud::AutoML::V1beta1::OutputConfig can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 936

def export_data \
    name,
    output_config,
    options: nil
  req = {
    name: name,
    output_config: output_config
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::ExportDataRequest)
  operation = Google::Gax::Operation.new(
    @export_data.call(req, options),
    @operations_client,
    Google::Protobuf::Empty,
    Google::Cloud::AutoML::V1beta1::OperationMetadata,
    call_options: options
  )
  operation.on_done { |operation| yield(operation) } if block_given?
  operation
end

#export_evaluated_examples(name, output_config, options: nil) ⇒ Google::Gax::Operation

Exports examples on which the model was evaluated (i.e. which were in the TEST set of the dataset the model was created from), together with their ground truth annotations and the annotations created (predicted) by the model. The examples, ground truth and predictions are exported in the state they were at the moment the model was evaluated.

This export is available only for 30 days since the model evaluation is created.

Currently only available for Tables.

Returns an empty response in the response field when it completes.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.model_path("[PROJECT]", "[LOCATION]", "[MODEL]")

# TODO: Initialize `output_config`:
output_config = {}

# Register a callback during the method call.
operation = automl_client.export_evaluated_examples(formatted_name, output_config) do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Or use the return value to register a callback.
operation.on_done do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Manually reload the operation.
operation.reload!

# Or block until the operation completes, triggering callbacks on
# completion.
operation.wait_until_done!

Parameters:

  • name (String)

    Required. The resource name of the model whose evaluated examples are to be exported.

  • output_config (Google::Cloud::AutoML::V1beta1::ExportEvaluatedExamplesOutputConfig | Hash)

    Required. The desired output location and configuration. A hash of the same form as Google::Cloud::AutoML::V1beta1::ExportEvaluatedExamplesOutputConfig can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1501

def export_evaluated_examples \
    name,
    output_config,
    options: nil
  req = {
    name: name,
    output_config: output_config
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::ExportEvaluatedExamplesRequest)
  operation = Google::Gax::Operation.new(
    @export_evaluated_examples.call(req, options),
    @operations_client,
    Google::Protobuf::Empty,
    Google::Cloud::AutoML::V1beta1::OperationMetadata,
    call_options: options
  )
  operation.on_done { |operation| yield(operation) } if block_given?
  operation
end

#export_model(name, output_config, options: nil) ⇒ Google::Gax::Operation

Exports a trained, "export-able", model to a user specified Google Cloud Storage location. A model is considered export-able if and only if it has an export format defined for it in

ModelExportOutputConfig.

Returns an empty response in the response field when it completes.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.model_path("[PROJECT]", "[LOCATION]", "[MODEL]")

# TODO: Initialize `output_config`:
output_config = {}

# Register a callback during the method call.
operation = automl_client.export_model(formatted_name, output_config) do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Or use the return value to register a callback.
operation.on_done do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Manually reload the operation.
operation.reload!

# Or block until the operation completes, triggering callbacks on
# completion.
operation.wait_until_done!

Parameters:

  • name (String)

    Required. The resource name of the model to export.

  • output_config (Google::Cloud::AutoML::V1beta1::ModelExportOutputConfig | Hash)

    Required. The desired output location and configuration. A hash of the same form as Google::Cloud::AutoML::V1beta1::ModelExportOutputConfig can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1418

def export_model \
    name,
    output_config,
    options: nil
  req = {
    name: name,
    output_config: output_config
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::ExportModelRequest)
  operation = Google::Gax::Operation.new(
    @export_model.call(req, options),
    @operations_client,
    Google::Protobuf::Empty,
    Google::Cloud::AutoML::V1beta1::OperationMetadata,
    call_options: options
  )
  operation.on_done { |operation| yield(operation) } if block_given?
  operation
end

#get_annotation_spec(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::AnnotationSpec

Gets an annotation spec.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.annotation_spec_path("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]")
response = automl_client.get_annotation_spec(formatted_name)

Parameters:

  • name (String)

    The resource name of the annotation spec to retrieve.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1610

def get_annotation_spec \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::GetAnnotationSpecRequest)
  @get_annotation_spec.call(req, options, &block)
end

#get_column_spec(name, field_mask: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::ColumnSpec

Gets a column spec.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.column_spec_path("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]")
response = automl_client.get_column_spec(formatted_name)

Parameters:

  • name (String)

    The resource name of the column spec to retrieve.

  • field_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    Mask specifying which fields to read. A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1789

def get_column_spec \
    name,
    field_mask: nil,
    options: nil,
    &block
  req = {
    name: name,
    field_mask: field_mask
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::GetColumnSpecRequest)
  @get_column_spec.call(req, options, &block)
end

#get_dataset(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::Dataset

Gets a dataset.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.dataset_path("[PROJECT]", "[LOCATION]", "[DATASET]")
response = automl_client.get_dataset(formatted_name)

Parameters:

  • name (String)

    The resource name of the dataset to retrieve.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



667
668
669
670
671
672
673
674
675
676
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 667

def get_dataset \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::GetDatasetRequest)
  @get_dataset.call(req, options, &block)
end

#get_model(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::Model

Gets a model.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.model_path("[PROJECT]", "[LOCATION]", "[MODEL]")
response = automl_client.get_model(formatted_name)

Parameters:

  • name (String)

    Resource name of the model.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1048

def get_model \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::GetModelRequest)
  @get_model.call(req, options, &block)
end

#get_model_evaluation(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::ModelEvaluation

Gets a model evaluation.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.model_evaluation_path("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]")
response = automl_client.get_model_evaluation(formatted_name)

Parameters:

  • name (String)

    Resource name for the model evaluation.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1351

def get_model_evaluation \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::GetModelEvaluationRequest)
  @get_model_evaluation.call(req, options, &block)
end

#get_table_spec(name, field_mask: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::TableSpec

Gets a table spec.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.table_spec_path("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]")
response = automl_client.get_table_spec(formatted_name)

Parameters:

  • name (String)

    The resource name of the table spec to retrieve.

  • field_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    Mask specifying which fields to read. A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1644

def get_table_spec \
    name,
    field_mask: nil,
    options: nil,
    &block
  req = {
    name: name,
    field_mask: field_mask
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::GetTableSpecRequest)
  @get_table_spec.call(req, options, &block)
end

#import_data(name, input_config, options: nil) ⇒ Google::Gax::Operation

Imports data into a dataset. For Tables this method can only be called on an empty Dataset.

For Tables:

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.dataset_path("[PROJECT]", "[LOCATION]", "[DATASET]")

# TODO: Initialize `input_config`:
input_config = {}

# Register a callback during the method call.
operation = automl_client.import_data(formatted_name, input_config) do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Or use the return value to register a callback.
operation.on_done do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Manually reload the operation.
operation.reload!

# Or block until the operation completes, triggering callbacks on
# completion.
operation.wait_until_done!

Parameters:

  • name (String)

    Required. Dataset name. Dataset must already exist. All imported annotations and examples will be added.

  • input_config (Google::Cloud::AutoML::V1beta1::InputConfig | Hash)

    Required. The desired input location and its domain specific semantics, if any. A hash of the same form as Google::Cloud::AutoML::V1beta1::InputConfig can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 865

def import_data \
    name,
    input_config,
    options: nil
  req = {
    name: name,
    input_config: input_config
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::ImportDataRequest)
  operation = Google::Gax::Operation.new(
    @import_data.call(req, options),
    @operations_client,
    Google::Protobuf::Empty,
    Google::Cloud::AutoML::V1beta1::OperationMetadata,
    call_options: options
  )
  operation.on_done { |operation| yield(operation) } if block_given?
  operation
end

#list_column_specs(parent, field_mask: nil, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::ColumnSpec>

Lists column specs in a table spec.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_parent = Google::Cloud::AutoML::V1beta1::AutoMLClient.table_spec_path("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]")

# Iterate over all results.
automl_client.list_column_specs(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
automl_client.list_column_specs(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    The resource name of the table spec to list column specs from.

  • field_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    Mask specifying which fields to read. A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • filter (String) (defaults to: nil)

    Filter expression, see go/filtering.

  • page_size (Integer) (defaults to: nil)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::ColumnSpec>)

    An enumerable of Google::Cloud::AutoML::V1beta1::ColumnSpec instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1849

def list_column_specs \
    parent,
    field_mask: nil,
    filter: nil,
    page_size: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    field_mask: field_mask,
    filter: filter,
    page_size: page_size
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::ListColumnSpecsRequest)
  @list_column_specs.call(req, options, &block)
end

#list_datasets(parent, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::Dataset>

Lists datasets in a project.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_parent = Google::Cloud::AutoML::V1beta1::AutoMLClient.location_path("[PROJECT]", "[LOCATION]")

# Iterate over all results.
automl_client.list_datasets(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
automl_client.list_datasets(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    The resource name of the project from which to list datasets.

  • filter (String) (defaults to: nil)

    An expression for filtering the results of the request.

    • dataset_metadata - for existence of the case (e.g. image_classification_dataset_metadata:*). Some examples of using the filter are:

      • translation_dataset_metadata:* --> The dataset has translation_dataset_metadata.
  • page_size (Integer) (defaults to: nil)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::Dataset>)

    An enumerable of Google::Cloud::AutoML::V1beta1::Dataset instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



727
728
729
730
731
732
733
734
735
736
737
738
739
740
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 727

def list_datasets \
    parent,
    filter: nil,
    page_size: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    filter: filter,
    page_size: page_size
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::ListDatasetsRequest)
  @list_datasets.call(req, options, &block)
end

#list_model_evaluations(parent, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::ModelEvaluation>

Lists model evaluations.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_parent = Google::Cloud::AutoML::V1beta1::AutoMLClient.model_path("[PROJECT]", "[LOCATION]", "[MODEL]")

# Iterate over all results.
automl_client.list_model_evaluations(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
automl_client.list_model_evaluations(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    Resource name of the model to list the model evaluations for. If modelId is set as "-", this will list model evaluations from across all models of the parent location.

  • filter (String) (defaults to: nil)

    An expression for filtering the results of the request.

    • annotation_spec_id - for =, != or existence. See example below for the last.

    Some examples of using the filter are:

    • annotation_spec_id!=4 --> The model evaluation was done for annotation spec with ID different than 4.
      • NOT annotation_spec_id:* --> The model evaluation was done for aggregate of all annotation specs.
  • page_size (Integer) (defaults to: nil)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::ModelEvaluation>)

    An enumerable of Google::Cloud::AutoML::V1beta1::ModelEvaluation instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1576

def list_model_evaluations \
    parent,
    filter: nil,
    page_size: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    filter: filter,
    page_size: page_size
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::ListModelEvaluationsRequest)
  @list_model_evaluations.call(req, options, &block)
end

#list_models(parent, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::Model>

Lists models.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_parent = Google::Cloud::AutoML::V1beta1::AutoMLClient.location_path("[PROJECT]", "[LOCATION]")

# Iterate over all results.
automl_client.list_models(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
automl_client.list_models(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    Resource name of the project, from which to list the models.

  • filter (String) (defaults to: nil)

    An expression for filtering the results of the request.

    • model_metadata - for existence of the case (e.g. video_classification_model_metadata:*).

      • dataset_id - for = or !=. Some examples of using the filter are:
      • image_classification_model_metadata:* --> The model has image_classification_model_metadata.
      • dataset_id=5 --> The model was created from a dataset with ID 5.
  • page_size (Integer) (defaults to: nil)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::Model>)

    An enumerable of Google::Cloud::AutoML::V1beta1::Model instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1110

def list_models \
    parent,
    filter: nil,
    page_size: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    filter: filter,
    page_size: page_size
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::ListModelsRequest)
  @list_models.call(req, options, &block)
end

#list_table_specs(parent, field_mask: nil, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::TableSpec>

Lists table specs in a dataset.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_parent = Google::Cloud::AutoML::V1beta1::AutoMLClient.dataset_path("[PROJECT]", "[LOCATION]", "[DATASET]")

# Iterate over all results.
automl_client.list_table_specs(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
automl_client.list_table_specs(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    The resource name of the dataset to list table specs from.

  • field_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    Mask specifying which fields to read. A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • filter (String) (defaults to: nil)

    Filter expression, see go/filtering.

  • page_size (Integer) (defaults to: nil)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::AutoML::V1beta1::TableSpec>)

    An enumerable of Google::Cloud::AutoML::V1beta1::TableSpec instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1704

def list_table_specs \
    parent,
    field_mask: nil,
    filter: nil,
    page_size: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    field_mask: field_mask,
    filter: filter,
    page_size: page_size
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::ListTableSpecsRequest)
  @list_table_specs.call(req, options, &block)
end

#undeploy_model(name, options: nil) ⇒ Google::Gax::Operation

Undeploys a model. If the model is not deployed this method has no effect.

Only applicable for Text Classification, Image Object Detection and Tables; all other domains manage deployment automatically.

Returns an empty response in the response field when it completes.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)
formatted_name = Google::Cloud::AutoML::V1beta1::AutoMLClient.model_path("[PROJECT]", "[LOCATION]", "[MODEL]")

# Register a callback during the method call.
operation = automl_client.undeploy_model(formatted_name) do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Or use the return value to register a callback.
operation.on_done do |op|
  raise op.results.message if op.error?
  op_results = op.results
  # Process the results.

   = op.
  # Process the metadata.
end

# Manually reload the operation.
operation.reload!

# Or block until the operation completes, triggering callbacks on
# completion.
operation.wait_until_done!

Parameters:

  • name (String)

    Resource name of the model to undeploy.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1314

def undeploy_model \
    name,
    options: nil
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::UndeployModelRequest)
  operation = Google::Gax::Operation.new(
    @undeploy_model.call(req, options),
    @operations_client,
    Google::Protobuf::Empty,
    Google::Cloud::AutoML::V1beta1::OperationMetadata,
    call_options: options
  )
  operation.on_done { |operation| yield(operation) } if block_given?
  operation
end

#update_column_spec(column_spec, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::ColumnSpec

Updates a column spec.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)

# TODO: Initialize `column_spec`:
column_spec = {}
response = automl_client.update_column_spec(column_spec)

Parameters:

  • column_spec (Google::Cloud::AutoML::V1beta1::ColumnSpec | Hash)

    The column spec which replaces the resource on the server. A hash of the same form as Google::Cloud::AutoML::V1beta1::ColumnSpec can also be provided.

  • update_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    The update mask applies to the resource. For the FieldMask definition, see

    https: //developers.google.com/protocol-buffers // /docs/reference/google.protobuf#fieldmask A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1898

def update_column_spec \
    column_spec,
    update_mask: nil,
    options: nil,
    &block
  req = {
    column_spec: column_spec,
    update_mask: update_mask
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::UpdateColumnSpecRequest)
  @update_column_spec.call(req, options, &block)
end

#update_dataset(dataset, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::Dataset

Updates a dataset.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)

# TODO: Initialize `dataset`:
dataset = {}
response = automl_client.update_dataset(dataset)

Parameters:

  • dataset (Google::Cloud::AutoML::V1beta1::Dataset | Hash)

    The dataset which replaces the resource on the server. A hash of the same form as Google::Cloud::AutoML::V1beta1::Dataset can also be provided.

  • update_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    The update mask applies to the resource. For the FieldMask definition, see

    https: //developers.google.com/protocol-buffers // /docs/reference/google.protobuf#fieldmask A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



635
636
637
638
639
640
641
642
643
644
645
646
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 635

def update_dataset \
    dataset,
    update_mask: nil,
    options: nil,
    &block
  req = {
    dataset: dataset,
    update_mask: update_mask
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::UpdateDatasetRequest)
  @update_dataset.call(req, options, &block)
end

#update_table_spec(table_spec, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::AutoML::V1beta1::TableSpec

Updates a table spec.

Examples:

require "google/cloud/automl"

automl_client = Google::Cloud::AutoML::AutoML.new(version: :v1beta1)

# TODO: Initialize `table_spec`:
table_spec = {}
response = automl_client.update_table_spec(table_spec)

Parameters:

  • table_spec (Google::Cloud::AutoML::V1beta1::TableSpec | Hash)

    The table spec which replaces the resource on the server. A hash of the same form as Google::Cloud::AutoML::V1beta1::TableSpec can also be provided.

  • update_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    The update mask applies to the resource. For the FieldMask definition, see

    https: //developers.google.com/protocol-buffers // /docs/reference/google.protobuf#fieldmask A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
# File 'lib/google/cloud/automl/v1beta1/automl_client.rb', line 1753

def update_table_spec \
    table_spec,
    update_mask: nil,
    options: nil,
    &block
  req = {
    table_spec: table_spec,
    update_mask: update_mask
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::AutoML::V1beta1::UpdateTableSpecRequest)
  @update_table_spec.call(req, options, &block)
end