Cant we create a collection with named vectors using json file configuration but via python v4 sdk?

Description

Hello community, I wonder if I could put all my configurations about a new Collection in a json file, and use client.collections.create_from_dict() method to create this Collection? The stuff in python sdk is not that clear and migratable (in my opinon, json file config could be directly used for Weaviate RESTful API) for me so personally I would choose json config if it is still possible.
Thank you for your attention.

hi @user1503 !!

Welcome to our community :hugs:

Sure, you can export your collection configuration into a python dictionary and move it around using json then create a new collection use that configuration.

here is how using Python Client: 4.16.10 and Server: 1.32.9:

client.collections.delete(["Test", "Test2"])
collection = client.collections.create(
    name="Test",
    vector_config=[
        wvc.config.Configure.Vectors.text2vec_openai(name="vector1"),
        wvc.config.Configure.Vectors.text2vec_cohere(name="vector2"),
    ],
    properties=[
        wvc.config.Property(
            name="data",
            data_type=wvc.config.DataType.TEXT,
        ),
        wvc.config.Property(
            name="hotel_id",
            data_type=wvc.config.DataType.INT,
        )
    ]
)
my_collection_schema = collection.config.get().to_dict()
# now let's create a new collection
new_collection_schema = my_collection_schema
# change the collection name
new_collection_schema["class"] = "Test2"
new_collection = client.collections.create_from_dict(new_collection_schema)
# assert their vector configs are the same
assert new_collection.config.get().vector_config, collection.config.get().vector_config

Let me know if this helps!

Happy coding!