automl

package
v0.49.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2019 License: Apache-2.0 Imports: 20 Imported by: 5

Documentation

Overview

Train high-quality custom machine learning models with minimum effort and machine learning expertise.

Use of Context

The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

For information about setting deadlines, reusing contexts, and more please visit godoc.org/cloud.google.com/go.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

Types

type BatchPredictOperation added in v0.48.0

type BatchPredictOperation struct {
	// contains filtered or unexported fields
}

BatchPredictOperation manages a long-running operation from BatchPredict.

func (*BatchPredictOperation) Done added in v0.48.0

func (op *BatchPredictOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*BatchPredictOperation) Metadata added in v0.48.0

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*BatchPredictOperation) Name added in v0.48.0

func (op *BatchPredictOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*BatchPredictOperation) Poll added in v0.48.0

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*BatchPredictOperation) Wait added in v0.48.0

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

type CallOptions

type CallOptions struct {
	CreateDataset        []gax.CallOption
	UpdateDataset        []gax.CallOption
	GetDataset           []gax.CallOption
	ListDatasets         []gax.CallOption
	DeleteDataset        []gax.CallOption
	ImportData           []gax.CallOption
	ExportData           []gax.CallOption
	GetAnnotationSpec    []gax.CallOption
	CreateModel          []gax.CallOption
	GetModel             []gax.CallOption
	UpdateModel          []gax.CallOption
	ListModels           []gax.CallOption
	DeleteModel          []gax.CallOption
	DeployModel          []gax.CallOption
	UndeployModel        []gax.CallOption
	ExportModel          []gax.CallOption
	GetModelEvaluation   []gax.CallOption
	ListModelEvaluations []gax.CallOption
}

CallOptions contains the retry settings for each method of Client.

type Client

type Client struct {

	// LROClient is used internally to handle longrunning operations.
	// It is exposed so that its CallOptions can be modified if required.
	// Users should not Close this client.
	LROClient *lroauto.OperationsClient

	// The call options for this service.
	CallOptions *CallOptions
	// contains filtered or unexported fields
}

Client is a client for interacting with Cloud AutoML API.

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewClient

func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error)

NewClient creates a new auto ml client.

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.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}
Output:

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*Client) Connection

func (c *Client) Connection() *grpc.ClientConn

Connection returns the client's connection to the API service.

func (*Client) CreateDataset

CreateDataset creates a dataset.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.CreateDatasetRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.CreateDataset(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) CreateDatasetOperation

func (c *Client) CreateDatasetOperation(name string) *CreateDatasetOperation

CreateDatasetOperation returns a new CreateDatasetOperation from a given name. The name must be that of a previously created CreateDatasetOperation, possibly from a different process.

func (*Client) CreateModel

func (c *Client) CreateModel(ctx context.Context, req *automlpb.CreateModelRequest, opts ...gax.CallOption) (*CreateModelOperation, error)

CreateModel creates a model. Returns a Model in the [response][google.longrunning.Operation.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.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.CreateModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.CreateModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) CreateModelOperation

func (c *Client) CreateModelOperation(name string) *CreateModelOperation

CreateModelOperation returns a new CreateModelOperation from a given name. The name must be that of a previously created CreateModelOperation, possibly from a different process.

func (*Client) DeleteDataset

DeleteDataset deletes a dataset and all of its contents. Returns empty response in the [response][google.longrunning.Operation.response] field when it completes, and delete_details in the metadata[google.longrunning.Operation.metadata] field.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.DeleteDatasetRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.DeleteDataset(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	// TODO: Handle error.
}
Output:

func (*Client) DeleteDatasetOperation

func (c *Client) DeleteDatasetOperation(name string) *DeleteDatasetOperation

DeleteDatasetOperation returns a new DeleteDatasetOperation from a given name. The name must be that of a previously created DeleteDatasetOperation, possibly from a different process.

func (*Client) DeleteModel

func (c *Client) DeleteModel(ctx context.Context, req *automlpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error)

DeleteModel deletes a model. Returns google.protobuf.Empty in the [response][google.longrunning.Operation.response] field when it completes, and delete_details in the metadata[google.longrunning.Operation.metadata] field.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.DeleteModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.DeleteModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	// TODO: Handle error.
}
Output:

func (*Client) DeleteModelOperation

func (c *Client) DeleteModelOperation(name string) *DeleteModelOperation

DeleteModelOperation returns a new DeleteModelOperation from a given name. The name must be that of a previously created DeleteModelOperation, possibly from a different process.

func (*Client) DeployModel added in v0.48.0

