From 3979d3cb08e0cc1ae3095d7af60acdbd73cb77a0 Mon Sep 17 00:00:00 2001 From: Trayan Azarov Date: Fri, 6 Oct 2023 14:53:41 +0300 Subject: [PATCH] fix: Python Client SQLite import - Added conditional import and check of SQLite version in __init__.py for chromadb-client Refs: #1206 --- chromadb/__init__.py | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/chromadb/__init__.py b/chromadb/__init__.py index aa5a3edd7ea4..ffc32392e075 100644 --- a/chromadb/__init__.py +++ b/chromadb/__init__.py @@ -1,6 +1,5 @@ from typing import Dict import logging -import sqlite3 import chromadb.config from chromadb.config import Settings, System from chromadb.api import API @@ -54,22 +53,31 @@ except ImportError: IN_COLAB = False -if sqlite3.sqlite_version_info < (3, 35, 0): - if IN_COLAB: - # In Colab, hotswap to pysqlite-binary if it's too old - import subprocess - import sys - - subprocess.check_call( - [sys.executable, "-m", "pip", "install", "pysqlite3-binary"] - ) - __import__("pysqlite3") - sys.modules["sqlite3"] = sys.modules.pop("pysqlite3") - else: - raise RuntimeError( - "\033[91mYour system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0.\033[0m\n" - "\033[94mPlease visit https://docs.trychroma.com/troubleshooting#sqlite to learn how to upgrade.\033[0m" - ) +is_client = False +try: + from chromadb.is_thin_client import is_thin_client # type: ignore + is_client = is_thin_client +except ImportError: + is_client = False + +if not is_client: + import sqlite3 + if sqlite3.sqlite_version_info < (3, 35, 0): + if IN_COLAB: + # In Colab, hotswap to pysqlite-binary if it's too old + import subprocess + import sys + + subprocess.check_call( + [sys.executable, "-m", "pip", "install", "pysqlite3-binary"] + ) + __import__("pysqlite3") + sys.modules["sqlite3"] = sys.modules.pop("pysqlite3") + else: + raise RuntimeError( + "\033[91mYour system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0.\033[0m\n" + "\033[94mPlease visit https://docs.trychroma.com/troubleshooting#sqlite to learn how to upgrade.\033[0m" + ) def configure(**kwargs) -> None: # type: ignore