fix: convert NumPy arrays in insert_many vector field (Fixes #1002)#2082
Open
rtmalikian wants to merge 1 commit into
Open
fix: convert NumPy arrays in insert_many vector field (Fixes #1002)#2082rtmalikian wants to merge 1 commit into
rtmalikian wants to merge 1 commit into
Conversation
…weaviate#1002) insert_many() in executor.py constructs _BatchObject directly without converting the vector, causing NumPy arrays, torch tensors, and other supported vector types to be silently discarded. The fix applies _get_vector_v4() conversion (same as BatchObject.__init__) before storing the vector in _BatchObject. Also handles named vectors (dict[str, vector]) by converting each value. Signed-off-by: rtmalikian <rtmalikian@gmail.com>
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
|
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. |
Contributor
Author
|
I agree with the Contributor License Agreement. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1002
Problem
insert_many()inexecutor.pyconstructs_BatchObjectdirectly without converting thevectorfield, causing NumPy arrays, torch tensors, and other supported vector types to be silently discarded.BatchObject.__init__()already handles this via_get_vector_v4(), butinsert_manybypassesBatchObjectand uses the plain_BatchObjectdataclass directly, which stores whatever is passed without conversion.Solution
Applied
_get_vector_v4()conversion ininsert_many()before storing the vector in_BatchObject, matching the behavior ofBatchObject.__init__(). Also handles named vectors (dict[str, vector]) by converting each value.Files Changed
weaviate/collections/data/executor.py— Added_get_vector_v4()conversion for both single vectors and named vector dictsVerification
All checks passed!_get_vector_v4()is already imported (line 63) and used elsewhere in the same file (lines 715, 717)Changelog
About the Author: Raphael Malikian — Clinical AI Solutions Architect. I specialise in building and fixing AI/ML systems for healthcare, including vector databases, RAG pipelines, and clinical NLP. If you need help with your project or think I can add value to your organisation, feel free to reach out — I'd love to connect.
📧 rtmalikian@gmail.com
🔗 GitHub: https://github.com/rtmalikian
🔗 LinkedIn: http://www.linkedin.com/in/raphael-t-malikian-mbbs-bsc-hons-71075436a
Disclosure: This code was developed with assistance from DeepSeek v4 Pro (DeepSeek) via Hermes Agent (Nous Research). All changes were reviewed, tested against the actual codebase, and verified for correctness.