in datastore/providers/weaviate_datastore.py [0:0]
def __init__(self):
auth_credentials = self._build_auth_credentials()
url = os.environ.get("WEAVIATE_URL", WEAVIATE_URL_DEFAULT)
logger.debug(
f"Connecting to weaviate instance at {url} with credential type {type(auth_credentials).__name__}"
)
self.client = Client(url, auth_client_secret=auth_credentials)
self.client.batch.configure(
batch_size=WEAVIATE_BATCH_SIZE,
dynamic=WEAVIATE_BATCH_DYNAMIC, # type: ignore
callback=self.handle_errors, # type: ignore
timeout_retries=WEAVIATE_BATCH_TIMEOUT_RETRIES,
num_workers=WEAVIATE_BATCH_NUM_WORKERS,
)
if self.client.schema.contains(SCHEMA):
current_schema = self.client.schema.get(WEAVIATE_CLASS)
current_schema_properties = extract_schema_properties(current_schema)
logger.debug(
f"Found index {WEAVIATE_CLASS} with properties {current_schema_properties}"
)
logger.debug("Will reuse this schema")
else:
new_schema_properties = extract_schema_properties(SCHEMA)
logger.debug(
f"Creating collection {WEAVIATE_CLASS} with properties {new_schema_properties}"
)
self.client.schema.create_class(SCHEMA)