Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -72,11 +72,23 @@ Article = {
|
|
72 |
# Function to check if a class exists in the schema
|
73 |
def class_exists(class_name):
|
74 |
try:
|
75 |
-
|
|
|
|
|
76 |
except Exception as e:
|
77 |
print(f"Error checking if class exists: {e}")
|
78 |
return False
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
# Initialize the schema
|
81 |
schema = {
|
82 |
"classes": [Article]
|
|
|
72 |
# Function to check if a class exists in the schema
|
73 |
def class_exists(class_name):
|
74 |
try:
|
75 |
+
existing_schema = client.schema.get()
|
76 |
+
existing_classes = [cls["class"] for cls in existing_schema["classes"]]
|
77 |
+
return class_name in existing_classes
|
78 |
except Exception as e:
|
79 |
print(f"Error checking if class exists: {e}")
|
80 |
return False
|
81 |
|
82 |
+
# Check if 'Article' class already exists
|
83 |
+
if not class_exists("Article"):
|
84 |
+
# Create the schema if 'Article' class does not exist
|
85 |
+
try:
|
86 |
+
client.schema.create(schema)
|
87 |
+
except Exception as e:
|
88 |
+
print(f"Error creating schema: {e}")
|
89 |
+
else:
|
90 |
+
print("Class 'Article' already exists in the schema.")
|
91 |
+
|
92 |
# Initialize the schema
|
93 |
schema = {
|
94 |
"classes": [Article]
|