func (c *Client) DeployModel(ctx context.Context, req *automlpb.DeployModelRequest, opts ...gax.CallOption) (*DeployModelOperation, error)

DeployModel 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][google.cloud.automl.v1.ImageObjectDetectionModelDeploymentMetadata.node_number]) will reset the deployment state without pausing the model's availability.

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

Returns an empty response in the [response][google.longrunning.Operation.response] field when it completes.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.DeployModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.DeployModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	// TODO: Handle error.
}
Output:

func (*Client) DeployModelOperation added in v0.48.0

func (c *Client) DeployModelOperation(name string) *DeployModelOperation

DeployModelOperation returns a new DeployModelOperation from a given name. The name must be that of a previously created DeployModelOperation, possibly from a different process.

func (*Client) ExportData

func (c *Client) ExportData(ctx context.Context, req *automlpb.ExportDataRequest, opts ...gax.CallOption) (*ExportDataOperation, error)

ExportData exports dataset's data to the provided output location. Returns an empty response in the [response][google.longrunning.Operation.response] field when it completes.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ExportDataRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.ExportData(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	// TODO: Handle error.
}
Output:

func (*Client) ExportDataOperation

func (c *Client) ExportDataOperation(name string) *ExportDataOperation

ExportDataOperation returns a new ExportDataOperation from a given name. The name must be that of a previously created ExportDataOperation, possibly from a different process.

func (*Client) ExportModel added in v0.48.0

func (c *Client) ExportModel(ctx context.Context, req *automlpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error)

ExportModel 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][google.cloud.automl.v1.ModelExportOutputConfig].

Returns an empty response in the [response][google.longrunning.Operation.response] field when it completes.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ExportModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.ExportModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	// TODO: Handle error.
}
Output:

func (*Client) ExportModelOperation added in v0.48.0

func (c *Client) ExportModelOperation(name string) *ExportModelOperation

ExportModelOperation returns a new ExportModelOperation from a given name. The name must be that of a previously created ExportModelOperation, possibly from a different process.

func (*Client) GetAnnotationSpec added in v0.48.0

func (c *Client) GetAnnotationSpec(ctx context.Context, req *automlpb.GetAnnotationSpecRequest, opts ...gax.CallOption) (*automlpb.AnnotationSpec, error)

GetAnnotationSpec gets an annotation spec.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.GetAnnotationSpecRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetAnnotationSpec(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) GetDataset

func (c *Client) GetDataset(ctx context.Context, req *automlpb.GetDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error)

GetDataset gets a dataset.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.GetDatasetRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetDataset(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) GetModel

func (c *Client) GetModel(ctx context.Context, req *automlpb.GetModelRequest, opts ...gax.CallOption) (*automlpb.Model, error)

GetModel gets a model.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.GetModelRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) GetModelEvaluation

func (c *Client) GetModelEvaluation(ctx context.Context, req *automlpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*automlpb.ModelEvaluation, error)

GetModelEvaluation gets a model evaluation.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.GetModelEvaluationRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetModelEvaluation(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) ImportData

func (c *Client) ImportData(ctx context.Context, req *automlpb.ImportDataRequest, opts ...gax.CallOption) (*ImportDataOperation, error)

ImportData imports data into a dataset.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ImportDataRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.ImportData(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	// TODO: Handle error.
}
Output:

func (*Client) ImportDataOperation

func (c *Client) ImportDataOperation(name string) *ImportDataOperation

ImportDataOperation returns a new ImportDataOperation from a given name. The name must be that of a previously created ImportDataOperation, possibly from a different process.

func (*Client) ListDatasets

func (c *Client) ListDatasets(ctx context.Context, req *automlpb.ListDatasetsRequest, opts ...gax.CallOption) *DatasetIterator

ListDatasets lists datasets in a project.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	"google.golang.org/api/iterator"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ListDatasetsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListDatasets(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*Client) ListModelEvaluations

