cleanup pysqlite imports and chroma errors - fix tests

This commit is contained in:
Jason Hunter 2023-12-19 02:29:41 -05:00
parent 45d1c51d8d
commit 3da86df9f6
4 changed files with 24 additions and 14 deletions

View File

@ -1,9 +1,3 @@
# This is required to satisfy the chromadb dependency
__import__("pysqlite3")
import sys # noqa: E402
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
import faulthandler # noqa: E402 import faulthandler # noqa: E402
import threading # noqa: E402 import threading # noqa: E402

View File

@ -3,12 +3,22 @@ import base64
import io import io
import logging import logging
import os import os
import sys
import time import time
import numpy as np import numpy as np
from chromadb import Collection
from chromadb import HttpClient as ChromaClient try:
from chromadb.config import Settings from chromadb import Collection
from chromadb import HttpClient as ChromaClient
from chromadb.config import Settings
except RuntimeError:
__import__("pysqlite3")
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
from chromadb import Collection
from chromadb import HttpClient as ChromaClient
from chromadb.config import Settings
from PIL import Image from PIL import Image
from playhouse.shortcuts import model_to_dict from playhouse.shortcuts import model_to_dict

View File

@ -1,5 +0,0 @@
# This is required to satisfy the chromadb dependency
__import__("pysqlite3")
import sys # noqa: E402
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")

View File

@ -121,6 +121,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
id = "123456.random" id = "123456.random"
id2 = "7890.random" id2 = "7890.random"
@ -157,6 +158,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
id = "123456.random" id = "123456.random"
@ -178,6 +180,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
id = "123456.random" id = "123456.random"
bad_id = "654321.other" bad_id = "654321.other"
@ -198,6 +201,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
id = "123456.random" id = "123456.random"
@ -220,6 +224,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
id = "123456.random" id = "123456.random"
@ -246,6 +251,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
morning_id = "123456.random" morning_id = "123456.random"
evening_id = "654321.random" evening_id = "654321.random"
@ -284,6 +290,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
id = "123456.random" id = "123456.random"
sub_label = "sub" sub_label = "sub"
@ -319,6 +326,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
id = "123456.random" id = "123456.random"
sub_label = "sub" sub_label = "sub"
@ -344,6 +352,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
with app.test_client() as client: with app.test_client() as client:
@ -361,6 +370,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
id = "123456.random" id = "123456.random"
@ -381,6 +391,7 @@ class TestHttp(unittest.TestCase):
None, None,
None, None,
PlusApi(), PlusApi(),
None,
) )
mock_stats.return_value = self.test_stats mock_stats.return_value = self.test_stats