Skip to content

Commit 60756cb

Browse files
authored
fix: Pass native input values to get_online_features from feature server (#4117)
* fix: Pass native input values to get_online_features from feature server Signed-off-by: tokoko <[email protected]> * remove unnecessary type ignore hint Signed-off-by: tokoko <[email protected]> --------- Signed-off-by: tokoko <[email protected]>
1 parent b8087f7 commit 60756cb

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

‎sdk/python/feast/feature_server.py‎

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
from fastapi import FastAPI, HTTPException, Request, Response, status
1111
from fastapi.logger import logger
1212
from fastapi.params import Depends
13-
from google.protobuf.json_format import MessageToDict, Parse
13+
from google.protobuf.json_format import MessageToDict
1414
from pydantic import BaseModel
1515

1616
import feast
1717
from feast import proto_json, utils
1818
from feast.constants import DEFAULT_FEATURE_SERVER_REGISTRY_TTL
1919
from feast.data_source import PushMode
2020
from feast.errors import PushSourceNotFoundException
21-
from feast.protos.feast.serving.ServingService_pb2 import GetOnlineFeaturesRequest
2221

2322

2423
# TODO: deprecate this in favor of push features
@@ -83,34 +82,25 @@ def shutdown_event():
8382
@app.post("/get-online-features")
8483
def get_online_features(body=Depends(get_body)):
8584
try:
86-
# Validate and parse the request data into GetOnlineFeaturesRequest Protobuf object
87-
request_proto = GetOnlineFeaturesRequest()
88-
Parse(body, request_proto)
89-
85+
body = json.loads(body)
9086
# Initialize parameters for FeatureStore.get_online_features(...) call
91-
if request_proto.HasField("feature_service"):
87+
if "feature_service" in body:
9288
features = store.get_feature_service(
93-
request_proto.feature_service, allow_cache=True
89+
body["feature_service"], allow_cache=True
9490
)
9591
else:
96-
features = list(request_proto.features.val)
97-
98-
full_feature_names = request_proto.full_feature_names
92+
features = body["features"]
9993

100-
batch_sizes = [len(v.val) for v in request_proto.entities.values()]
101-
num_entities = batch_sizes[0]
102-
if any(batch_size != num_entities for batch_size in batch_sizes):
103-
raise HTTPException(status_code=500, detail="Uneven number of columns")
94+
full_feature_names = body.get("full_feature_names", False)
10495

10596
response_proto = store._get_online_features(
10697
features=features,
107-
entity_values=request_proto.entities,
98+
entity_values=body["entities"],
10899
full_feature_names=full_feature_names,
109-
native_entity_values=False,
110100
).proto
111101

112102
# Convert the Protobuf object to JSON and return it
113-
return MessageToDict( # type: ignore
103+
return MessageToDict(
114104
response_proto, preserving_proto_field_name=True, float_precision=18
115105
)
116106
except Exception as e:

0 commit comments

Comments
 (0)