func (c *Client) ListModelEvaluations(ctx context.Context, req *automlpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator

ListModelEvaluations lists model evaluations.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	"google.golang.org/api/iterator"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ListModelEvaluationsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListModelEvaluations(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context, req *automlpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator

ListModels lists models.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	"google.golang.org/api/iterator"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ListModelsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListModels(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*Client) UndeployModel added in v0.48.0

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

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

Returns an empty response in the [response][google.longrunning.Operation.response] field when it completes.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.UndeployModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.UndeployModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	// TODO: Handle error.
}
Output:

func (*Client) UndeployModelOperation added in v0.48.0

func (c *Client) UndeployModelOperation(name string) *UndeployModelOperation

UndeployModelOperation returns a new UndeployModelOperation from a given name. The name must be that of a previously created UndeployModelOperation, possibly from a different process.

func (*Client) UpdateDataset

func (c *Client) UpdateDataset(ctx context.Context, req *automlpb.UpdateDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error)

UpdateDataset updates a dataset.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.UpdateDatasetRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateDataset(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) UpdateModel

func (c *Client) UpdateModel(ctx context.Context, req *automlpb.UpdateModelRequest, opts ...gax.CallOption) (*automlpb.Model, error)

UpdateModel updates a model.

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.UpdateModelRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

type CreateDatasetOperation

type CreateDatasetOperation struct {
	// contains filtered or unexported fields
}

CreateDatasetOperation manages a long-running operation from CreateDataset.

func (*CreateDatasetOperation) Done

func (op *CreateDatasetOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*CreateDatasetOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*CreateDatasetOperation) Name

func (op *CreateDatasetOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*CreateDatasetOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*CreateDatasetOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

type CreateModelOperation

type CreateModelOperation struct {
	// contains filtered or unexported fields
}

CreateModelOperation manages a long-running operation from CreateModel.

func (*CreateModelOperation) Done

func (op *CreateModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*CreateModelOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*CreateModelOperation) Name

func (op *CreateModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*CreateModelOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*CreateModelOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

type DatasetIterator

type DatasetIterator struct {

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*automlpb.Dataset, nextPageToken string, err error)
	// contains filtered or unexported fields
}

DatasetIterator manages a stream of *automlpb.Dataset.

func (*DatasetIterator) Next

func (it *DatasetIterator) Next() (*automlpb.Dataset, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*DatasetIterator) PageInfo

func (it *DatasetIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type DeleteDatasetOperation

type DeleteDatasetOperation struct {
	// contains filtered or unexported fields
}

DeleteDatasetOperation manages a long-running operation from DeleteDataset.

func (*DeleteDatasetOperation) Done

func (op *DeleteDatasetOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*DeleteDatasetOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*DeleteDatasetOperation) Name

func (op *DeleteDatasetOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*DeleteDatasetOperation) Poll

func (op *DeleteDatasetOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true.

func (*DeleteDatasetOperation) Wait

func (op *DeleteDatasetOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning any error encountered.

See documentation of Poll for error-handling information.

type DeleteModelOperation

type DeleteModelOperation struct {
	// contains filtered or unexported fields
}

DeleteModelOperation manages a long-running operation from DeleteModel.

func (*DeleteModelOperation) Done

func (op *DeleteModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*DeleteModelOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*DeleteModelOperation) Name

func (op *DeleteModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*DeleteModelOperation) Poll

func (op *DeleteModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true.

func (*DeleteModelOperation) Wait

func (op *DeleteModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning any error encountered.

See documentation of Poll for error-handling information.

type DeployModelOperation added in v0.48.0

type DeployModelOperation struct {
	// contains filtered or unexported fields
}

DeployModelOperation manages a long-running operation from DeployModel.

func (*DeployModelOperation) Done added in v0.48.0

func (op *DeployModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*DeployModelOperation) Metadata added in v0.48.0

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*DeployModelOperation) Name added in v0.48.0

func (op *DeployModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*DeployModelOperation) Poll added in v0.48.0

func (op *DeployModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true.

func (*DeployModelOperation) Wait added in v0.48.0

func (op *DeployModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning any error encountered.

See documentation of Poll for error-handling information.

type ExportDataOperation

type ExportDataOperation struct {
	// contains filtered or unexported fields
}

ExportDataOperation manages a long-running operation from ExportData.

func (*ExportDataOperation) Done

func (op *ExportDataOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*ExportDataOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*ExportDataOperation) Name

func (op *ExportDataOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*ExportDataOperation) Poll

func (op *ExportDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true.

func (*ExportDataOperation) Wait

func (op *ExportDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning any error encountered.

See documentation of Poll for error-handling information.

type ExportModelOperation added in v0.48.0

type ExportModelOperation struct {
	// contains filtered or unexported fields
}

ExportModelOperation manages a long-running operation from ExportModel.

func (*ExportModelOperation) Done added in v0.48.0

func (op *ExportModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*ExportModelOperation) Metadata added in v0.48.0

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*ExportModelOperation) Name added in v0.48.0

func (op *ExportModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*ExportModelOperation) Poll added in v0.48.0

func (op *ExportModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true.

func (*ExportModelOperation) Wait added in v0.48.0

func (op *ExportModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning any error encountered.

See documentation of Poll for error-handling information.

type ImportDataOperation

type ImportDataOperation struct {
	// contains filtered or unexported fields
}

ImportDataOperation manages a long-running operation from ImportData.

func (*ImportDataOperation) Done

func (op *ImportDataOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*ImportDataOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*ImportDataOperation) Name

func (op *ImportDataOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*ImportDataOperation) Poll

func (op *ImportDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true.

func (*ImportDataOperation) Wait

func (op *ImportDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning any error encountered.

See documentation of Poll for error-handling information.

type ModelEvaluationIterator

type ModelEvaluationIterator struct {

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*automlpb.ModelEvaluation, nextPageToken string, err error)
	// contains filtered or unexported fields
}

ModelEvaluationIterator manages a stream of *automlpb.ModelEvaluation.

func (*ModelEvaluationIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*ModelEvaluationIterator) PageInfo

func (it *ModelEvaluationIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type ModelIterator

type ModelIterator struct {

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*automlpb.Model, nextPageToken string, err error)
	// contains filtered or unexported fields
}

ModelIterator manages a stream of *automlpb.Model.

func (*ModelIterator) Next

func (it *ModelIterator) Next() (*automlpb.Model, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*ModelIterator) PageInfo

func (it *ModelIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type PredictionCallOptions

type PredictionCallOptions struct {
	Predict      []gax.CallOption
	BatchPredict []gax.CallOption
}

PredictionCallOptions contains the retry settings for each method of PredictionClient.

type PredictionClient

type PredictionClient struct {

	// LROClient is used internally to handle longrunning operations.
	// It is exposed so that its CallOptions can be modified if required.
	// Users should not Close this client.
	LROClient *lroauto.OperationsClient

	// The call options for this service.
	CallOptions *PredictionCallOptions
	// contains filtered or unexported fields
}

PredictionClient is a client for interacting with Cloud AutoML API.

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewPredictionClient

func NewPredictionClient(ctx context.Context, opts ...option.ClientOption) (*PredictionClient, error)

NewPredictionClient creates a new prediction service client.

AutoML Prediction API.

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

Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewPredictionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}
Output:

func (*PredictionClient) BatchPredict added in v0.48.0

BatchPredict perform a batch prediction. Unlike the online [Predict][google.cloud.automl.v1.PredictionService.Predict], batch prediction result won't be immediately available in the response. Instead, a long running operation object is returned. User can poll the operation result via [GetOperation][google.longrunning.Operations.GetOperation] method. Once the operation is done, [BatchPredictResult][google.cloud.automl.v1.BatchPredictResult] is returned in the [response][google.longrunning.Operation.response] field. Available for following ML problems:

Image Classification

Image Object Detection

Text Extraction
Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewPredictionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.BatchPredictRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.BatchPredict(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*PredictionClient) BatchPredictOperation added in v0.48.0

func (c *PredictionClient) BatchPredictOperation(name string) *BatchPredictOperation

BatchPredictOperation returns a new BatchPredictOperation from a given name. The name must be that of a previously created BatchPredictOperation, possibly from a different process.

func (*PredictionClient) Close

func (c *PredictionClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*PredictionClient) Connection

func (c *PredictionClient) Connection() *grpc.ClientConn

Connection returns the client's connection to the API service.

func (*PredictionClient) Predict

Predict perform an online prediction. The prediction result will be directly returned in the response. Available for following ML problems, and their expected request payloads:

Image Classification - Image in .JPEG, .GIF or .PNG format, image_bytes
up to 30MB.

Image Object Detection - Image in .JPEG, .GIF or .PNG format, image_bytes
up to 30MB.

Text Classification - TextSnippet, content up to 60,000 characters,
UTF-8 encoded.

Text Extraction - TextSnippet, content up to 30,000 characters,
UTF-8 NFC encoded.

Translation - TextSnippet, content up to 25,000 characters, UTF-8
encoded.

Text Sentiment - TextSnippet, content up 500 characters, UTF-8
encoded.
Example
package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewPredictionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.PredictRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.Predict(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

type UndeployModelOperation added in v0.48.0

type UndeployModelOperation struct {
	// contains filtered or unexported fields
}

UndeployModelOperation manages a long-running operation from UndeployModel.

func (*UndeployModelOperation) Done added in v0.48.0

func (op *UndeployModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*UndeployModelOperation) Metadata added in v0.48.0

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*UndeployModelOperation) Name added in v0.48.0

func (op *UndeployModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*UndeployModelOperation) Poll added in v0.48.0

func (op *UndeployModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true.

func (*UndeployModelOperation) Wait added in v0.48.0

func (op *UndeployModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning any error encountered.

See documentation of Poll for error-handling information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL