Hi @DudaNogueira , aplogies for the delay, here’s the minimal reproducible code:
import uuid
import weaviate
import weaviate.classes as wvc
from weaviate.classes.query import Filter, MetadataQuery
from weaviate.classes.config import Configure, VectorDistances, Property, DataType
from weaviate.classes.tenants import Tenant
from datetime import datetime, timedelta
import pytz
try:
# TODO: use different credentials for production
# Best practice: store your credentials in environment variables
wcd_url = ""
wcd_api_key = ""
client = weaviate.connect_to_weaviate_cloud(
cluster_url=wcd_url, # Replace with your Weaviate Cloud URL
auth_credentials=wvc.init.Auth.api_key(wcd_api_key), # Replace with your Weaviate Cloud key
)
except Exception as e:
print(e)
# exit
pass
try:
# For all objects
nodes_collection = client.collections.create(
name="Nodes",
vectorizer_config=wvc.config.Configure.Vectorizer.none(),
vector_index_config=Configure.VectorIndex.hnsw(
distance_metric=VectorDistances.COSINE
),
# Multi tenancy to separate each user's data
multi_tenancy_config=Configure.multi_tenancy(enabled=True, auto_tenant_creation=True, auto_tenant_activation=True),
inverted_index_config=Configure.inverted_index(
index_null_state=True,
index_property_length=True,
index_timestamps=True
)
# Specify some properties beforehand to set right data type (i.e. obj[] instead of string[])
properties=[
Property(name="tags", data_type=DataType.OBJECT_ARRAY),
]
)
except:
nodes_collection = client.collections.get("Nodes")
try:
# Create tenant on Node
nodes_collection.tenants.create(
tenants=[
Tenant(name="tenantA"),
Tenant(name="tenantB"),
]
)
except:
pass
# Will cause an error
nodes_collection.with_tenant('tenantA').data.insert(
vector=[0.0] * 384,
properties={'lastUpdateDeviceId': 'device-78C24351-F40A-4E37-8953-F003FA474877'},
uuid=str(uuid.uuid4())
)