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
reverted changes back
  • Loading branch information
Manisha Sudhir committed Aug 17, 2023
commit 880efed25e1ec2826d2fda437f6b953dbc6f780e
30 changes: 6 additions & 24 deletions sdk/python/feast/expediagroup/vectordb/milvus_online_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ def online_write_batch(
) -> None:
with MilvusConnectionManager(config.online_store):
try:
entities = self._format_data_for_milvus(data)
rows = self._format_data_for_milvus(data)
collection_to_load_data = Collection(table.name)
collection_to_load_data.insert(entities)
collection_to_load_data.insert(rows)
# The flush call will seal any remaining segments and send them for indexing
collection_to_load_data.flush()
except Exception as e:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that we shouldn't put a try / except around the entire code and rather catch errors more targeted where they actually occur. We can address it later, but if you see ways to do it now please do so.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Expand Down Expand Up @@ -257,29 +257,11 @@ def _format_data_for_milvus(self, feast_data):
feature = []
for feature_name, val in values.items():
val_type = val.WhichOneof("val")
value = getattr(val, val_type)
if val_type == "float_list_val":
float_list = val.float_list_val.val
final_float_list = np.array(float_list)
feature.append(final_float_list)
# TODO: Test out binary lists
if val_type == "biinary_list_val":
binary_list = val.binary_list_val.val
feature.append(binary_list)
if val_type == "string_val":
string_val = val.string_val
feature.append(string_val)
if val_type == "int32_val":
int32_val = val.int32_val
feature.append(int32_val)
if val_type == "int64_val":
int64_val = val.int64_val
feature.append(int64_val)
if val_type == "bytes_val":
bytes_val = val.bytes_val
feature.append(bytes_val)
if val_type == "float_val":
float_val = val.float_val
feature.append(float_val)
value = np.array(value.val)
# TODO: Check binary vector conversion
feature.append(value)
milvus_data.append(feature)

transformed_data = [list(item) for item in zip(*milvus_data)]
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/tests/expediagroup/test_milvus_online_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def create_n_customer_test_samples_milvus(self, n=10):
),
{
"avg_orders_day": ValueProto(
float_list_val=FloatList(val=[1, 2, 3, 4, 5])
float_list_val=FloatList(val=[1.0, 2.1, 3.3, 4.0, 5.0])
),
"name": ValueProto(string_val="John"),
"age": ValueProto(int64_val=3),
Expand Down