Spaces:
Running
Running
add
Browse files
infrastructure/database.py
CHANGED
|
@@ -102,6 +102,7 @@ def _init_chroma_client():
|
|
| 102 |
test_file = os.path.join(path, ".write_test")
|
| 103 |
with open(test_file, "a", encoding="utf-8") as tf:
|
| 104 |
tf.write("ok")
|
|
|
|
| 105 |
os.remove(test_file)
|
| 106 |
return True
|
| 107 |
except Exception as e: # pragma: no cover - env specific
|
|
@@ -149,7 +150,9 @@ def _init_chroma_client():
|
|
| 149 |
test_coll_name = f"_rw_test_{int(time.time()*1000)}"
|
| 150 |
try:
|
| 151 |
tc = client.get_or_create_collection(name=test_coll_name, embedding_function=default_ef) # type: ignore
|
|
|
|
| 152 |
tc.add(ids=["0"], metadatas=[{"t": "x"}], documents=["test"])
|
|
|
|
| 153 |
client.delete_collection(name=test_coll_name)
|
| 154 |
_logger.info(f"Successfully connected with write access at {abs_path}")
|
| 155 |
return client
|
|
|
|
| 102 |
test_file = os.path.join(path, ".write_test")
|
| 103 |
with open(test_file, "a", encoding="utf-8") as tf:
|
| 104 |
tf.write("ok")
|
| 105 |
+
_logger.info(f"Directory {path} is writable.")
|
| 106 |
os.remove(test_file)
|
| 107 |
return True
|
| 108 |
except Exception as e: # pragma: no cover - env specific
|
|
|
|
| 150 |
test_coll_name = f"_rw_test_{int(time.time()*1000)}"
|
| 151 |
try:
|
| 152 |
tc = client.get_or_create_collection(name=test_coll_name, embedding_function=default_ef) # type: ignore
|
| 153 |
+
_logger.info(f"Successfully created test collection {test_coll_name} at {abs_path}")
|
| 154 |
tc.add(ids=["0"], metadatas=[{"t": "x"}], documents=["test"])
|
| 155 |
+
_logger.info(f"Successfully added to test collection {test_coll_name} at {abs_path}")
|
| 156 |
client.delete_collection(name=test_coll_name)
|
| 157 |
_logger.info(f"Successfully connected with write access at {abs_path}")
|
| 158 |
return client
|