phaethon-order commited on
Commit
32d948f
·
unverified ·
1 Parent(s): 3a4d792

Set writable cache directory for ChromaDB and update file opening mode for home write test

Browse files
Files changed (1) hide show
  1. infrastructure/database.py +7 -1
infrastructure/database.py CHANGED
@@ -27,6 +27,12 @@ SEG_VER = int(os.getenv("SEG_VER", "1"))
27
  # ---------------------------------------------------------------------------
28
  # ChromaDB client setup (with HuggingFace / read-only filesystem resilience)
29
  # ---------------------------------------------------------------------------
 
 
 
 
 
 
30
  CHROMA_PATH = os.getenv("CHROMA_PATH", "/data/chroma_db")
31
 
32
  def _init_chroma_client():
@@ -79,7 +85,7 @@ def _ensure_writable_caches(): # pragma: no cover (env specific)
79
  try:
80
  os.makedirs(cand, exist_ok=True)
81
  test_path = os.path.join(cand, ".home_write_test")
82
- with open(test_path, "w", encoding="utf-8") as f:
83
  f.write("ok")
84
  os.remove(test_path)
85
  os.environ["HOME"] = cand
 
27
  # ---------------------------------------------------------------------------
28
  # ChromaDB client setup (with HuggingFace / read-only filesystem resilience)
29
  # ---------------------------------------------------------------------------
30
+ # Set a writable cache directory for ChromaDB
31
+ CACHE_DIR = "/data/chroma_cache"
32
+ os.environ["CHROMA_CACHE_DIR"] = CACHE_DIR
33
+ if not os.path.exists(CACHE_DIR):
34
+ os.makedirs(CACHE_DIR)
35
+
36
  CHROMA_PATH = os.getenv("CHROMA_PATH", "/data/chroma_db")
37
 
38
  def _init_chroma_client():
 
85
  try:
86
  os.makedirs(cand, exist_ok=True)
87
  test_path = os.path.join(cand, ".home_write_test")
88
+ with open(test_path, "a", encoding="utf-8") as f:
89
  f.write("ok")
90
  os.remove(test_path)
91
  os.environ["HOME"] = cand