-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathfeaturestore_test.go
More file actions
72 lines (64 loc) · 2.14 KB
/
Copy pathfeaturestore_test.go
File metadata and controls
72 lines (64 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package feast
import (
"context"
"path/filepath"
"runtime"
"testing"
"github.com/stretchr/testify/assert"
"github.com/feast-dev/feast/go/internal/feast/onlinestore"
"github.com/feast-dev/feast/go/internal/feast/registry"
"github.com/feast-dev/feast/go/protos/feast/types"
)
// Return absolute path to the test_repo registry regardless of the working directory
func getRegistryPath() map[string]interface{} {
// Get the file path of this source file, regardless of the working directory
_, filename, _, ok := runtime.Caller(0)
if !ok {
panic("couldn't find file path of the test file")
}
registry := map[string]interface{}{
"path": filepath.Join(filename, "..", "..", "..", "feature_repo/data/registry.db"),
}
return registry
}
func TestNewFeatureStore(t *testing.T) {
t.Skip("@todo(achals): feature_repo isn't checked in yet")
config := registry.RepoConfig{
Project: "feature_repo",
Registry: getRegistryPath(),
Provider: "local",
OnlineStore: map[string]interface{}{
"type": "redis",
},
}
fs, err := NewFeatureStore(&config, nil)
assert.Nil(t, err)
assert.IsType(t, &onlinestore.RedisOnlineStore{}, fs.onlineStore)
}
func TestGetOnlineFeaturesRedis(t *testing.T) {
t.Skip("@todo(achals): feature_repo isn't checked in yet")
config := registry.RepoConfig{
Project: "feature_repo",
Registry: getRegistryPath(),
Provider: "local",
OnlineStore: map[string]interface{}{
"type": "redis",
"connection_string": "localhost:6379",
},
}
featureNames := []string{"driver_hourly_stats:conv_rate",
"driver_hourly_stats:acc_rate",
"driver_hourly_stats:avg_daily_trips",
}
entities := map[string]*types.RepeatedValue{"driver_id": {Val: []*types.Value{{Val: &types.Value_Int64Val{Int64Val: 1001}},
{Val: &types.Value_Int64Val{Int64Val: 1002}},
{Val: &types.Value_Int64Val{Int64Val: 1003}}}},
}
fs, err := NewFeatureStore(&config, nil)
assert.Nil(t, err)
ctx := context.Background()
response, err := fs.GetOnlineFeatures(
ctx, featureNames, nil, entities, map[string]*types.RepeatedValue{}, true)
assert.Nil(t, err)
assert.Len(t, response, 4) // 3 Features + 1 entity = 4 columns (feature vectors) in response
}