Spaces:
Build error
Build error
Commit ·
340cc83
1
Parent(s): 2734d11
Update weaviate_utils.py
Browse files22 unmodified lines23242526262728293031323334353637383940414243444546474849505152535455565758596061626364656622 unmodified lines return "string"
def ingest_data_to_weaviate(client, dataframe, class_name, class_description): # ... [same as in your code] # Create class schema class_schema = { "class": class_name, "description": class_description, "properties": [] # Start with an empty properties list } # Try to create the class without properties first try: client.schema.create({"classes": [class_schema]}) except weaviate.exceptions.SchemaValidationException: # Class might already exist, so we can continue pass
# Now, let's add properties to the class for column_name, data_type in zip(dataframe.columns, dataframe.dtypes): property_schema = { "name": column_name, "description": f"Property for {column_name}", "dataType": [map_dtype_to_weaviate(data_type)] } try: client.schema.property.create(class_name, property_schema) except weaviate.exceptions.SchemaValidationException: # Property might already exist, so we can continue pass
# Ingest data for index, row in dataframe.iterrows(): obj = { "class": class_name, "id": str(index), "properties": row.to_dict() } client.data_object.create(obj)
# Log data ingestion log_debug_info(f"Data ingested into Weaviate for class: {class_name}")
def get_class_schema(client, class_name): all_classes = client.schema.get()["classes"]weaviate_utils.py+38-1