insert_many silently discards vectors if they're NumPy arrays
Opened this issue · 4 comments
If I have a collection c
and call c.data.insert_many
on a list[DataObject]
, each of which with the vector
field set to a NumPy array, the upload returns without error but silently discards the vectors. The line that causes this behavior is here.
I would expect the NumPy array to be interpreted as a list of floats. Or, if this is undesirable for some reason, passing a NumPy array as a vector should result in an error.
hi @kylrth, this is definitely a bug since we handle NumPy arrays gracefully in other areas of the API. I will make sure it's fixed for the next release. Thanks for raising it!
hi @tsmith023 Can I work on this?
Yes thank you, that would be great!
@tsmith023 I have raised a PR, please review it.
I was not sure how to do it without importing numpy, I was having troubles with Pydantic throwing errors when specifying types without importing them. Also numpy.ndarray doesn't seem to implement Sequence from ABC, only closest thing it implements is Iterable, So I added a custom class for validation.