James Edmunds commited on
Commit ·
01f3780
1
Parent(s): 576366e
feat: add detailed Chroma DB debugging and file structure validation
Browse files- src/generator/generator.py +21 -3
src/generator/generator.py
CHANGED
|
@@ -40,12 +40,20 @@ class LyricGenerator:
|
|
| 40 |
))
|
| 41 |
print(f"Dataset downloaded to: {local_dir}")
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# Check if chroma directory exists
|
| 44 |
chroma_dir = local_dir / "chroma"
|
| 45 |
if not chroma_dir.exists():
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
)
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
print(f"Loading Chroma DB from: {chroma_dir}")
|
| 51 |
# Initialize vector store from the cached location
|
|
@@ -61,6 +69,16 @@ class LyricGenerator:
|
|
| 61 |
count = collection.count()
|
| 62 |
print(f"Collection contains {count} documents")
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
except Exception as e:
|
| 65 |
print(f"Error loading HF embeddings: {str(e)}")
|
| 66 |
raise RuntimeError(f"Failed to load HF embeddings: {str(e)}")
|
|
|
|
| 40 |
))
|
| 41 |
print(f"Dataset downloaded to: {local_dir}")
|
| 42 |
|
| 43 |
+
# List contents to debug
|
| 44 |
+
print("Contents of downloaded directory:")
|
| 45 |
+
for path in local_dir.rglob("*"):
|
| 46 |
+
print(f" {path}")
|
| 47 |
+
|
| 48 |
# Check if chroma directory exists
|
| 49 |
chroma_dir = local_dir / "chroma"
|
| 50 |
if not chroma_dir.exists():
|
| 51 |
+
# Try looking in the root
|
| 52 |
+
chroma_dir = local_dir
|
| 53 |
+
if not (chroma_dir / "chroma.sqlite3").exists():
|
| 54 |
+
raise RuntimeError(
|
| 55 |
+
f"Chroma files not found in {local_dir}"
|
| 56 |
+
)
|
| 57 |
|
| 58 |
print(f"Loading Chroma DB from: {chroma_dir}")
|
| 59 |
# Initialize vector store from the cached location
|
|
|
|
| 69 |
count = collection.count()
|
| 70 |
print(f"Collection contains {count} documents")
|
| 71 |
|
| 72 |
+
if count == 0:
|
| 73 |
+
# Try listing collections
|
| 74 |
+
print("Available collections:")
|
| 75 |
+
print(collection.list_collections())
|
| 76 |
+
|
| 77 |
+
raise RuntimeError(
|
| 78 |
+
"Chroma DB is empty. Please ensure embeddings were "
|
| 79 |
+
"properly uploaded to the dataset."
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
except Exception as e:
|
| 83 |
print(f"Error loading HF embeddings: {str(e)}")
|
| 84 |
raise RuntimeError(f"Failed to load HF embeddings: {str(e)}")
|