Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
501f59d
Initial structure for go sqlite online store
kevjumba Mar 23, 2022
0fbd8dc
Somewhat intermediate state
kevjumba Mar 23, 2022
21c8900
Add sqlite online store for go for testing
kevjumba Mar 24, 2022
01d9a1d
Revert
kevjumba Mar 24, 2022
2c4fccd
Revert
kevjumba Mar 24, 2022
34dcd15
Clean up
kevjumba Mar 24, 2022
80f4579
Address review issues
kevjumba Mar 24, 2022
17acc6a
Fix/address issues
kevjumba Mar 25, 2022
64fa88b
lint
kevjumba Mar 25, 2022
0601f0a
Fix
kevjumba Mar 25, 2022
2233ff8
Fix
kevjumba Mar 25, 2022
4de021b
Make integration test work
kevjumba Mar 25, 2022
e3f9970
Fix tests
kevjumba Mar 25, 2022
d9f5333
Fix tests
kevjumba Mar 25, 2022
a631c52
debugging
kevjumba Mar 25, 2022
993ead4
Debug
kevjumba Mar 25, 2022
63fbee6
Debug
kevjumba Mar 25, 2022
c325834
Debug
kevjumba Mar 25, 2022
f2202b8
Debug
kevjumba Mar 25, 2022
c242587
Debug
kevjumba Mar 25, 2022
08e51fb
Debug
kevjumba Mar 25, 2022
b551639
Remove feature_repo files
kevjumba Mar 28, 2022
0755e05
update gitignore
kevjumba Mar 28, 2022
eb8a320
Clean up code
kevjumba Mar 28, 2022
c3472bd
Update go mod
kevjumba Mar 28, 2022
a5b6607
Update makefile
kevjumba Mar 28, 2022
5f68689
Fix gitignore issue
kevjumba Mar 28, 2022
3896f99
Update makefile
kevjumba Mar 28, 2022
111c2d0
Update makefile
kevjumba Mar 28, 2022
c6197ce
Update makefile
kevjumba Mar 28, 2022
a5d4d28
Update makefile
kevjumba Mar 28, 2022
14d5602
Update makefile
kevjumba Mar 28, 2022
02eda7a
Revert worfklow
kevjumba Mar 28, 2022
14876a2
Update build path
kevjumba Mar 29, 2022
3bfcfad
remove
kevjumba Mar 29, 2022
8739e68
rename
kevjumba Mar 29, 2022
bd052a3
Address review
kevjumba Mar 29, 2022
189d3d2
fix tests
kevjumba Mar 29, 2022
acc86bb
Fix
kevjumba Mar 29, 2022
34ab63d
see if this fixes test
kevjumba Mar 29, 2022
fa0abf3
Fix
kevjumba Mar 29, 2022
941aea8
revert
kevjumba Mar 29, 2022
025a7e4
Will add in separate pr to update cryptography
kevjumba Mar 29, 2022
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
Prev Previous commit
Next Next commit
Clean up code
Signed-off-by: Kevin Zhang <[email protected]>
  • Loading branch information
