Spaces:
Running
Running
Refactor dataset.py: Replace print statements with logger.debug for better logging during upload checks and add error logging for upload failures.
Browse files
src/knowledge_base/dataset.py
CHANGED
|
@@ -22,8 +22,6 @@ from config.settings import (
|
|
| 22 |
DATASET_FINE_TUNED_PATH,
|
| 23 |
DATASET_ANNOTATIONS_PATH
|
| 24 |
)
|
| 25 |
-
from langchain_huggingface import HuggingFaceEmbeddings
|
| 26 |
-
import logging
|
| 27 |
|
| 28 |
logger = logging.getLogger(__name__)
|
| 29 |
|
|
@@ -197,9 +195,9 @@ def get_last_update_date(self):
|
|
| 197 |
config_path = os.path.join(temp_dir, "index.pkl")
|
| 198 |
|
| 199 |
# Add debug logging
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
|
| 204 |
if not os.path.exists(index_path) or not os.path.exists(config_path):
|
| 205 |
return False, "Vector store files not created"
|
|
@@ -284,6 +282,7 @@ def get_last_update_date(self):
|
|
| 284 |
return True, "Vector store uploaded successfully"
|
| 285 |
|
| 286 |
except Exception as e:
|
|
|
|
| 287 |
return False, f"Error uploading vector store: {str(e)}"
|
| 288 |
|
| 289 |
def download_vector_store(self) -> Tuple[bool, Union[FAISS, str]]:
|
|
|
|
| 22 |
DATASET_FINE_TUNED_PATH,
|
| 23 |
DATASET_ANNOTATIONS_PATH
|
| 24 |
)
|
|
|
|
|
|
|
| 25 |
|
| 26 |
logger = logging.getLogger(__name__)
|
| 27 |
|
|
|
|
| 195 |
config_path = os.path.join(temp_dir, "index.pkl")
|
| 196 |
|
| 197 |
# Add debug logging
|
| 198 |
+
logger.debug(f"Checking files before upload:")
|
| 199 |
+
logger.debug(f"index.faiss exists: {os.path.exists(index_path)}, size: {os.path.getsize(index_path) if os.path.exists(index_path) else 0} bytes")
|
| 200 |
+
logger.debug(f"index.pkl exists: {os.path.exists(config_path)}, size: {os.path.getsize(config_path) if os.path.exists(config_path) else 0} bytes")
|
| 201 |
|
| 202 |
if not os.path.exists(index_path) or not os.path.exists(config_path):
|
| 203 |
return False, "Vector store files not created"
|
|
|
|
| 282 |
return True, "Vector store uploaded successfully"
|
| 283 |
|
| 284 |
except Exception as e:
|
| 285 |
+
logger.error(f"Error uploading vector store: {str(e)}")
|
| 286 |
return False, f"Error uploading vector store: {str(e)}"
|
| 287 |
|
| 288 |
def download_vector_store(self) -> Tuple[bool, Union[FAISS, str]]:
|