Skip to content

Commit 0c99aa7

Browse files
committed
fixed chromaDB version import error in production
1 parent b474cef commit 0c99aa7

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

docker_image/src/app_api_handler.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
import logging
21
import os
2+
import sys
3+
4+
# Swap sqlite3 with pysqlite3 before any ChromaDB import (ChromaDB checks sqlite3 version at import time)
5+
if os.environ.get("IS_USING_IMAGE_RUNTIME"):
6+
try:
7+
__import__("pysqlite3")
8+
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
9+
except ImportError:
10+
pass
11+
12+
import logging
313
from pathlib import Path
414

515
from dotenv import load_dotenv
-73.9 KB
Binary file not shown.

docker_image/src/rag_app/get_chroma_db.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ def get_chroma_db():
2222

2323
# In Lambda runtime, I copied ChromaDB to /tmp so it can have write permissions.
2424
if IS_USING_IMAGE_RUNTIME:
25-
try:
26-
__import__("pysqlite3")
27-
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
28-
except ImportError:
29-
logger.warning("pysqlite3 not available, using default sqlite3")
3025
copy_chroma_to_tmp()
3126

3227
try:

0 commit comments

Comments
 (0)