Spaces:
Build error
Build error
Commit
·
d0443ee
1
Parent(s):
b9dd2dd
Update weaviate_utils.py
Browse files- weaviate_utils.py +1 -22
weaviate_utils.py
CHANGED
|
@@ -46,25 +46,4 @@ def ingest_data_to_weaviate(client, dataframe, class_name, class_description):
|
|
| 46 |
}
|
| 47 |
try:
|
| 48 |
client.schema.property.create(class_name, property_schema)
|
| 49 |
-
except weaviate.exceptions.
|
| 50 |
-
# Property might already exist, so we can continue
|
| 51 |
-
pass
|
| 52 |
-
|
| 53 |
-
# Ingest data
|
| 54 |
-
for index, row in dataframe.iterrows():
|
| 55 |
-
obj = {
|
| 56 |
-
"class": class_name,
|
| 57 |
-
"id": str(index),
|
| 58 |
-
"properties": row.to_dict()
|
| 59 |
-
}
|
| 60 |
-
client.data_object.create(obj)
|
| 61 |
-
|
| 62 |
-
# Log data ingestion
|
| 63 |
-
log_debug_info(f"Data ingested into Weaviate for class: {class_name}")
|
| 64 |
-
|
| 65 |
-
def get_class_schema(client, class_name):
|
| 66 |
-
all_classes = client.schema.get()["classes"]
|
| 67 |
-
for cls in all_classes:
|
| 68 |
-
if cls["class"] == class_name:
|
| 69 |
-
return cls
|
| 70 |
-
return None
|
|
|
|
| 46 |
}
|
| 47 |
try:
|
| 48 |
client.schema.property.create(class_name, property_schema)
|
| 49 |
+
except weaviate.exceptions.SchemaValidation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|