Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -94,12 +94,14 @@ def index():
|
|
94 |
logger.info(f"Deleted ChromaDB collection: {DB_NAME}")
|
95 |
except Exception as e:
|
96 |
logger.warning(f"Failed to delete collection {DB_NAME}: {e}")
|
97 |
-
client.create_collection(DB_NAME)
|
98 |
logger.info(f"Created fresh ChromaDB collection: {DB_NAME}")
|
99 |
|
100 |
# Process dataset
|
101 |
-
result = subprocess.run(['python', 'process_hf_dataset.py'], check=True, capture_output=True, text=True)
|
102 |
logger.info(f"Process Hugging Face dataset output: {result.stdout}")
|
|
|
|
|
103 |
return render_template(
|
104 |
'results_partial.html',
|
105 |
parts=None,
|
@@ -121,8 +123,10 @@ def index():
|
|
121 |
logger.info(f"Using existing or new ChromaDB collection: {DB_NAME}")
|
122 |
|
123 |
# Process dataset
|
124 |
-
result = subprocess.run(['python', 'process_hf_dataset.py'], check=True, capture_output=True, text=True)
|
125 |
logger.info(f"Load Hugging Face dataset output: {result.stdout}")
|
|
|
|
|
126 |
return render_template(
|
127 |
'results_partial.html',
|
128 |
parts=None,
|
@@ -144,8 +148,11 @@ def index():
|
|
144 |
logger.info(f"Deleted ChromaDB collection: {DB_NAME}")
|
145 |
except Exception as e:
|
146 |
logger.warning(f"Failed to delete collection {DB_NAME}: {e}")
|
147 |
-
client.create_collection(DB_NAME)
|
148 |
logger.info(f"Created fresh ChromaDB collection: {DB_NAME}")
|
|
|
|
|
|
|
149 |
return render_template(
|
150 |
'results_partial.html',
|
151 |
parts=None,
|
|
|
94 |
logger.info(f"Deleted ChromaDB collection: {DB_NAME}")
|
95 |
except Exception as e:
|
96 |
logger.warning(f"Failed to delete collection {DB_NAME}: {e}")
|
97 |
+
collection = client.create_collection(DB_NAME)
|
98 |
logger.info(f"Created fresh ChromaDB collection: {DB_NAME}")
|
99 |
|
100 |
# Process dataset
|
101 |
+
result = subprocess.run(['python', 'process_hf_dataset.py'], check=True, capture_output=True, text=True, cwd=os.path.dirname(__file__))
|
102 |
logger.info(f"Process Hugging Face dataset output: {result.stdout}")
|
103 |
+
if result.stderr:
|
104 |
+
logger.error(f"Process Hugging Face dataset errors: {result.stderr}")
|
105 |
return render_template(
|
106 |
'results_partial.html',
|
107 |
parts=None,
|
|
|
123 |
logger.info(f"Using existing or new ChromaDB collection: {DB_NAME}")
|
124 |
|
125 |
# Process dataset
|
126 |
+
result = subprocess.run(['python', 'process_hf_dataset.py'], check=True, capture_output=True, text=True, cwd=os.path.dirname(__file__))
|
127 |
logger.info(f"Load Hugging Face dataset output: {result.stdout}")
|
128 |
+
if result.stderr:
|
129 |
+
logger.error(f"Load Hugging Face dataset errors: {result.stderr}")
|
130 |
return render_template(
|
131 |
'results_partial.html',
|
132 |
parts=None,
|
|
|
148 |
logger.info(f"Deleted ChromaDB collection: {DB_NAME}")
|
149 |
except Exception as e:
|
150 |
logger.warning(f"Failed to delete collection {DB_NAME}: {e}")
|
151 |
+
collection = client.create_collection(DB_NAME)
|
152 |
logger.info(f"Created fresh ChromaDB collection: {DB_NAME}")
|
153 |
+
# Verify collection creation by checking if it's iterable (fix for 'NoneType' error)
|
154 |
+
if collection is None or not hasattr(collection, 'add'):
|
155 |
+
raise ValueError("ChromaDB collection creation failed")
|
156 |
return render_template(
|
157 |
'results_partial.html',
|
158 |
parts=None,
|