Skip to content

Commit

Permalink
feat: Adding vector_search parameter to fields (feast-dev#4855)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
franciscojavierarceo authored Dec 18, 2024
1 parent 9887b90 commit 739eaa7
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 16 deletions.
7 changes: 6 additions & 1 deletion protos/feast/core/Feature.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ message FeatureSpecV2 {
map<string,string> tags = 3;

// Description of the feature.

string description = 4;

// Field indicating the vector will be indexed for vector similarity search
bool vector_index = 5;

// Metric used for vector similarity search.
string vector_search_metric = 6;
}
19 changes: 18 additions & 1 deletion sdk/python/docs/source/feast.infra.online_stores.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ Subpackages
.. toctree::
:maxdepth: 4

feast.infra.online_stores
feast.infra.online_stores.cassandra_online_store
feast.infra.online_stores.couchbase_online_store
feast.infra.online_stores.elasticsearch_online_store
feast.infra.online_stores.hazelcast_online_store
feast.infra.online_stores.hbase_online_store
feast.infra.online_stores.ikv_online_store
feast.infra.online_stores.milvus_online_store
feast.infra.online_stores.mysql_online_store
feast.infra.online_stores.postgres_online_store
feast.infra.online_stores.qdrant_online_store

Submodules
----------
Expand Down Expand Up @@ -36,6 +45,14 @@ feast.infra.online\_stores.dynamodb module
:undoc-members:
:show-inheritance:

feast.infra.online\_stores.faiss\_online\_store module
------------------------------------------------------

.. automodule:: feast.infra.online_stores.faiss_online_store
:members:
:undoc-members:
:show-inheritance:

feast.infra.online\_stores.helpers module
-----------------------------------------

Expand Down
8 changes: 8 additions & 0 deletions sdk/python/docs/source/feast.infra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ feast.infra.provider module
:undoc-members:
:show-inheritance:

feast.infra.supported\_async\_methods module
--------------------------------------------

.. automodule:: feast.infra.supported_async_methods
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

Expand Down
21 changes: 21 additions & 0 deletions sdk/python/feast/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ class Field:
dtype: The type of the field, such as string or float.
description: A human-readable description.
tags: User-defined metadata in dictionary form.
vector_index: If set to True the field will be indexed for vector similarity search.
vector_search_metric: The metric used for vector similarity search.
"""

name: str
dtype: FeastType
description: str
tags: Dict[str, str]
vector_index: bool
vector_search_metric: Optional[str]

def __init__(
self,
Expand All @@ -46,6 +50,8 @@ def __init__(
dtype: FeastType,
description: str = "",
tags: Optional[Dict[str, str]] = None,
vector_index: bool = False,
vector_search_metric: Optional[str] = None,
):
"""
Creates a Field object.
Expand All @@ -55,11 +61,15 @@ def __init__(
dtype: The type of the field, such as string or float.
description (optional): A human-readable description.
tags (optional): User-defined metadata in dictionary form.
vector_index (optional): If set to True the field will be indexed for vector similarity search.
vector_search_metric (optional): The metric used for vector similarity search.
"""
self.name = name
self.dtype = dtype
self.description = description
self.tags = tags or {}
self.vector_index = vector_index
self.vector_search_metric = vector_search_metric

def __eq__(self, other):
if type(self) != type(other):
Expand All @@ -70,6 +80,8 @@ def __eq__(self, other):
or self.dtype != other.dtype
or self.description != other.description
or self.tags != other.tags
# or self.vector_index != other.vector_index
# or self.vector_search_metric != other.vector_search_metric
):
return False
return True
Expand All @@ -87,6 +99,8 @@ def __repr__(self):
f" dtype={self.dtype!r},\n"
f" description={self.description!r},\n"
f" tags={self.tags!r}\n"
f" vector_index={self.vector_index!r}\n"
f" vector_search_metric={self.vector_search_metric!r}\n"
f")"
)

Expand All @@ -96,11 +110,14 @@ def __str__(self):
def to_proto(self) -> FieldProto:
"""Converts a Field object to its protobuf representation."""
value_type = self.dtype.to_value_type()
vector_search_metric = self.vector_search_metric or ""
return FieldProto(
name=self.name,
value_type=value_type.value,
description=self.description,
tags=self.tags,
vector_index=self.vector_index,
vector_search_metric=vector_search_metric,
)

@classmethod
Expand All @@ -112,11 +129,15 @@ def from_proto(cls, field_proto: FieldProto):
field_proto: FieldProto protobuf object
"""
value_type = ValueType(field_proto.value_type)
vector_search_metric = getattr(field_proto, "vector_search_metric", "")
vector_index = getattr(field_proto, "vector_index", False)
return cls(
name=field_proto.name,
dtype=from_value_type(value_type=value_type),
tags=dict(field_proto.tags),
description=field_proto.description,
vector_index=vector_index,
vector_search_metric=vector_search_metric,
)

@classmethod
Expand Down
4 changes: 3 additions & 1 deletion sdk/python/feast/protos/feast/core/DataSource_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions sdk/python/feast/protos/feast/core/DataSource_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -557,3 +557,18 @@ class DataSource(google.protobuf.message.Message):
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: ...

global___DataSource = DataSource

class DataSourceList(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

DATASOURCES_FIELD_NUMBER: builtins.int
@property
def datasources(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___DataSource]: ...
def __init__(
self,
*,
datasources: collections.abc.Iterable[global___DataSource] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["datasources", b"datasources"]) -> None: ...

global___DataSourceList = DataSourceList
4 changes: 3 additions & 1 deletion sdk/python/feast/protos/feast/core/Entity_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 739eaa7

Please sign in to comment.