Skip to content

Commit

Permalink
updated milvus
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Javier Arceo <[email protected]>
  • Loading branch information
franciscojavierarceo committed Dec 17, 2024
1 parent 8b66233 commit a026729
Show file tree
Hide file tree
Showing 19 changed files with 155 additions and 28 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;
}
20 changes: 20 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 @@ -101,6 +115,8 @@ def to_proto(self) -> FieldProto:
value_type=value_type.value,
description=self.description,
tags=self.tags,
vector_index=self.vector_index,
vector_search_metric=self.vector_search_metric
)

@classmethod
Expand All @@ -112,11 +128,15 @@ def from_proto(cls, field_proto: FieldProto):
field_proto: FieldProto protobuf object
"""
value_type = ValueType(field_proto.value_type)
vector_search_metric = field_proto.vector_search_metric if field_proto.HasField("vector_search_metric") else None
vector_index = field_proto.vector_index if field_proto.HasField("vector_index") else 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
13 changes: 11 additions & 2 deletions sdk/python/feast/infra/online_stores/milvus_online_store/milvus.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
from feast.repo_config import FeastConfigBaseModel, RepoConfig
from feast.type_map import PROTO_VALUE_TO_VALUE_TYPE_MAP
from feast.types import VALUE_TYPES_TO_FEAST_TYPES, Array, PrimitiveFeastType, ComplexFeastType, ValueType
from feast.types import (
VALUE_TYPES_TO_FEAST_TYPES,
Array,
ComplexFeastType,
PrimitiveFeastType,
ValueType,
)
from feast.utils import (
_build_retrieve_online_document_record,
to_naive_utc,
Expand All @@ -46,7 +52,9 @@
PROTO_VALUE_TO_VALUE_TYPE_MAP["bool_list_val"]: DataType.BINARY_VECTOR,
}

FEAST_PRIMITIVE_TO_MILVUS_TYPE_MAPPING: Dict[Union[PrimitiveFeastType, Array, ComplexFeastType], DataType] = {}
FEAST_PRIMITIVE_TO_MILVUS_TYPE_MAPPING: Dict[
Union[PrimitiveFeastType, Array, ComplexFeastType], DataType
] = {}

for value_type, feast_type in VALUE_TYPES_TO_FEAST_TYPES.items():
if isinstance(feast_type, PrimitiveFeastType):
Expand Down Expand Up @@ -267,6 +275,7 @@ def online_read(
results.append((None, None))
else:
results.append((res_ts, res_dict))

return results

def update(
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 a026729

Please sign in to comment.