Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix registry proto #2435

Merged
merged 7 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 37 additions & 19 deletions go/internal/feast/featurestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"context"
"errors"
"fmt"
"sort"
"strings"

"github.com/feast-dev/feast/go/protos/feast/serving"
"github.com/feast-dev/feast/go/protos/feast/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
"sort"
"strings"
)

type FeatureStore struct {
Expand Down Expand Up @@ -92,7 +93,7 @@ func (fs *FeatureStore) GetOnlineFeatures(ctx context.Context, request *serving.
return nil, err
}

fvs, requestedFeatureViews, requestedRequestFeatureViews, requestedOnDemandFeatureViews, err := fs.getFeatureViewsToUse(features, true, false)
fvs, requestedFeatureViews, requestedRequestFeatureViews, requestedOnDemandFeatureViews, err := fs.getFeatureViewsToUse(features, false)

if len(requestedRequestFeatureViews)+len(requestedOnDemandFeatureViews) > 0 {
return nil, status.Errorf(codes.InvalidArgument, "on demand feature views are currently not supported")
Expand Down Expand Up @@ -253,22 +254,31 @@ func (fs *FeatureStore) getFeatureRefs(features *Features) ([]string, error) {
retrieving all feature views. Similar argument to FeatureService applies.

*/
func (fs *FeatureStore) getFeatureViewsToUse(features *Features, allowCache, hideDummyEntity bool) (map[string]*FeatureView, map[*FeatureView][]string, []*RequestFeatureView, []*OnDemandFeatureView, error) {
func (fs *FeatureStore) getFeatureViewsToUse(features *Features, hideDummyEntity bool) (map[string]*FeatureView, map[*FeatureView][]string, []*RequestFeatureView, []*OnDemandFeatureView, error) {
fvs := make(map[string]*FeatureView)
requestFvs := make(map[string]*RequestFeatureView)
odFvs := make(map[string]*OnDemandFeatureView)

featureViews := fs.listFeatureViews(allowCache, hideDummyEntity)
featureViews, err := fs.listFeatureViews(hideDummyEntity)
if err != nil {
return nil, nil, nil, nil, err
}
for _, featureView := range featureViews {
fvs[featureView.base.name] = featureView
}

requestFeatureViews := fs.registry.listRequestFeatureViews(fs.config.Project)
requestFeatureViews, err := fs.registry.listRequestFeatureViews(fs.config.Project)
if err != nil {
return nil, nil, nil, nil, err
}
for _, requestFeatureView := range requestFeatureViews {
requestFvs[requestFeatureView.base.name] = requestFeatureView
}

onDemandFeatureViews := fs.registry.listOnDemandFeatureViews(fs.config.Project)
onDemandFeatureViews, err := fs.registry.listOnDemandFeatureViews(fs.config.Project)
if err != nil {
return nil, nil, nil, nil, err
}
for _, onDemandFeatureView := range onDemandFeatureViews {
odFvs[onDemandFeatureView.base.name] = onDemandFeatureView
}
Expand Down Expand Up @@ -347,7 +357,10 @@ func (fs *FeatureStore) getEntityMaps(requestedFeatureViews map[*FeatureView][]s
var joinKeyMap map[string]string
var featureView *FeatureView

entities := fs.listEntities(true, false)
entities, err := fs.listEntities(false)
if err != nil {
return nil, err
}

for _, entity := range entities {
entityNameToJoinKeyMap[entity.name] = entity.joinKey
Expand Down Expand Up @@ -636,26 +649,31 @@ func (fs *FeatureStore) dropUnneededColumns(onlineFeaturesResponse *serving.GetO
}
}

func (fs *FeatureStore) listFeatureViews(allowCache, hideDummyEntity bool) []*FeatureView {
featureViews := fs.registry.listFeatureViews(fs.config.Project)
for _, featureView := range featureViews {
if _, ok := featureView.entities[DUMMY_ENTITY_NAME]; ok && hideDummyEntity {
featureView.entities = make(map[string]struct{})
}
func (fs *FeatureStore) listFeatureViews(hideDummyEntity bool) ([]*FeatureView, error) {
kevjumba marked this conversation as resolved.
Show resolved Hide resolved
featureViews, err := fs.registry.listFeatureViews(fs.config.Project)
if err != nil {
return featureViews, err
}
return featureViews
return featureViews, nil
}

func (fs *FeatureStore) listRequestFeatureViews() ([]*RequestFeatureView, error) {
return fs.registry.listRequestFeatureViews(fs.config.Project)
}

func (fs *FeatureStore) listEntities(allowCache, hideDummyEntity bool) []*Entity {
func (fs *FeatureStore) listEntities(hideDummyEntity bool) ([]*Entity, error) {

allEntities := fs.registry.listEntities(fs.config.Project)
allEntities, err := fs.registry.listEntities(fs.config.Project)
if err != nil {
return allEntities, err
}
entities := make([]*Entity, 0)
for _, entity := range allEntities {
if entity.name != DUMMY_ENTITY_NAME || !hideDummyEntity {
entities = append(entities, entity)
}
}
return entities
return entities, nil
}

func (fs *FeatureStore) getFvEntityValues(fv *FeatureView,
Expand Down Expand Up @@ -820,7 +838,7 @@ func (fs *FeatureStore) groupFeatureRefs(requestedFeatureViews map[*FeatureView]
return fvFeatures, nil
}

func (fs *FeatureStore) getFeatureView(project, featureViewName string, allowCache, hideDummyEntity bool) (*FeatureView, error) {
func (fs *FeatureStore) getFeatureView(project, featureViewName string, hideDummyEntity bool) (*FeatureView, error) {
fv, err := fs.registry.getFeatureView(fs.config.Project, featureViewName)
if err != nil {
return nil, err
Expand Down
Loading