Skip to content

Commit 739eaa7

Browse files
feat: Adding vector_search parameter to fields (feast-dev#4855)
* feat: Adding vector_search parameter to fields Signed-off-by: Francisco Javier Arceo <farceo@redhat.com> * updated field to handle linter and updated sphinx docs Signed-off-by: Francisco Javier Arceo <farceo@redhat.com> * Have to remove the equality test for the new fields...for now we're going to ignore them so it is backwards compatible Signed-off-by: Francisco Javier Arceo <farceo@redhat.com> * linter Signed-off-by: Francisco Javier Arceo <farceo@redhat.com> --------- Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
1 parent 9887b90 commit 739eaa7

18 files changed

+162
-16
lines changed

protos/feast/core/Feature.proto

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ message FeatureSpecV2 {
3535
map<string,string> tags = 3;
3636

3737
// Description of the feature.
38-
3938
string description = 4;
39+
40+
// Field indicating the vector will be indexed for vector similarity search
41+
bool vector_index = 5;
42+
43+
// Metric used for vector similarity search.
44+
string vector_search_metric = 6;
4045
}

sdk/python/docs/source/feast.infra.online_stores.rst

+18-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ Subpackages
77
.. toctree::
88
:maxdepth: 4
99

10-
feast.infra.online_stores
10+
feast.infra.online_stores.cassandra_online_store
11+
feast.infra.online_stores.couchbase_online_store
12+
feast.infra.online_stores.elasticsearch_online_store
13+
feast.infra.online_stores.hazelcast_online_store
14+
feast.infra.online_stores.hbase_online_store
15+
feast.infra.online_stores.ikv_online_store
16+
feast.infra.online_stores.milvus_online_store
17+
feast.infra.online_stores.mysql_online_store
18+
feast.infra.online_stores.postgres_online_store
19+
feast.infra.online_stores.qdrant_online_store
1120

1221
Submodules
1322
----------
@@ -36,6 +45,14 @@ feast.infra.online\_stores.dynamodb module
3645
:undoc-members:
3746
:show-inheritance:
3847

48+
feast.infra.online\_stores.faiss\_online\_store module
49+
------------------------------------------------------
50+
51+
.. automodule:: feast.infra.online_stores.faiss_online_store
52+
:members:
53+
:undoc-members:
54+
:show-inheritance:
55+
3956
feast.infra.online\_stores.helpers module
4057
-----------------------------------------
4158

sdk/python/docs/source/feast.infra.rst

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ feast.infra.provider module
5151
:undoc-members:
5252
:show-inheritance:
5353

54+
feast.infra.supported\_async\_methods module
55+
--------------------------------------------
56+
57+
.. automodule:: feast.infra.supported_async_methods
58+
:members:
59+
:undoc-members:
60+
:show-inheritance:
61+
5462
Module contents
5563
---------------
5664

sdk/python/feast/field.py

+21
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ class Field:
3232
dtype: The type of the field, such as string or float.
3333
description: A human-readable description.
3434
tags: User-defined metadata in dictionary form.
35+
vector_index: If set to True the field will be indexed for vector similarity search.
36+
vector_search_metric: The metric used for vector similarity search.
3537
"""
3638

3739
name: str
3840
dtype: FeastType
3941
description: str
4042
tags: Dict[str, str]
43+
vector_index: bool
44+
vector_search_metric: Optional[str]
4145

4246
def __init__(
4347
self,
@@ -46,6 +50,8 @@ def __init__(
4650
dtype: FeastType,
4751
description: str = "",
4852
tags: Optional[Dict[str, str]] = None,
53+
vector_index: bool = False,
54+
vector_search_metric: Optional[str] = None,
4955
):
5056
"""
5157
Creates a Field object.
@@ -55,11 +61,15 @@ def __init__(
5561
dtype: The type of the field, such as string or float.
5662
description (optional): A human-readable description.
5763
tags (optional): User-defined metadata in dictionary form.
64+
vector_index (optional): If set to True the field will be indexed for vector similarity search.
65+
vector_search_metric (optional): The metric used for vector similarity search.
5866
"""
5967
self.name = name
6068
self.dtype = dtype
6169
self.description = description
6270
self.tags = tags or {}
71+
self.vector_index = vector_index
72+
self.vector_search_metric = vector_search_metric
6373

6474
def __eq__(self, other):
6575
if type(self) != type(other):
@@ -70,6 +80,8 @@ def __eq__(self, other):
7080
or self.dtype != other.dtype
7181
or self.description != other.description
7282
or self.tags != other.tags
83+
# or self.vector_index != other.vector_index
84+
# or self.vector_search_metric != other.vector_search_metric
7385
):
7486
return False
7587
return True
@@ -87,6 +99,8 @@ def __repr__(self):
8799
f" dtype={self.dtype!r},\n"
88100
f" description={self.description!r},\n"
89101
f" tags={self.tags!r}\n"
102+
f" vector_index={self.vector_index!r}\n"
103+
f" vector_search_metric={self.vector_search_metric!r}\n"
90104
f")"
91105
)
92106

@@ -96,11 +110,14 @@ def __str__(self):
96110
def to_proto(self) -> FieldProto:
97111
"""Converts a Field object to its protobuf representation."""
98112
value_type = self.dtype.to_value_type()
113+
vector_search_metric = self.vector_search_metric or ""
99114
return FieldProto(
100115
name=self.name,
101116
value_type=value_type.value,
102117
description=self.description,
103118
tags=self.tags,
119+
vector_index=self.vector_index,
120+
vector_search_metric=vector_search_metric,
104121
)
105122

106123
@classmethod
@@ -112,11 +129,15 @@ def from_proto(cls, field_proto: FieldProto):
112129
field_proto: FieldProto protobuf object
113130
"""
114131
value_type = ValueType(field_proto.value_type)
132+
vector_search_metric = getattr(field_proto, "vector_search_metric", "")
133+
vector_index = getattr(field_proto, "vector_index", False)
115134
return cls(
116135
name=field_proto.name,
117136
dtype=from_value_type(value_type=value_type),
118137
tags=dict(field_proto.tags),
119138
description=field_proto.description,
139+
vector_index=vector_index,
140+
vector_search_metric=vector_search_metric,
120141
)
121142

122143
@classmethod

sdk/python/feast/protos/feast/core/DataSource_pb2.py

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/python/feast/protos/feast/core/DataSource_pb2.pyi

+15
Original file line numberDiff line numberDiff line change
@@ -557,3 +557,18 @@ class DataSource(google.protobuf.message.Message):
557557
def WhichOneof(self, oneof_group: typing_extensions.Literal["options", b"options"]) -> typing_extensions.Literal["file_options", "bigquery_options", "kafka_options", "kinesis_options", "redshift_options", "request_data_options", "custom_options", "snowflake_options", "push_options", "spark_options", "trino_options", "athena_options"] | None: ...
558558

559559
global___DataSource = DataSource
560+
561+
class DataSourceList(google.protobuf.message.Message):
562+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
563+
564+
DATASOURCES_FIELD_NUMBER: builtins.int
565+
@property
566+
def datasources(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___DataSource]: ...
567+
def __init__(
568+
self,
569+
*,
570+
datasources: collections.abc.Iterable[global___DataSource] | None = ...,
571+
) -> None: ...
572+
def ClearField(self, field_name: typing_extensions.Literal["datasources", b"datasources"]) -> None: ...
573+
574+
global___DataSourceList = DataSourceList

sdk/python/feast/protos/feast/core/Entity_pb2.py

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)