feature: allow 1D numpy array
Fixes #1002
This is the simplest fix which allows a 1d numpy array to be passed in (additionally, anything which can be converted in the function util.get_vector). This will raise a TypeError if the input is incorrect, which is converted later to WeaviateInvalidInputError.
Note that passing in something else then types.VECTOR, e.g. a numpy array, will raise a mypy error.
Hey, thank you for your contribution! Would you be able to add a test here: integration/test_batch_v4.py? Numpy is available as a test dependency
To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.
beep boop - the Weaviate bot 👋🤖
PS:
Are you already a member of the Weaviate Slack channel?
agree with the CLA
agree with the CLA
Hi @dirkkul, I think should be fine now. The two previous tests which failed (DB issue and timeout on grpc) were not connected to this PR.
@dirkkul friendly reminder: can this branch be merged?
Hey, I think you are mixing two things up:
- how the users supplies vectors
- how we hand them internally (vector bytes, packing etc)
We would want that user supplied vectors that are numpy arrays are converted to python lists. So if you do
_BatchObject(
collection=self.name,
vector=_get_vector_v4(obj.vector),
uuid=str(obj.uuid if obj.uuid is not None else uuid_package.uuid4()),
properties=cast(dict, obj.properties),
tenant=self._tenant,
references=obj.references,
index=idx,
)
it should take care of things.
Hi @dirkkul, thanks for your patience, fingers crossed I got it now...
Friendly ping @dirkkul