Skip to content

Commit a5e68a8

Browse files
committed
use nil instead of dummy implementation for transformation callback
Signed-off-by: pyalex <[email protected]>
1 parent 92fe8fa commit a5e68a8

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

go/cmd/server/main.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ const (
1717
feastServerVersion = "0.18.0"
1818
)
1919

20-
func dummyTransformCallback(ODFVName string, inputArrPtr, inputSchemaPtr, outArrPtr, outSchemaPtr uintptr, fullFeatureNames bool) int {
21-
return 0
22-
}
23-
2420
// TODO: Add a proper logging library such as https://github.com/Sirupsen/logrus
2521
func main() {
2622
repoPath := os.Getenv(flagFeastRepoPath)
@@ -45,7 +41,7 @@ func main() {
4541
}
4642

4743
log.Println("Initializing feature store...")
48-
fs, err := feast.NewFeatureStore(repoConfig, dummyTransformCallback)
44+
fs, err := feast.NewFeatureStore(repoConfig, nil)
4945
if err != nil {
5046
log.Fatalln(err)
5147
}

go/cmd/server/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func getClient(ctx context.Context, basePath string) (serving.ServingServiceClie
4141
if err != nil {
4242
panic(err)
4343
}
44-
fs, err := feast.NewFeatureStore(config, dummyTransformCallback)
44+
fs, err := feast.NewFeatureStore(config, nil)
4545
if err != nil {
4646
panic(err)
4747
}

go/internal/feast/featurestore.go

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import (
1919
)
2020

2121
type FeatureStore struct {
22-
config *RepoConfig
23-
registry *Registry
24-
onlineStore OnlineStore
25-
tranformationCallback TransformationCallback
22+
config *RepoConfig
23+
registry *Registry
24+
onlineStore OnlineStore
25+
transformationCallback TransformationCallback
2626
}
2727

2828
// A Features struct specifies a list of features to be retrieved from the online store. These features
@@ -86,10 +86,10 @@ func NewFeatureStore(config *RepoConfig, callback TransformationCallback) (*Feat
8686
registry.initializeRegistry()
8787

8888
return &FeatureStore{
89-
config: config,
90-
registry: registry,
91-
onlineStore: onlineStore,
92-
tranformationCallback: callback,
89+
config: config,
90+
registry: registry,
91+
onlineStore: onlineStore,
92+
transformationCallback: callback,
9393
}, nil
9494
}
9595

@@ -189,22 +189,23 @@ func (fs *FeatureStore) GetOnlineFeatures(
189189
result = append(result, vectors...)
190190
}
191191

192-
onDemandFeatures, err := augmentResponseWithOnDemandTransforms(
193-
requestedOnDemandFeatureViews,
194-
requestData,
195-
joinKeyToEntityValues,
196-
result,
197-
fs.tranformationCallback,
198-
arrowMemory,
199-
numRows,
200-
fullFeatureNames,
201-
)
202-
if err != nil {
203-
return nil, err
192+
if fs.transformationCallback != nil {
193+
onDemandFeatures, err := augmentResponseWithOnDemandTransforms(
194+
requestedOnDemandFeatureViews,
195+
requestData,
196+
joinKeyToEntityValues,
197+
result,
198+
fs.transformationCallback,
199+
arrowMemory,
200+
numRows,
201+
fullFeatureNames,
202+
)
203+
if err != nil {
204+
return nil, err
205+
}
206+
result = append(result, onDemandFeatures...)
204207
}
205208

206-
result = append(result, onDemandFeatures...)
207-
208209
result, err = keepOnlyRequestedFeatures(result, featureRefs, featureService, fullFeatureNames)
209210
if err != nil {
210211
return nil, err

go/internal/feast/featurestore_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ func getRegistryPath() map[string]interface{} {
2222
return registry
2323
}
2424

25-
func dummyTransformCallback(ODFVName string, inputArrPtr, inputSchemaPtr, outArrPtr, outSchemaPtr uintptr, fullFeatureNames bool) int {
26-
return 0
27-
}
28-
2925
func TestNewFeatureStore(t *testing.T) {
3026
t.Skip("@todo(achals): feature_repo isn't checked in yet")
3127
config := RepoConfig{
@@ -36,7 +32,7 @@ func TestNewFeatureStore(t *testing.T) {
3632
"type": "redis",
3733
},
3834
}
39-
fs, err := NewFeatureStore(&config, dummyTransformCallback)
35+
fs, err := NewFeatureStore(&config, nil)
4036
assert.Nil(t, err)
4137
assert.IsType(t, &RedisOnlineStore{}, fs.onlineStore)
4238
}
@@ -62,7 +58,7 @@ func TestGetOnlineFeaturesRedis(t *testing.T) {
6258
{Val: &types.Value_Int64Val{Int64Val: 1003}}}},
6359
}
6460

65-
fs, err := NewFeatureStore(&config, dummyTransformCallback)
61+
fs, err := NewFeatureStore(&config, nil)
6662
assert.Nil(t, err)
6763
ctx := context.Background()
6864
response, err := fs.GetOnlineFeatures(

go/internal/feast/transformation.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import (
1515
"unsafe"
1616
)
1717

18+
/*
19+
TransformationCallback is a Python callback function's expected signature.
20+
The function should accept name of the on demand feature view and pointers to input & output record batches.
21+
Each record batch is being passed as two pointers: pointer to array (data) and pointer to schema.
22+
Python function is expected to return number of rows added to the output record batch.
23+
*/
1824
type TransformationCallback func(ODFVName string, inputArrPtr, inputSchemaPtr, outArrPtr, outSchemaPtr uintptr, fullFeatureNames bool) int
1925

2026
func augmentResponseWithOnDemandTransforms(

0 commit comments

Comments
 (0)