Skip to content

Commit f887a51

Browse files
author
Ly Cao
committed
migrating python's sdk get_online_features and its helper functions
1 parent c1ab5e7 commit f887a51

11 files changed

Lines changed: 945 additions & 172 deletions

go/feast/connector.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,18 @@ package feast
33
import (
44
"errors"
55
"fmt"
6-
// "io/ioutil"
7-
// "log"
86
"os"
97
"os/exec"
108
"github.com/hashicorp/go-plugin"
119
"github.com/hashicorp/go-hclog"
12-
"path/filepath"
13-
"runtime"
14-
// "time"
15-
// "github.com/feast-dev/feast/go/protos/feast/third_party/grpc/connector"
1610
)
1711

1812
func getOnlineStore(config *RepoConfig) (OnlineStore, error) {
1913
onlineStoreType, ok := getOnlineStoreType(config.OnlineStore)
2014
if !ok {
2115
return nil, errors.New(fmt.Sprintf("could not get online store type from online store config: %+v", config.OnlineStore))
2216
}
17+
fmt.Println(onlineStoreType)
2318
if onlineStoreType == "redis" {
2419
onlineStore, err := NewRedisOnlineStore(config.Project, config.OnlineStore)
2520
return onlineStore, err
@@ -35,14 +30,7 @@ func connectorClient(KV_PLUGIN string) (OnlineStore, error) {
3530
// log.SetOutput(ioutil.Discard)
3631

3732
// We're a host. Start by launching the plugin process.
38-
_, filename, _, ok := runtime.Caller(0)
39-
if !ok {
40-
panic("couldn't find file path of the connector file")
41-
}
4233
cmd := exec.Command("sh", "-c", KV_PLUGIN )
43-
cmd.Env = os.Environ()
44-
connectorPythonPath := filepath.Join(filename, "..", "..", "test_repo/connector_python")
45-
cmd.Env = append(cmd.Env, fmt.Sprintf("PYTHONPATH=%s:$PYTHONPATH", connectorPythonPath))
4634

4735
logger := hclog.New(&hclog.LoggerOptions{
4836
Name: "plugin",
@@ -84,5 +72,4 @@ func connectorClient(KV_PLUGIN string) (OnlineStore, error) {
8472
}
8573
return onlineStore, nil
8674
}
87-
// return raw, nil
8875
}

go/feast/featureservice.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package feast
2+
3+
import (
4+
"errors"
5+
"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"
10+
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
11+
"io/ioutil"
12+
"strings"
13+
// "sort"
14+
"fmt"
15+
)
16+
17+
// Wrapper around core.FeatureView to add projection
18+
type FeatureService struct {
19+
name string
20+
project string
21+
createdTimestamp *timestamppb.Timestamp
22+
lastUpdatedTimestamp *timestamppb.Timestamp
23+
projections []*FeatureViewProjection
24+
}
25+
26+
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}
30+
}
31+
return &FeatureService { name: proto.GetSpec().GetName(),
32+
project: proto.GetSpec().GetName(),
33+
createdTimestamp: proto.GetMeta().GetCreatedTimestamp(),
34+
lastUpdatedTimestamp: proto.GetMeta().GetLastUpdatedTimestamp(),
35+
projections: projections,
36+
}
37+
}

0 commit comments

Comments
 (0)