Skip to content

Commit 714b0c2

Browse files
mrzzyZhu Zhanyan
andauthored
Fix Go and Java SDK Regressions (feast-dev#729)
* Fix nil error cause by adding items to a nil map in go SDK's client.GetOnlineFeatures() * Fix issue where go sdk client.GetOnlineFeatures() does not return entity values * Fixed issue where Row is unable to parse Value type due to proto package rename. * Fix wrong path of test_feature python SDK test. * Revert stub and channel private fields to final in FeastClient java SDK Co-authored-by: Zhu Zhanyan <[email protected]>
1 parent b91f2dd commit 714b0c2

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

sdk/go/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (fc *GrpcClient) GetOnlineFeatures(ctx context.Context, req *OnlineFeatures
5252
resp, err := fc.cli.GetOnlineFeatures(ctx, featuresRequest)
5353

5454
// collect unqiue entity refs from entity rows
55-
var entityRefs map[string]struct{}
55+
entityRefs := make(map[string]struct{})
5656
for _, entityRows := range req.Entities {
5757
for ref, _ := range entityRows {
5858
entityRefs[ref] = struct{}{}
@@ -61,17 +61,17 @@ func (fc *GrpcClient) GetOnlineFeatures(ctx context.Context, req *OnlineFeatures
6161

6262
// strip projects from to projects
6363
for _, fieldValue := range resp.GetFieldValues() {
64-
var stripFields map[string]*types.Value
64+
stripFields := make(map[string]*types.Value)
6565
for refStr, value := range fieldValue.Fields {
6666
_, isEntity := entityRefs[refStr]
6767
if !isEntity { // is feature ref
6868
featureRef, err := parseFeatureRef(refStr, true)
6969
if err != nil {
7070
return nil, err
7171
}
72-
stripRefStr := toFeatureRefStr(featureRef)
73-
stripFields[stripRefStr] = value
72+
refStr = toFeatureRefStr(featureRef)
7473
}
74+
stripFields[refStr] = value
7575
}
7676
fieldValue.Fields = stripFields
7777
}

sdk/go/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ func (r Row) equalTo(other Row) bool {
2121
return true
2222
}
2323

24-
// StrVal is a int64 type feast value
24+
// StrVal is a string type feast value
2525
func StrVal(val string) *types.Value {
2626
return &types.Value{Val: &types.Value_StringVal{StringVal: val}}
2727
}
2828

29-
// Int32Val is a int64 type feast value
29+
// Int32Val is a int32 type feast value
3030
func Int32Val(val int32) *types.Value {
3131
return &types.Value{Val: &types.Value_Int32Val{Int32Val: val}}
3232
}

sdk/java/src/main/java/com/gojek/feast/FeastClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import feast.proto.serving.ServingAPIProto.GetOnlineFeaturesRequest.EntityRow;
2424
import feast.proto.serving.ServingAPIProto.GetOnlineFeaturesResponse;
2525
import feast.proto.serving.ServingServiceGrpc;
26+
import feast.proto.serving.ServingServiceGrpc.ServingServiceBlockingStub;
2627
import feast.proto.types.ValueProto.Value;
2728
import io.grpc.ManagedChannel;
2829
import io.grpc.ManagedChannelBuilder;
@@ -40,7 +41,7 @@ public class FeastClient implements AutoCloseable {
4041
private static final int CHANNEL_SHUTDOWN_TIMEOUT_SEC = 5;
4142

4243
private final ManagedChannel channel;
43-
private final ServingServiceGrpc.ServingServiceBlockingStub stub;
44+
private final ServingServiceBlockingStub stub;
4445

4546
/**
4647
* Create a client to access Feast
@@ -161,9 +162,9 @@ public List<Row> getOnlineFeatures(
161162
.collect(Collectors.toList());
162163
}
163164

164-
private FeastClient(ManagedChannel channel) {
165+
protected FeastClient(ManagedChannel channel) {
165166
this.channel = channel;
166-
stub = ServingServiceGrpc.newBlockingStub(channel);
167+
this.stub = ServingServiceGrpc.newBlockingStub(channel);
167168
}
168169

169170
public void close() throws Exception {

sdk/java/src/main/java/com/gojek/feast/Row.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public Row set(String fieldName, Object value) {
7676
fields.put(
7777
fieldName, Value.newBuilder().setBytesVal(ByteString.copyFrom((byte[]) value)).build());
7878
break;
79-
case "feast.types.ValueProto.Value":
79+
case "feast.proto.types.ValueProto.Value":
8080
fields.put(fieldName, (Value) value);
8181
break;
8282
default:

sdk/python/feast/test_feature.py renamed to sdk/python/tests/test_feature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class TestFeatureRef:
1919
def test_str_ref(self):
20-
original_ref = FeatureRef(project="test", name="test")
20+
original_ref = FeatureRef(feature_set="test", name="test")
2121
ref_str = repr(original_ref)
2222
parsed_ref = FeatureRef.from_str(ref_str)
2323
assert original_ref == parsed_ref

0 commit comments

Comments
 (0)