James Edmunds commited on
Commit
8b9b46c
·
1 Parent(s): aede054

more path fixes

Browse files
Files changed (1) hide show
  1. src/generator/generator.py +12 -11
src/generator/generator.py CHANGED
@@ -84,22 +84,14 @@ class LyricGenerator:
84
  self._setup_embeddings_from_hf()
85
 
86
  # Dynamically determine the correct chroma directory
87
- possible_dirs = ["/data/.huggingface/chroma"]
88
- chroma_dir = None
89
- for dir_path in possible_dirs:
90
- if Path(dir_path).exists():
91
- chroma_dir = Path(dir_path)
92
- break
93
-
94
  if chroma_dir is None:
95
- raise RuntimeError(
96
- "Chroma directory not found in any expected location.")
97
 
98
  else:
99
  print("Local environment detected")
100
  print(f"Base directory: {Settings.BASE_DIR}")
101
- # Local environment path
102
- chroma_dir = Path("/data/processed/embeddings/chroma")
103
 
104
  print(f"Checking Chroma directory: {chroma_dir}")
105
  print(f"Absolute path: {chroma_dir.absolute()}")
@@ -165,6 +157,15 @@ class LyricGenerator:
165
  # Setup QA chain
166
  self._setup_qa_chain()
167
 
 
 
 
 
 
 
 
 
 
168
  def _setup_qa_chain(self) -> None:
169
  """Initialize the QA chain for generating lyrics"""
170
  # Configure retriever with a more reasonable number of documents
 
84
  self._setup_embeddings_from_hf()
85
 
86
  # Dynamically determine the correct chroma directory
87
+ chroma_dir = self._find_chroma_directory("/data")
 
 
 
 
 
 
88
  if chroma_dir is None:
89
+ raise RuntimeError("Chroma directory not found in any expected location.")
 
90
 
91
  else:
92
  print("Local environment detected")
93
  print(f"Base directory: {Settings.BASE_DIR}")
94
+ chroma_dir = Path("/data/processed/embeddings/chroma") # Local environment path
 
95
 
96
  print(f"Checking Chroma directory: {chroma_dir}")
97
  print(f"Absolute path: {chroma_dir.absolute()}")
 
157
  # Setup QA chain
158
  self._setup_qa_chain()
159
 
160
+ def _find_chroma_directory(self, base_path: str) -> Path:
161
+ """Find the Chroma directory within the base path"""
162
+ base_dir = Path(base_path)
163
+ for subdir in base_dir.iterdir():
164
+ if subdir.is_dir() and (subdir / "chroma.sqlite3").exists():
165
+ print(f"Chroma directory found: {subdir}")
166
+ return subdir
167
+ return None
168
+
169
  def _setup_qa_chain(self) -> None:
170
  """Initialize the QA chain for generating lyrics"""
171
  # Configure retriever with a more reasonable number of documents