Visitar URL original
perf: Replace MessageToDict with optimized custom dict builder by abhijeet-dhumal · Pull Request #6015 · feast-dev/feast · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
fix: Return raw bytes to match proto_json.patch() behavior
Signed-off-by: abhijeet-dhumal <abhijeetdhumal652@gmail.com>
  • Loading branch information
abhijeet-dhumal committed May 27, 2026
commit 698d0a17cb2c6c79cc1364f1985f5fb5552abeb4
9 changes: 5 additions & 4 deletions sdk/python/feast/feature_server_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Values are serialized as native Python types (not wrapped dicts).
"""

import base64
from datetime import datetime, timezone
from typing import Any, Dict, Optional

Expand Down Expand Up @@ -52,12 +51,14 @@ def convert_response_to_dict(response: GetOnlineFeaturesResponse) -> Dict[str, A


def _value_to_native(v: Value) -> Optional[Any]:
"""Convert a Value proto to native Python type (matches proto_json.patch() format)."""
"""Convert a Value proto to native Python type (matches proto_json.patch() format).

Note: proto_json.patch() modifies MessageToDict to return raw bytes instead of
base64 encoding, so we return raw bytes here to match that behavior.
"""
which = v.WhichOneof("val")
if which is None or which == "null_val":
return None
elif which == "bytes_val":
return base64.b64encode(v.bytes_val).decode("ascii")
elif "_list_" in which:
return list(getattr(v, which).val)
else:
Expand Down
5 changes: 2 additions & 3 deletions sdk/python/tests/unit/test_feature_server_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
Related issue: https://github.com/feast-dev/feast/issues/6013
"""

import base64
import time

import pytest
Expand Down Expand Up @@ -99,7 +98,7 @@ def test_bytes_val(self):
data = b"\x00\x01\x02\x03"
v = Value(bytes_val=data)
result = _value_to_native(v)
assert result == base64.b64encode(data).decode("ascii")
assert result == data

def test_double_list_val(self):
v = Value(double_list_val=DoubleList(val=[1.1, 2.2, 3.3]))
Expand Down Expand Up @@ -357,7 +356,7 @@ def test_metadata_matches_patched_format(self):
)

def test_bytes_values_match_patched_message_to_dict(self):
"""Ensure bytes serialization matches proto_json.patch() format (base64)."""
"""Ensure bytes serialization matches proto_json.patch() format (raw bytes)."""
response = GetOnlineFeaturesResponse()
fv = response.results.add()
fv.values.append(Value(bytes_val=b"\x00\x01\x02\xff"))
Expand Down