Visitar URL original
fix: Convert PdfBytes values to protos like ImageBytes by raashish1601 · Pull Request #6968 · feast-dev/feast · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ def _type_err(item, dtype):
),
ValueType.STRING: ("string_val", lambda x: str(x), None),
ValueType.BYTES: ("bytes_val", lambda x: x, {bytes}),
ValueType.PDF_BYTES: ("bytes_val", lambda x: x, {bytes}),
ValueType.IMAGE_BYTES: ("bytes_val", lambda x: x, {bytes}),
ValueType.BOOL: ("bool_val", lambda x: x, {bool, np.bool_, int, np.int_}),
ValueType.UUID: ("uuid_val", lambda x: str(x), {str, uuid_module.UUID}),
Expand Down
9 changes: 9 additions & 0 deletions sdk/python/tests/unit/test_type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ def test_python_values_to_proto_values_bytes_to_list(values, value_type, expecte
assert converted == expected


@pytest.mark.parametrize(
"value_type", [ValueType.BYTES, ValueType.PDF_BYTES, ValueType.IMAGE_BYTES]
)
def test_python_values_to_proto_values_binary(value_type):
protos = python_values_to_proto_values([b"%PDF-1.3", None], value_type)
assert feast_value_type_to_python_type(protos[0]) == b"%PDF-1.3"
assert feast_value_type_to_python_type(protos[1]) is None


def test_python_values_to_proto_values_bytes_to_list_not_supported():
with pytest.raises(TypeError):
_ = python_values_to_proto_values([b"[]"], ValueType.BYTES_LIST)
Expand Down
Loading