AttributeError: 'DataObject' object has no attribute 'items' in v4 Python Client

Hi @Maruthi !!

Thanks jumping in on our new V4 client!! :hugs:

~I believe we have a bug :beetle: here!~ (or not)

consider the following code, based on your previous thread:

import json
import requests
import weaviate
import weaviate.classes as wvc
from fastembed.embedding import FlagEmbedding as Embedding

client = weaviate.connect_to_local(
    port=8080,
    grpc_port=50051
)

embedding_model = Embedding(model_name="BAAI/bge-base-en", max_length=512)

if client.collections.exists("new"):
    client.collections.delete("new") 

questions = client.collections.create(
    name="new",
    vectorizer_config=None,
    generative_config=None,
)

resp = requests.get(
    "https://raw.githubusercontent.com/weaviate-tutorials/quickstart/main/data/jeopardy_tiny.json"
)
data = json.loads(resp.text)
question_objs = list()
for i, d in enumerate(data):
    vec = list(embedding_model.embed(d["Question"]))[0]
    print(f"importing question: {i+1}")
    question_objs.append(
        wvc.DataObject(
            properties={
                "answer": d["Answer"],
                "question": d["Question"],
                "category": d["Category"],
                "test": "test",
            },
            vector=vec
        )
    )

questions = client.collections.get("new")

# this doesn't work
#questions.data.insert(question_objs[0]) 
# this works
questions.data.insert_many([question_objs[0]]) 

I will poke about this internally. I was able to use insert() but only when I don’t provide the vectors.

Thanks for reporting this!

1 Like