README
Feast Golang SDK
The Feast golang SDK currently only supports retrieval from online stores.
Quickstart
import (
"context"
feast "github.com/gojek/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:1", "my_project_2/feature1:1", "my_project_4/feature3", "feature2:2", "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:1",
"my_project_2/feature1:1",
"my_project_4/feature3",
"feature2:2",
"feature2"}, // order of features
[]int64{1,2,3,4,5}) // fillNa values
Documentation
Index ¶
- Variables
- func BoolVal(val bool) *types.Value
- func BytesVal(val []byte) *types.Value
- func DoubleVal(val float64) *types.Value
- func FloatVal(val float32) *types.Value
- func Int32Val(val int32) *types.Value
- func Int64Val(val int64) *types.Value
- func StrVal(val string) *types.Value
- type Client
- type GrpcClient
- func (fc *GrpcClient) Close() error
- func (fc *GrpcClient) GetFeastServingInfo(ctx context.Context, in *serving.GetFeastServingInfoRequest) (*serving.GetFeastServingInfoResponse, error)
- func (fc *GrpcClient) GetOnlineFeatures(ctx context.Context, req *OnlineFeaturesRequest) (*OnlineFeaturesResponse, error)
- type OnlineFeaturesRequest
- type OnlineFeaturesResponse
- type Row
Constants ¶
Variables ¶
var ( ErrLengthMismatch = "Length mismatch; number of na values (%d) not equal to number of features requested (%d)." ErrFeatureNotFound = "Feature %s not found in response." ErrTypeMismatch = "Requested output of type %s does not match type of feature value returned." )
var (
ErrInvalidFeatureName = "invalid feature ids %s provided, feature names must be in the format <project>/<feature>:<version>"
)
Functions ¶
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 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 (*GrpcClient) GetFeastServingInfo ¶
func (fc *GrpcClient) GetFeastServingInfo(ctx context.Context, in *serving.GetFeastServingInfoRequest) ( *serving.GetFeastServingInfoResponse, error)
GetInfo 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 // <feature-name> // <feature-name>:<feature-version> // <project-name>/<feature-name> // <project-name>/<feature-name>:<feature-version> // The only required components are the feature name and project. 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 is the default project to use when looking up features. This is only used when a project is not found // within the feature id. Project string }
OnlineFeaturesRequest wrapper on feast.serving.GetOnlineFeaturesRequest.
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.
Directories
Path | Synopsis |
---|---|
protos
|
|