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

chore: Deprecate value type #2611

Merged
merged 17 commits into from
May 4, 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
4 changes: 2 additions & 2 deletions examples/java-demo/feature_repo/driver_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from google.protobuf.duration_pb2 import Duration
from feast.field import Field

from feast import Entity, Feature, BatchFeatureView, FileSource, ValueType
from feast import Entity, Feature, BatchFeatureView, FileSource

driver_hourly_stats = FileSource(
path="data/driver_stats_with_string.parquet",
timestamp_field="event_timestamp",
created_timestamp_column="created",
)
driver = Entity(name="driver_id", value_type=ValueType.INT64, description="driver id",)
driver = Entity(name="driver_id", description="driver id",)
driver_hourly_stats_view = BatchFeatureView(
name="driver_hourly_stats",
entities=["driver_id"],
Expand Down
22 changes: 4 additions & 18 deletions go/embedded/online_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ func (s *OnlineFeatureService) GetEntityTypesMap(featureRefs []string) (map[stri
viewNames[viewName] = nil
}

entities, _ := s.fs.ListEntities(true)
entitiesByName := make(map[string]*model.Entity)
for _, entity := range entities {
entitiesByName[entity.Name] = entity
}

joinKeyTypes := make(map[string]int32)

for viewName := range viewNames {
Expand All @@ -86,9 +80,8 @@ func (s *OnlineFeatureService) GetEntityTypesMap(featureRefs []string) (map[stri
// skip on demand feature views
continue
}
for _, entityName := range view.Entities {
entity := entitiesByName[entityName]
joinKeyTypes[entity.JoinKey] = int32(entity.ValueType.Number())
for _, entityColumn := range view.EntityColumns {
joinKeyTypes[entityColumn.Name] = int32(entityColumn.Dtype.Number())
}
}

Expand All @@ -103,21 +96,14 @@ func (s *OnlineFeatureService) GetEntityTypesMapByFeatureService(featureServiceN

joinKeyTypes := make(map[string]int32)

entities, _ := s.fs.ListEntities(true)
entitiesByName := make(map[string]*model.Entity)
for _, entity := range entities {
entitiesByName[entity.Name] = entity
}

for _, projection := range featureService.Projections {
view, err := s.fs.GetFeatureView(projection.Name, true)
if err != nil {
// skip on demand feature views
continue
}
for _, entityName := range view.Entities {
entity := entitiesByName[entityName]
joinKeyTypes[entity.JoinKey] = int32(entity.ValueType.Number())
for _, entityColumn := range view.EntityColumns {
joinKeyTypes[entityColumn.Name] = int32(entityColumn.Dtype.Number())
}
}

Expand Down
4 changes: 2 additions & 2 deletions go/internal/feast/featurestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (fs *FeatureStore) GetOnlineFeatures(
if entitylessCase {
dummyEntityColumn := &prototypes.RepeatedValue{Val: make([]*prototypes.Value, numRows)}
for index := 0; index < numRows; index++ {
dummyEntityColumn.Val[index] = &model.DUMMY_ENTITY
dummyEntityColumn.Val[index] = &model.DUMMY_ENTITY_VALUE
}
joinKeyToEntityValues[model.DUMMY_ENTITY_ID] = dummyEntityColumn
}
Expand Down Expand Up @@ -272,7 +272,7 @@ func (fs *FeatureStore) GetFeatureView(featureViewName string, hideDummyEntity b
return nil, err
}
if fv.HasEntity(model.DUMMY_ENTITY_NAME) && hideDummyEntity {
fv.Entities = []string{}
fv.EntityNames = []string{}
}
return fv, nil
}
Expand Down
8 changes: 4 additions & 4 deletions go/internal/feast/model/basefeatureview.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (

type BaseFeatureView struct {
Name string
Features []*Feature
Features []*Field
Projection *FeatureViewProjection
}

func NewBaseFeatureView(name string, featureProtos []*core.FeatureSpecV2) *BaseFeatureView {
base := &BaseFeatureView{Name: name}
features := make([]*Feature, len(featureProtos))
features := make([]*Field, len(featureProtos))
for index, featureSpecV2 := range featureProtos {
features[index] = NewFeatureFromProto(featureSpecV2)
features[index] = NewFieldFromProto(featureSpecV2)
}
base.Features = features
base.Projection = NewFeatureViewProjectionFromDefinition(base)
Expand All @@ -43,7 +43,7 @@ func (fv *BaseFeatureView) WithProjection(projection *FeatureViewProjection) (*B
}

func (fv *BaseFeatureView) ProjectWithFeatures(featureNames []string) *FeatureViewProjection {
features := make([]*Feature, 0)
features := make([]*Field, 0)
for _, feature := range fv.Features {
for _, allowedFeatureName := range featureNames {
if feature.Name == allowedFeatureName {
Expand Down
12 changes: 5 additions & 7 deletions go/internal/feast/model/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ package model

import (
"github.com/feast-dev/feast/go/protos/feast/core"
"github.com/feast-dev/feast/go/protos/feast/types"
)

type Entity struct {
Name string
ValueType types.ValueType_Enum
JoinKey string
Name string
JoinKey string
}

func NewEntityFromProto(proto *core.Entity) *Entity {
return &Entity{Name: proto.Spec.Name,
ValueType: proto.Spec.ValueType,
JoinKey: proto.Spec.JoinKey,
return &Entity{
Name: proto.Spec.Name,
JoinKey: proto.Spec.JoinKey,
}
}
32 changes: 19 additions & 13 deletions go/internal/feast/model/featureview.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,44 @@ const (
DUMMY_ENTITY_VAL = ""
)

var DUMMY_ENTITY types.Value = types.Value{Val: &types.Value_StringVal{StringVal: DUMMY_ENTITY_VAL}}
var DUMMY_ENTITY_VALUE types.Value = types.Value{Val: &types.Value_StringVal{StringVal: DUMMY_ENTITY_VAL}}

type FeatureView struct {
Base *BaseFeatureView
Ttl *durationpb.Duration
Entities []string
Base *BaseFeatureView
Ttl *durationpb.Duration
EntityNames []string
EntityColumns []*Field
}

func NewFeatureViewFromProto(proto *core.FeatureView) *FeatureView {
featureView := &FeatureView{Base: NewBaseFeatureView(proto.Spec.Name, proto.Spec.Features),
Ttl: &(*proto.Spec.Ttl),
}
if len(proto.Spec.Entities) == 0 {
featureView.Entities = []string{DUMMY_ENTITY_NAME}
featureView.EntityNames = []string{DUMMY_ENTITY_NAME}
} else {
featureView.Entities = proto.Spec.Entities
featureView.EntityNames = proto.Spec.Entities
}
entityColumns := make([]*Field, len(proto.Spec.EntityColumns))
for i, entityColumn := range proto.Spec.EntityColumns {
entityColumns[i] = NewFieldFromProto(entityColumn)
}
featureView.EntityColumns = entityColumns
return featureView
}

func (fs *FeatureView) NewFeatureViewFromBase(base *BaseFeatureView) *FeatureView {
ttl := durationpb.Duration{Seconds: fs.Ttl.Seconds, Nanos: fs.Ttl.Nanos}
func (fv *FeatureView) NewFeatureViewFromBase(base *BaseFeatureView) *FeatureView {
ttl := durationpb.Duration{Seconds: fv.Ttl.Seconds, Nanos: fv.Ttl.Nanos}
featureView := &FeatureView{Base: base,
Ttl: &ttl,
Entities: fs.Entities,
Ttl: &ttl,
EntityNames: fv.EntityNames,
}
return featureView
}

func (fs *FeatureView) HasEntity(lookup string) bool {
for _, entityName := range fs.Entities {
if entityName == lookup {
func (fv *FeatureView) HasEntity(name string) bool {
for _, entityName := range fv.EntityNames {
if entityName == name {
return true
}
}
Expand Down
6 changes: 3 additions & 3 deletions go/internal/feast/model/featureviewprojection.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
type FeatureViewProjection struct {
Name string
NameAlias string
Features []*Feature
Features []*Field
JoinKeyMap map[string]string
}

Expand All @@ -24,9 +24,9 @@ func NewFeatureViewProjectionFromProto(proto *core.FeatureViewProjection) *Featu
JoinKeyMap: proto.JoinKeyMap,
}

features := make([]*Feature, len(proto.FeatureColumns))
features := make([]*Field, len(proto.FeatureColumns))
for index, featureSpecV2 := range proto.FeatureColumns {
features[index] = NewFeatureFromProto(featureSpecV2)
features[index] = NewFieldFromProto(featureSpecV2)
}
featureProjection.Features = features
return featureProjection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"github.com/feast-dev/feast/go/protos/feast/types"
)

type Feature struct {
type Field struct {
Name string
Dtype types.ValueType_Enum
}

func NewFeatureFromProto(proto *core.FeatureSpecV2) *Feature {
return &Feature{Name: proto.Name,
func NewFieldFromProto(proto *core.FeatureSpecV2) *Field {
return &Field{
Name: proto.Name,
Dtype: proto.ValueType,
}
}
4 changes: 2 additions & 2 deletions go/internal/feast/onlineserving/serving.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func GetEntityMaps(requestedFeatureViews []*FeatureViewAndRefs, entities []*mode
joinKeyToAliasMap = map[string]string{}
}

for _, entityName := range featureView.Entities {
for _, entityName := range featureView.EntityNames {
joinKey := entitiesByName[entityName].JoinKey
entityNameToJoinKeyMap[entityName] = joinKey

Expand Down Expand Up @@ -518,7 +518,7 @@ func GroupFeatureRefs(requestedFeatureViews []*FeatureViewAndRefs,
joinKeys := make([]string, 0)
fv := featuresAndView.View
featureNames := featuresAndView.FeatureRefs
for _, entityName := range fv.Entities {
for _, entityName := range fv.EntityNames {
joinKeys = append(joinKeys, entityNameToJoinKeyMap[entityName])
}

Expand Down
22 changes: 11 additions & 11 deletions go/internal/feast/onlineserving/serving_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ func TestGroupingFeatureRefs(t *testing.T) {
NameAlias: "aliasViewA",
},
},
Entities: []string{"driver", "customer"},
EntityNames: []string{"driver", "customer"},
}
viewB := &model.FeatureView{
Base: &model.BaseFeatureView{Name: "viewB"},
Entities: []string{"driver", "customer"},
Base: &model.BaseFeatureView{Name: "viewB"},
EntityNames: []string{"driver", "customer"},
}
viewC := &model.FeatureView{
Base: &model.BaseFeatureView{Name: "viewC"},
Entities: []string{"driver"},
Base: &model.BaseFeatureView{Name: "viewC"},
EntityNames: []string{"driver"},
}
viewD := &model.FeatureView{
Base: &model.BaseFeatureView{Name: "viewD"},
Entities: []string{"customer"},
Base: &model.BaseFeatureView{Name: "viewD"},
EntityNames: []string{"customer"},
}
refGroups, _ := GroupFeatureRefs(
[]*FeatureViewAndRefs{
Expand Down Expand Up @@ -105,11 +105,11 @@ func TestGroupingFeatureRefsWithJoinKeyAliases(t *testing.T) {
JoinKeyMap: map[string]string{"location_id": "destination_id"},
},
},
Entities: []string{"location"},
EntityNames: []string{"location"},
}
viewB := &model.FeatureView{
Base: &model.BaseFeatureView{Name: "viewB"},
Entities: []string{"location"},
Base: &model.BaseFeatureView{Name: "viewB"},
EntityNames: []string{"location"},
}

refGroups, _ := GroupFeatureRefs(
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestGroupingFeatureRefsWithMissingKey(t *testing.T) {
JoinKeyMap: map[string]string{"location_id": "destination_id"},
},
},
Entities: []string{"location"},
EntityNames: []string{"location"},
}

_, err := GroupFeatureRefs(
Expand Down
9 changes: 4 additions & 5 deletions go/internal/feast/server/logging/featureserviceschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,20 @@ func generateSchema(featureService *model.FeatureService, entityMap map[string]*
features = append(features, fullFeatureName)
allFeatureTypes[fullFeatureName] = f.Dtype
}
for _, entityName := range fv.Entities {
entity := entityMap[entityName]
for _, entityColumn := range fv.EntityColumns {
var joinKey string
if joinKeyAlias, ok := featureProjection.JoinKeyMap[entity.JoinKey]; ok {
if joinKeyAlias, ok := featureProjection.JoinKeyMap[entityColumn.Name]; ok {
joinKey = joinKeyAlias
} else {
joinKey = entity.JoinKey
joinKey = entityColumn.Name
}

if _, ok := joinKeysSet[joinKey]; !ok {
joinKeys = append(joinKeys, joinKey)
}

joinKeysSet[joinKey] = nil
entityJoinKeyToType[joinKey] = entity.ValueType
entityJoinKeyToType[joinKey] = entityColumn.Dtype
}
} else if odFv, ok := odFvMap[featureViewName]; ok {
for _, f := range featureProjection.Features {
Expand Down
Loading