Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Close embeddings in tests

davidmezzettia3542086b487
diff --git a/test/python/testdatabase/testembeddings.py b/test/python/testdatabase/testembeddings.py
index bdf425f4..a3108cac 100644
--- a/test/python/testdatabase/testembeddings.py
+++ b/test/python/testdatabase/testembeddings.py
@@ -35,6 +35,15 @@ class TestEmbeddings(unittest.TestCase):
# Create embeddings model, backed by sentence-transformers & transformers
cls.embeddings = Embeddings({"path": "sentence-transformers/nli-mpnet-base-v2", "content": True})
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Cleanup data.
+ """
+
+ if cls.embeddings:
+ cls.embeddings.close()
+
def testArchive(self):
"""
Tests embeddings index archiving
diff --git a/test/python/testdatabase/testencoder.py b/test/python/testdatabase/testencoder.py
index a111e77c..d02b9c24 100644
--- a/test/python/testdatabase/testencoder.py
+++ b/test/python/testdatabase/testencoder.py
@@ -37,6 +37,15 @@ class TestEncoder(unittest.TestCase):
{"method": "sentence-transformers", "path": "sentence-transformers/clip-ViT-B-32", "content": True, "objects": "image"}
)
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Cleanup data.
+ """
+
+ if cls.embeddings:
+ cls.embeddings.close()
+
def testDefault(self):
"""
Tests an index with default encoder
diff --git a/test/python/testembeddings.py b/test/python/testembeddings.py
index 4be52409..469859d7 100644
--- a/test/python/testembeddings.py
+++ b/test/python/testembeddings.py
@@ -33,6 +33,15 @@ class TestEmbeddings(unittest.TestCase):
# Create embeddings model, backed by sentence-transformers & transformers
cls.embeddings = Embeddings({"path": "sentence-transformers/nli-mpnet-base-v2"})
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Cleanup data.
+ """
+
+ if cls.embeddings:
+ cls.embeddings.close()
+
def testDelete(self):
"""
Test delete
diff --git a/test/python/testpipeline/testextractor.py b/test/python/testpipeline/testextractor.py
index 448f5814..01cf5c6c 100644
--- a/test/python/testpipeline/testextractor.py
+++ b/test/python/testpipeline/testextractor.py
@@ -41,6 +41,15 @@ class TestExtractor(unittest.TestCase):
# Create extractor instance
cls.extractor = Extractor(cls.embeddings, "distilbert-base-cased-distilled-squad")
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Cleanup data.
+ """
+
+ if cls.embeddings:
+ cls.embeddings.close()
+
def testAnswer(self):
"""
Test qa extraction with an answer