kevjumba committed Mar 29, 2022
commit eb8a3208d807da32e105fdfb74db2833719ff9bd
31 changes: 24 additions & 7 deletions go/cmd/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/feast-dev/feast/go/internal/feast"
"github.com/feast-dev/feast/go/internal/test"
"github.com/feast-dev/feast/go/protos/feast/serving"
"github.com/feast-dev/feast/go/protos/feast/types"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -68,7 +69,8 @@ func getClient(ctx context.Context, basePath string) (serving.ServingServiceClie
func TestGetFeastServingInfo(t *testing.T) {
ctx := context.Background()
// Pregenerated using `feast init`.
client, closer := getClient(ctx, "../../internal/test")
dir := "../../internal/test"
client, closer := getClient(ctx, dir)
defer closer()
response, err := client.GetFeastServingInfo(ctx, &serving.GetFeastServingInfoRequest{})
assert.Nil(t, err)
Expand All @@ -78,7 +80,8 @@ func TestGetFeastServingInfo(t *testing.T) {
func TestGetOnlineFeaturesSqlite(t *testing.T) {
ctx := context.Background()
// Pregenerated using `feast init`.
client, closer := getClient(ctx, "../../internal/test")
dir := "../../internal/test"
client, closer := getClient(ctx, dir)
defer closer()
entities := make(map[string]*types.RepeatedValue)
entities["driver_id"] = &types.RepeatedValue{
Expand All @@ -105,12 +108,26 @@ func TestGetOnlineFeaturesSqlite(t *testing.T) {
expectedFeatureNamesResp := []string{"driver_id", "conv_rate", "acc_rate", "avg_daily_trips"}
assert.Nil(t, err)
assert.NotNil(t, response)
rows, err := test.ReadParquet(filepath.Join(dir, "feature_repo", "data", "driver_stats.parquet"))
assert.Nil(t, err)
entityKeys := map[int64]bool{1001: true, 1003: true, 1005: true}
correctFeatures := test.GetLatestFeatures(rows, entityKeys)
expectedConvRateValues := []*types.Value{}
expectedAccRateValues := []*types.Value{}
expectedAvgDailyTripsValues := []*types.Value{}

for _, key := range []int64{1001, 1003, 1005} {
expectedConvRateValues = append(expectedConvRateValues, &types.Value{Val: &types.Value_FloatVal{FloatVal: correctFeatures[key].Conv_rate}})
expectedAccRateValues = append(expectedAccRateValues, &types.Value{Val: &types.Value_FloatVal{FloatVal: correctFeatures[key].Acc_rate}})
expectedAvgDailyTripsValues = append(expectedAvgDailyTripsValues, &types.Value{Val: &types.Value_Int64Val{Int64Val: int64(correctFeatures[key].Avg_daily_trips)}})
}
// Columnar so get in column format row by row should have column names of all features
assert.Equal(t, len(response.Results), 4)

// Columnar so first column should have column names of all features
assert.True(t, reflect.DeepEqual(response.Results[0].Values, expectedEntityValuesResp))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add here check for feature values as well, since we read them from the source file

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOne.

assert.True(t, reflect.DeepEqual(response.Results[1].Values, expectedConvRateValues))
assert.True(t, reflect.DeepEqual(response.Results[2].Values, expectedAccRateValues))
assert.True(t, reflect.DeepEqual(response.Results[3].Values, expectedAvgDailyTripsValues))

assert.True(t, reflect.DeepEqual(response.Metadata.FeatureNames.Val, expectedFeatureNamesResp))
assert.Equal(t, len(response.Results), 4)
for _, row := range response.Results {
assert.Greater(t, len(row.Values), 0)
}
}
7 changes: 2 additions & 5 deletions go/internal/feast/onlinestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ func getOnlineStoreType(onlineStoreConfig map[string]interface{}) (string, bool)
func NewOnlineStore(config *RepoConfig) (OnlineStore, error) {
onlineStoreType, ok := getOnlineStoreType(config.OnlineStore)
if !ok {
return nil, fmt.Errorf("could not get online store type from online store config: %+v", config.OnlineStore)
onlineStore, err := NewSqliteOnlineStore(config.Project, config, config.OnlineStore)
return onlineStore, err
Comment on lines 54 to 56
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong ? DOn't we need ok && onlineStoreType == "sqlite" before we do this code path?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the python implementation, no type for online store config automatically assumes sqlite as the onlinestore => I believe I tried adding type = sqlite there were some small config collisions so I decided it makes sense to adhere to the python online store configuraiton.

}
if onlineStoreType == "redis" {
onlineStore, err := NewRedisOnlineStore(config.Project, config.OnlineStore)
return onlineStore, err
}
if onlineStoreType == "sqlite" {
onlineStore, err := NewSqliteOnlineStore(config.Project, config, config.OnlineStore)
return onlineStore, err
} else {
return nil, fmt.Errorf("%s online store type is currently not supported; only redis and sqlite are supported", onlineStoreType)
}
Expand Down
5 changes: 0 additions & 5 deletions go/internal/feast/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package feast
import (
"errors"
"fmt"
"log"
"net/url"
"sync"
"time"
Expand Down Expand Up @@ -38,8 +37,6 @@ type Registry struct {
}

func NewRegistry(registryConfig *RegistryConfig, repoPath string) (*Registry, error) {
log.Println("registry")
log.Println(registryConfig)
registryStoreType := registryConfig.RegistryStoreType
registryPath := registryConfig.Path
r := &Registry{
Expand Down Expand Up @@ -91,11 +88,9 @@ func (r *Registry) refresh() error {
func (r *Registry) getRegistryProto() (*core.Registry, error) {
expired := r.cachedRegistry == nil || (r.cachedRegistryProtoTtl > 0 && time.Now().After(r.cachedRegistryProtoLastUpdated.Add(r.cachedRegistryProtoTtl)))
if !expired {
log.Println("Expired?")
return r.cachedRegistry, nil
}
registryProto, err := r.registryStore.GetRegistryProto()
log.Println(registryProto)
if err != nil {
return registryProto, err
}
Expand Down
3 changes: 3 additions & 0 deletions go/internal/feast/sqliteonlinestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ func initializeConnection(db_path string) (*sql.DB, error) {
}

func hashSerializedEntityKey(serializedEntityKey *[]byte) string {
if serializedEntityKey == nil {
return ""
}
h := sha1.New()
h.Write(*serializedEntityKey)
Comment thread
kevjumba marked this conversation as resolved.
Outdated
sha1_hash := hex.EncodeToString(h.Sum(nil))
Expand Down
22 changes: 11 additions & 11 deletions go/internal/feast/sqliteonlinestore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package feast

import (
"context"
"path/filepath"
"reflect"
"testing"

"github.com/feast-dev/feast/go/internal/test"
"github.com/feast-dev/feast/go/protos/feast/types"
"github.com/stretchr/testify/assert"
)
Expand All @@ -17,7 +19,6 @@ func TestSqliteSetup(t *testing.T) {
assert.Equal(t, "data/registry.db", config.GetRegistryConfig().Path)
assert.Equal(t, "local", config.Provider)
assert.Equal(t, map[string]interface{}{
"type": "sqlite",
"path": "data/online_store.db",
}, config.OnlineStore)
assert.Empty(t, config.OfflineStore)
Expand Down Expand Up @@ -57,16 +58,15 @@ func TestSqliteOnlineRead(t *testing.T) {
returnedFeatureNames = append(returnedFeatureNames, featureVector[idx].reference.FeatureName)
}
}
expectedFeatureValues := []*types.Value{
{Val: &types.Value_FloatVal{FloatVal: 0.78135854}},
{Val: &types.Value_FloatVal{FloatVal: 0.38527268}},
{Val: &types.Value_Int64Val{Int64Val: 755}},
{Val: &types.Value_FloatVal{FloatVal: 0.49661186}},
{Val: &types.Value_FloatVal{FloatVal: 0.9440974}},
{Val: &types.Value_Int64Val{Int64Val: 169}},
{Val: &types.Value_FloatVal{FloatVal: 0.80762655}},
{Val: &types.Value_FloatVal{FloatVal: 0.71510273}},
{Val: &types.Value_Int64Val{Int64Val: 545}},
rows, err := test.ReadParquet(filepath.Join(dir, "data", "driver_stats.parquet"))
assert.Nil(t, err)
entities := map[int64]bool{1005: true, 1001: true, 1003: true}
correctFeatures := test.GetLatestFeatures(rows, entities)
expectedFeatureValues := []*types.Value{}
for _, key := range []int64{1005, 1001, 1003} {
expectedFeatureValues = append(expectedFeatureValues, &types.Value{Val: &types.Value_FloatVal{FloatVal: correctFeatures[key].Conv_rate}})
expectedFeatureValues = append(expectedFeatureValues, &types.Value{Val: &types.Value_FloatVal{FloatVal: correctFeatures[key].Acc_rate}})
expectedFeatureValues = append(expectedFeatureValues, &types.Value{Val: &types.Value_Int64Val{Int64Val: int64(correctFeatures[key].Avg_daily_trips)}})
}
expectedFeatureNames := []string{"conv_rate", "acc_rate", "avg_daily_trips", "conv_rate", "acc_rate", "avg_daily_trips", "conv_rate", "acc_rate", "avg_daily_trips"}
assert.True(t, reflect.DeepEqual(expectedFeatureValues, returnedFeatureValues))
Expand Down