README

Feast Golang SDK

The Feast golang SDK currently only supports retrieval from online stores.

Quickstart

import (
    "context"
    feast "github.com/feast-dev/feast/sdk/go"
)

func main() {
    cli, err := feast.NewGrpcClient("localhost", 6565)
    if err != nil {
        panic(err)
    }
    
    ctx := context.Background()
    req := feast.OnlineFeaturesRequest{
        Features: []string{"my_project_1/feature1", "my_project_2/feature1", "my_project_4/feature3", "feature2", "feature2"},
        Entities: []feast.Row{
            {"entity1": feast.Int64Val(1), "entity2": feast.StrVal("bob")},
            {"entity1": feast.Int64Val(1), "entity2": feast.StrVal("annie")},
            {"entity1": feast.Int64Val(1), "entity2": feast.StrVal("jane")},
        },
        Project: "my_project_3",
    }

    resp, err := cli.GetOnlineFeatures(ctx, &req)
    if err != nil {
        panic(err)
    }

    // returns a list of rows (map[string]featureValue)
    out := resp.Rows()
}

If all features retrieved are of a single type, Feast provides convenience functions to retrieve your features as a vector of feature values:

arr, err := resp.Int64Arrays(
    []string{"my_project_1/feature1", 
            "my_project_2/feature1", 
            "my_project_4/feature3", 
            "feature2", 
            "feature2"},             // order of features
    []int64{1,2,3,4,5})              // fillNa values
Expand ▾ Collapse ▴

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLengthMismatch indicates that the number of values returned is not the same as the number of values requested
	ErrLengthMismatch = "Length mismatch; number of na values (%d) not equal to number of features requested (%d)."

	// ErrFeatureNotFound indicates that the a requested feature was not found in the response
	ErrFeatureNotFound = "Feature %s not found in response."

	// ErrTypeMismatch indicates that the there was a type mismatch in the returned values
	ErrTypeMismatch = "Requested output of type %s does not match type of feature value returned."
)
View Source
var (
	// ErrInvalidFeatureRef indicates that the user has provided a feature reference
	// with the wrong structure or contents
	ErrInvalidFeatureRef = "Invalid Feature Reference %s provided, " +
		"feature reference must be in the format featureTableName:featureName"
)

Functions

func BoolVal

