Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Update tests to improve memory cleanup

davidmezzettid21d00acc5ab
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3b154ca2..721b06bb 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -8,7 +8,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
- os: [ubuntu-latest, macos-10.15, windows-latest]
+ os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
@@ -27,7 +27,7 @@ jobs:
run: |
brew install libomp
pip install annoy==1.16.3
- if: matrix.os == 'macos-10.15'
+ if: matrix.os == 'macos-latest'
- name: Install dependencies - Windows
run: choco install wget
diff --git a/test/python/testpipeline/testentity.py b/test/python/testpipeline/testentity.py
index 2d49b963..1335de82 100644
--- a/test/python/testpipeline/testentity.py
+++ b/test/python/testpipeline/testentity.py
@@ -14,8 +14,20 @@ class TestEntity(unittest.TestCase):
@classmethod
def setUpClass(cls):
+ """
+ Create entity instance.
+ """
+
cls.entity = Entity("dslim/bert-base-NER")
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Cleanup data.
+ """
+
+ cls.entity = None
+
def testEntity(self):
"""
Test entity
diff --git a/test/python/testpipeline/testextractor.py b/test/python/testpipeline/testextractor.py
index 01cf5c6c..6dfc01d7 100644
--- a/test/python/testpipeline/testextractor.py
+++ b/test/python/testpipeline/testextractor.py
@@ -50,6 +50,8 @@ class TestExtractor(unittest.TestCase):
if cls.embeddings:
cls.embeddings.close()
+ cls.extractor = None
+
def testAnswer(self):
"""
Test qa extraction with an answer
diff --git a/test/python/testpipeline/testlabels.py b/test/python/testpipeline/testlabels.py
index cb46599b..57178d08 100644
--- a/test/python/testpipeline/testlabels.py
+++ b/test/python/testpipeline/testlabels.py
@@ -30,6 +30,15 @@ class TestLabels(unittest.TestCase):
cls.labels = Labels("prajjwal1/bert-medium-mnli")
cls.similarity = Similarity(model=cls.labels)
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Cleanup data.
+ """
+
+ cls.labels = None
+ cls.similarity = None
+
def testLabel(self):
"""
Test labels with single text input
diff --git a/test/python/testpipeline/testsummary.py b/test/python/testpipeline/testsummary.py
index 8d51f88d..ac5a82dd 100644
--- a/test/python/testpipeline/testsummary.py
+++ b/test/python/testpipeline/testsummary.py
@@ -15,7 +15,7 @@ class TestSummary(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""
- Create single summary instance
+ Create single summary instance.
"""
cls.text = (
@@ -29,6 +29,14 @@ class TestSummary(unittest.TestCase):
cls.summary = Summary("t5-small")
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Cleanup data.
+ """
+
+ cls.summary = None
+
def testSummary(self):
"""
Test summarization of text
diff --git a/test/python/testvectors/testtransformers.py b/test/python/testvectors/testtransformers.py
index 85c065dd..6d28cbb0 100644
--- a/test/python/testvectors/testtransformers.py
+++ b/test/python/testvectors/testtransformers.py
@@ -23,6 +23,14 @@ class TestTransformersVectors(unittest.TestCase):
cls.model = VectorsFactory.create({"path": "sentence-transformers/nli-mpnet-base-v2"}, None)
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Cleanup data
+ """
+
+ cls.model = None
+
def testIndex(self):
"""
Test transformers indexing