Skip to content

Commit 31b0829

Browse files
Ly CaoLy Cao
authored andcommitted
added redis pipeline + passed go tests, haven't tested feature service
1 parent f887a51 commit 31b0829

13 files changed

+726
-352
lines changed

go/feast/basefeatureview.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package feast
2+
3+
import (
4+
"errors"
5+
"github.com/feast-dev/feast/go/protos/feast/core"
6+
"fmt"
7+
)
8+
9+
type BaseFeatureView struct {
10+
name string
11+
features []*core.FeatureSpecV2
12+
projection *FeatureViewProjection
13+
}
14+
15+
func NewBaseFeatureView(name string, features []*core.FeatureSpecV2) *BaseFeatureView {
16+
base := &BaseFeatureView{name: name, features: features}
17+
base.projection = NewFeatureViewProjectionFromDefinition(base)
18+
return base
19+
}
20+
21+
func (fv *BaseFeatureView) withProjection(projection *FeatureViewProjection) (*BaseFeatureView, error) {
22+
if projection.name != fv.name {
23+
return nil, errors.New(fmt.Sprintf("The projection for the %s FeatureView cannot be applied because it differs in name. " +
24+
"The projection is named %s and the name indicates which " +
25+
"FeatureView the projection is for.", fv.name, projection.name))
26+
}
27+
features := make(map[string]bool)
28+
for _, feature := range fv.features {
29+
features[feature.Name] = true
30+
}
31+
for _, feature := range projection.features {
32+
if _, ok := features[feature.Name]; !ok {
33+
return nil, errors.New(fmt.Sprintf("The projection for %s cannot be applied because it contains %s which the " +
34+
"FeatureView doesn't have.", projection.name, feature.Name))
35+
}
36+
}
37+
return &BaseFeatureView{name: fv.name, features: fv.features, projection: projection}, nil
38+
}

go/feast/connector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010
)
1111

1212
func getOnlineStore(config *RepoConfig) (OnlineStore, error) {
13+
fmt.Println(config == nil)
1314
onlineStoreType, ok := getOnlineStoreType(config.OnlineStore)
1415
if !ok {
1516
return nil, errors.New(fmt.Sprintf("could not get online store type from online store config: %+v", config.OnlineStore))
1617
}
17-
fmt.Println(onlineStoreType)
1818
if onlineStoreType == "redis" {
1919
onlineStore, err := NewRedisOnlineStore(config.Project, config.OnlineStore)
2020
return onlineStore, err

go/feast/featureservice.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
package feast
22

33
import (
4-
"errors"
54
"github.com/feast-dev/feast/go/protos/feast/core"
6-
"github.com/feast-dev/feast/go/protos/feast/serving"
7-
"github.com/feast-dev/feast/go/protos/feast/types"
8-
"github.com/golang/protobuf/proto"
9-
durationpb "google.golang.org/protobuf/types/known/durationpb"
105
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
11-
"io/ioutil"
12-
"strings"
13-
// "sort"
14-
"fmt"
156
)
167

178
// Wrapper around core.FeatureView to add projection
@@ -24,14 +15,14 @@ type FeatureService struct {
2415
}
2516

2617
func NewFeatureServiceFromProto(proto *core.FeatureService) *FeatureService {
27-
projections := make([]*FeatureViewProjection, len(proto.GetFeatures()))
28-
for index, projection := range proto.GetFeatures() {
29-
projections[index] = &FeatureViewProjection{proto: projection}
18+
projections := make([]*FeatureViewProjection, len(proto.Spec.Features))
19+
for index, projectionProto := range proto.Spec.Features {
20+
projections[index] = NewFeatureViewProjectionFromProto(projectionProto)
3021
}
31-
return &FeatureService { name: proto.GetSpec().GetName(),
32-
project: proto.GetSpec().GetName(),
33-
createdTimestamp: proto.GetMeta().GetCreatedTimestamp(),
34-
lastUpdatedTimestamp: proto.GetMeta().GetLastUpdatedTimestamp(),
22+
return &FeatureService { name: proto.Spec.Name,
23+
project: proto.Spec.Project,
24+
createdTimestamp: proto.Meta.CreatedTimestamp,
25+
lastUpdatedTimestamp: proto.Meta.LastUpdatedTimestamp,
3526
projections: projections,
3627
}
3728
}

0 commit comments

Comments
 (0)