func BoolVal(val bool) *types.Value

    BoolVal is a bool type feast value

    func BytesVal

    func BytesVal(val []byte) *types.Value

      BytesVal is a bytes type feast value

      func DoubleVal

      func DoubleVal(val float64) *types.Value

        DoubleVal is a float64 type feast value

        func FloatVal

        func FloatVal(val float32) *types.Value

          FloatVal is a float32 type feast value

          func Int32Val

          func Int32Val(val int32) *types.Value

            Int32Val is a int32 type feast value

            func Int64Val

            func Int64Val(val int64) *types.Value

              Int64Val is a int64 type feast value

              func StrVal

              func StrVal(val string) *types.Value

                StrVal is a string type feast value

                Types

                type Client

                type Client interface {
                	GetOnlineFeatures(ctx context.Context, req *OnlineFeaturesRequest) (*OnlineFeaturesResponse, error)
                	GetFeastServingInfo(ctx context.Context, in *serving.GetFeastServingInfoRequest) (*serving.GetFeastServingInfoResponse, error)
                	Close() error
                }

                  Client is a feast serving client.

                  type Credential

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

                    Credential provides OIDC ID tokens used when authenticating with Feast. Implements credentials.PerRPCCredentials

                    func NewGoogleCredential

                    func NewGoogleCredential(audience string) (*Credential, error)

                      Creates a new Google Credential which obtains credentials from Application Default Credentials

                      func NewOAuthCredential

                      func NewOAuthCredential(audience string, clientId string, clientSecret string, endpointURL *url.URL) *Credential

                        Creates a new OAuth credential witch obtains credentials by making a client credentials request to an OAuth endpoint. clientId, clientSecret - Client credentials used to authenticate the client when obtaining credentials. endpointURL - target URL of the OAuth endpoint to make the OAuth request to.

                        func NewStaticCredential

                        func NewStaticCredential(token string) *Credential

                          Create a Static Authentication Provider that provides a static token

                          func (*Credential) GetRequestMetadata

                          func (provider *Credential) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

                            GetRequestMetadata attaches OIDC token as metadata, refreshing tokens if required. This should be called by the GRPC to authenticate each request.

                            func (*Credential) RequireTransportSecurity

                            func (provider *Credential) RequireTransportSecurity() bool

                              Disable requirement of transport security to allow user to configure it explictly instead.

                              type GrpcClient

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

                                GrpcClient is a grpc client for feast serving.

                                func NewGrpcClient

                                func NewGrpcClient(host string, port int) (*GrpcClient, error)

                                  NewGrpcClient constructs a client that can interact via grpc with the feast serving instance at the given host:port.

                                  func NewSecureGrpcClient

                                  func NewSecureGrpcClient(host string, port int, security SecurityConfig) (*GrpcClient, error)

                                    NewSecureGrpcClient constructs a secure client that uses security features (ie authentication). host - hostname of the serving host/instance to connect to. port - post of the host to service host/instancf to connect to. securityConfig - security config configures client security.

                                    func NewSecureGrpcClientWithDialOptions

                                    func NewSecureGrpcClientWithDialOptions(host string, port int, security SecurityConfig, opts ...grpc.DialOption) (*GrpcClient, error)

                                      NewSecureGrpcClientWithDialOptions constructs a secure client that uses security features (ie authentication) along with custom grpc dial options. host - hostname of the serving host/instance to connect to. port - post of the host to service host/instancf to connect to. securityConfig - security config configures client security. opts - grpc.DialOptions which should be used with this connection

                                      func (*GrpcClient) Close

                                      func (fc *GrpcClient) Close() error

                                        Close the grpc connection.

                                        func (*GrpcClient) GetFeastServingInfo

                                          GetFeastServingInfo gets information about the feast serving instance this client is connected to.

                                          func (*GrpcClient) GetOnlineFeatures

                                          func (fc *GrpcClient) GetOnlineFeatures(ctx context.Context, req *OnlineFeaturesRequest) (
                                          	*OnlineFeaturesResponse, error)

                                            GetOnlineFeatures gets the latest values of the request features from the Feast serving instance provided.

                                            type OnlineFeaturesRequest

                                            type OnlineFeaturesRequest struct {
                                            	// Features is the list of features to obtain from Feast. Each feature can be given as
                                            	// the format feature_table:feature, where "feature_table" & "feature" are feature table name
                                            	// and feature name respectively. The only required components is feature name.
                                            	Features []string
                                            
                                            	// Entities is the list of entity rows to retrieve features on. Each row is a map of entity name to entity value.
                                            	Entities []Row
                                            
                                            	// Project optionally specifies the project override. If specified, uses given project for retrieval.
                                            	// Overrides the projects specified in Feature References if also specified.
                                            	Project string
                                            }

                                              OnlineFeaturesRequest wrapper on feast.serving.GetOnlineFeaturesRequestV2.

                                              type OnlineFeaturesResponse

                                              type OnlineFeaturesResponse struct {
                                              	RawResponse *serving.GetOnlineFeaturesResponse
                                              }

                                                OnlineFeaturesResponse is a wrapper around serving.GetOnlineFeaturesResponse.

                                                func (OnlineFeaturesResponse) Float64Arrays

                                                func (r OnlineFeaturesResponse) Float64Arrays(order []string, fillNa []float64) ([][]float64, error)

                                                  Float64Arrays retrieves the result of the request as a list of float64 slices. Any missing values will be filled with the missing values provided.

                                                  func (OnlineFeaturesResponse) Int64Arrays

                                                  func (r OnlineFeaturesResponse) Int64Arrays(order []string, fillNa []int64) ([][]int64, error)

                                                    Int64Arrays retrieves the result of the request as a list of int64 slices. Any missing values will be filled with the missing values provided.

                                                    func (OnlineFeaturesResponse) Rows

                                                    func (r OnlineFeaturesResponse) Rows() []Row

                                                      Rows retrieves the result of the request as a list of Rows.

                                                      func (OnlineFeaturesResponse) Statuses

                                                        Statuses retrieves field level status metadata for each row in Rows(). Each status map returned maps status 1:1 to each returned row from Rows()

                                                        type Row

                                                        type Row map[string]*types.Value

                                                          Row is a map of fields

                                                          type SecurityConfig

                                                          type SecurityConfig struct {
                                                          	// Whether to enable TLS SSL trasnport security if true.
                                                          	EnableTLS bool
                                                          	// Optional: Provides path to TLS certificate used the verify Service identity.
                                                          	TLSCertPath string
                                                          	// Optional: Credential used for authentication.
                                                          	// Disables authentication if unspecified.
                                                          	Credential *Credential
                                                          }

                                                            SecurityConfig wraps security config for GrpcClient

                                                            Directories

                                                            Path Synopsis
                                                            Package mock_serving is a generated GoMock package.
                                                            Package mock_serving is a generated GoMock package.
                                                            protos