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

davidmezzetti5aeefc3ab8eb
diff --git a/test/python/testann.py b/test/python/testann.py
index d0ca9337..c3ccec10 100644
--- a/test/python/testann.py
+++ b/test/python/testann.py
@@ -59,7 +59,7 @@ class TestANN(unittest.TestCase):
"""
# Test with custom settings
- self.runTests("faiss", {"faiss": {"nprobe": 2, "components": "PCA16,IDMap,SQ8"}}, False)
+ self.runTests("faiss", {"faiss": {"nprobe": 2, "components": "PCA16,IDMap,SQ8", "sample": 1.0}}, False)
@unittest.skipIf(os.name == "nt", "mmap not supported on Windows")
def testFaissMmap(self):
@@ -87,7 +87,7 @@ class TestANN(unittest.TestCase):
def testNotImplemented(self):
"""
- Tests exceptions for non-implemented methods
+ Test exceptions for non-implemented methods
"""
ann = ANN({})
diff --git a/test/python/testapi/testextension.py b/test/python/testapi/testextension.py
index 04f3f906..4e21dddb 100644
--- a/test/python/testapi/testextension.py
+++ b/test/python/testapi/testextension.py
@@ -100,7 +100,7 @@ class TestExtension(unittest.TestCase):
def testEmpty(self):
"""
- Tests an empty extension
+ Test an empty extension
"""
extension = Extension()
@@ -108,7 +108,7 @@ class TestExtension(unittest.TestCase):
def testExtension(self):
"""
- Tests a pipeline extension
+ Test a pipeline extension
"""
text = self.client.get("sample?text=Test%20String").json()
diff --git a/test/python/testapp.py b/test/python/testapp.py
index 4f153dd1..41102699 100644
--- a/test/python/testapp.py
+++ b/test/python/testapp.py
@@ -14,7 +14,7 @@ class TestApp(unittest.TestCase):
def testConfig(self):
"""
- Tests a file not found config exception
+ Test a file not found config exception
"""
with self.assertRaises(FileNotFoundError):
diff --git a/test/python/testcompress.py b/test/python/testarchive.py
similarity index 80%
rename from test/python/testcompress.py
rename to test/python/testarchive.py
index 58e9ab44..b199586d 100644
--- a/test/python/testcompress.py
+++ b/test/python/testarchive.py
@@ -9,15 +9,15 @@ import unittest
from zipfile import ZipFile, ZIP_DEFLATED
-from txtai.compress import Compress, CompressFactory
+from txtai.archive import ArchiveFactory, Compress
# pylint: disable = C0411
from utils import Utils
-class TestCompress(unittest.TestCase):
+class TestArchive(unittest.TestCase):
"""
- Compress tests.
+ Archive tests.
"""
def testInvalidTar(self):
@@ -29,11 +29,11 @@ class TestCompress(unittest.TestCase):
with tarfile.open(path, "w") as tar:
tar.add(Utils.PATH, arcname="..")
- compress = CompressFactory.create("tar")
+ archive = ArchiveFactory.create(path)
# Validate error is thrown for file
with self.assertRaises(IOError):
- compress.unpack(path, path)
+ archive.load(path, "tar")
def testInvalidZip(self):
"""
@@ -44,11 +44,11 @@ class TestCompress(unittest.TestCase):
with ZipFile(path, "w", ZIP_DEFLATED) as zfile:
zfile.write(Utils.PATH + "/article.pdf", arcname="../article.pdf")
- compress = CompressFactory.create("zip")
+ archive = ArchiveFactory.create(path)
# Validate error is thrown for file
with self.assertRaises(IOError):
- compress.unpack(path, path)
+ archive.load(path, "zip")
def testNotImplemented(self):
"""
diff --git a/test/python/testcloud.py b/test/python/testcloud.py
new file mode 100644
index 00000000..29d664f9
--- /dev/null
+++ b/test/python/testcloud.py
@@ -0,0 +1,163 @@
+"""
+Cloud module tests
+"""
+
+import os
+import tempfile
+import time
+import unittest
+
+from unittest.mock import patch
+
+from txtai.cloud import Cloud
+from txtai.embeddings import Embeddings
+
+
+class TestCloud(unittest.TestCase):
+ """
+ Cloud tests.
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ """
+ Initialize test data.
+ """
+
+ cls.data = [
+ "US tops 5 million confirmed virus cases",
+ "Canada's last fully intact ice shelf has suddenly collapsed, forming a Manhattan-sized iceberg",
+ "Beijing mobilises invasion craft along coast as Taiwan tensions escalate",
+ "The National Park Service warns against sacrificing slower friends in a bear attack",
+ "Maine man wins $1M from $25 lottery ticket",
+ "Make huge profits without work, earn up to $100,000 a day",
+ ]
+
+ # Create embeddings model, backed by sentence-transformers & transformers
+ cls.embeddings = Embeddings({"format": "json", "path": "sentence-transformers/nli-mpnet-base-v2", "content": True})
+
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Cleanup data.
+ """
+
+ if cls.embeddings:
+ cls.embeddings.close()
+
+ def testCustom(self):
+ """
+ Test custom provider
+ """
+
+ # pylint: disable=E1120
+ self.runHub("txtai.cloud.HuggingFaceHub")
+
+ def testHub(self):
+ """
+ Test huggingface-hub integration
+ """
+
+ # pylint: disable=E1120
+ self.runHub("huggingface-hub")
+
+ def testInvalidProvider(self):
+ """
+ Test invalid provider identifier
+ """
+
+ # Test invalid external provider
+ with self.assertRaises(ImportError):
+ embeddings = Embeddings()
+ embeddings.load(provider="ProviderNoExist", container="Invalid")
+
+ def testNotImplemented(self):
+ """
+ Test exceptions for non-implemented methods
+ """
+
+ cloud = Cloud({})
+
+ self.assertRaises(NotImplementedError, cloud.exists, None)
+ self.assertRaises(NotImplementedError, cloud.load, None)
+ self.assertRaises(NotImplementedError, cloud.save, None)
+
+ def testObjectStorage(self):
+ """
+ Test object storage integration
+ """
+
+ # Run tests with uncompressed and compressed index
+ for path in ["cloud.object", "cloud.object.tar.gz"]:
+ self.runTests(path, {"provider": "local", "container": f"cloud.{time.time()}", "key": tempfile.gettempdir()})
+
+ @patch("huggingface_hub.hf_hub_download")
+ @patch("huggingface_hub.get_hf_file_metadata")
+ @patch("huggingface_hub.upload_file")
+ @patch("huggingface_hub.create_repo")
+ def runHub(self, provider, create, upload, metadata, download):
+ """
+ Run huggingface-hub tests. This method mocks write operations since a token won't be available.
+ """
+
+ def filemeta(url, token):
+ return (url, token) if "Invalid" not in url else None
+
+ def filedownload(**kwargs):
+ if "Invalid" in kwargs["repo_id"]:
+ raise Exception
+
+ return index
+
+ # Patch write methods since token will not be available
+ create.return_value = None
+ upload.return_value = None
+ metadata.side_effect = filemeta
+ download.side_effect = filedownload
+
+ # Create dummy index
+ self.embeddings.index([(uid, text, None) for uid, text in enumerate(self.data)])
+
+ # Generate temp file path
+ index = os.path.join(tempfile.gettempdir(), f"cloud.{provider}.tar.gz")
+ self.embeddings.save(index)
+
+ # Run tests with uncompressed and compressed index
+ for path in [f"cloud.{provider}", f"cloud.{provider}.tar.gz"]:
+ self.runTests(path, {"provider": provider, "container": "neuml/txtai-intro"})
+
+ def runTests(self, path, cloud):
+ """
+ Runs a series of cloud sync tests.
+ """
+
+ # Create an index for the list of text
+ self.embeddings.index([(uid, text, None) for uid, text in enumerate(self.data)])
+
+ # Generate temp file path
+ index = os.path.join(tempfile.gettempdir(), path)
+
+ # Test exists handles missing cloud storage object
+ invalid = cloud.copy()
+ invalid["container"] = "InvalidPathToTest"
+ self.assertFalse(self.embeddings.exists(index, invalid))
+
+ # Test exception raised when trying to load index and doesn't exist in cloud storage
+ with self.assertRaises(Exception):
+ self.embeddings.load(index, invalid)
+
+ # Save index
+ self.embeddings.save(index, cloud)
+
+ # Test object exists in cloud storage
+ self.assertTrue(self.embeddings.exists(index, cloud))
+
+ # Test object exists locally
+ self.assertTrue(self.embeddings.exists(index))
+
+ # Test index can be reloaded
+ self.embeddings.load(index, cloud)
+
+ # Search for best match
+ result = self.embeddings.search("feel good story", 1)[0]
+ self.assertEqual(result["text"], self.data[4])
diff --git a/test/python/testdatabase/testembeddings.py b/test/python/testdatabase/testembeddings.py
index f22546e4..f695a3bf 100644
--- a/test/python/testdatabase/testembeddings.py
+++ b/test/python/testdatabase/testembeddings.py
@@ -6,11 +6,8 @@ import contextlib
import io
import os
import tempfile
-import time
import unittest
-from libcloud.storage.types import ContainerDoesNotExistError, ObjectDoesNotExistError
-
from txtai.embeddings import Embeddings
from txtai.database import Database, SQLError
@@ -50,7 +47,7 @@ class TestEmbeddings(unittest.TestCase):
def testArchive(self):
"""
- Tests embeddings index archiving
+ Test embeddings index archiving
"""
for extension in ["tar.bz2", "tar.gz", "tar.xz", "zip"]:
@@ -72,46 +69,9 @@ class TestEmbeddings(unittest.TestCase):
self.embeddings.upsert([(0, "Looking out into the dreadful abyss", None)])
self.assertEqual(self.embeddings.count(), len(self.data))
- def testArchiveCloud(self):
- """
- Tests embeddings index archiving with cloud storage
- """
-
- # Create an index for the list of text
- self.embeddings.index([(uid, text, None) for uid, text in enumerate(self.data)])
-
- # Generate temp file path
- index = os.path.join(tempfile.gettempdir(), "cloud.tar.gz")
-
- # Test save with local cloud provider
- cloud = {"provider": "local", "container": f"cloud.{time.time()}", "key": tempfile.gettempdir()}
-
- # Test exists handles missing cloud storage object
- self.assertFalse(self.embeddings.exists(index, cloud))
-
- # Test exception raised when trying to load index and doesn't exist in cloud storage
- with self.assertRaises((ContainerDoesNotExistError, ObjectDoesNotExistError)):
- self.embeddings.load(index, cloud)
-
- # Save index
- self.embeddings.save(index, cloud)
-
- # Test object exists in cloud storage
- self.assertTrue(self.embeddings.exists(index, cloud))
-
- # Test object exists locally
- self.assertTrue(self.embeddings.exists(index))
-
- # Test index can be reloaded
- self.embeddings.load(index, cloud)
-
- # Search for best match
- result = self.embeddings.search("feel good story", 1)[0]
- self.assertEqual(result["text"], self.data[4])
-
def testClose(self):
"""
- Tests embeddings close
+ Test embeddings close
"""
embeddings = None
@@ -290,6 +250,22 @@ class TestEmbeddings(unittest.TestCase):
self.assertIn("txtai", output.getvalue())
+ def testInstructions(self):
+ """
+ Test indexing with instruction prefixes.
+ """
+
+ embeddings = Embeddings(
+ {"path": "sentence-transformers/nli-mpnet-base-v2", "content": True, "instructions": {"query": "query: ", "data": "passage: "}}
+ )
+
+ embeddings.index([(uid, text, None) for uid, text in enumerate(self.data)])
+
+ # Search for best match
+ result = embeddings.search("feel good story", 1)[0]
+
+ self.assertEqual(result["text"], self.data[4])
+
def testInvalidData(self):
"""
Test invalid JSON data
@@ -299,6 +275,33 @@ class TestEmbeddings(unittest.TestCase):
with self.assertRaises(ValueError):
self.embeddings.index([(0, {"text": "This is a test", "flag": float("NaN")}, None)])
+ def testJSON(self):
+ """
+ Test JSON configuration
+ """
+
+ embeddings = Embeddings(
+ {
+ "format": "json",
+ "path": "sentence-transformers/nli-mpnet-base-v2",
+ "content": True,
+ }
+ )
+
+ embeddings.index([(uid, text, None) for uid, text in enumerate(self.data)])
+
+ # Generate temp file path
+ index = os.path.join(tempfile.gettempdir(), "embeddings.json")
+
+ embeddings.save(index)
+
+ # Check that config.json exists
+ self.assertTrue(os.path.exists(os.path.join(index, "config.json")))
+
+ # Check that index can be reloaded
+ embeddings.load(index)
+ self.assertEqual(embeddings.count(), 6)
+
def testMultiData(self):
"""
Test indexing with multiple data types (text, documents)
@@ -321,7 +324,7 @@ class TestEmbeddings(unittest.TestCase):
def testMultiSave(self):
"""
- Tests multiple successive saves
+ Test multiple successive saves
"""
# Create an index for the list of text
@@ -355,7 +358,7 @@ class TestEmbeddings(unittest.TestCase):
def testNotImplemented(self):
"""
- Tests exceptions for non-implemented methods
+ Test exceptions for non-implemented methods
"""
database = Database({})
@@ -376,7 +379,7 @@ class TestEmbeddings(unittest.TestCase):
Test index
"""
- embeddings = Embeddings({"path": "sentence-transformers/nli-mpnet-base-v2", "content": True, "query": {"path": "NeuML/t5-small-txtsql"}})
+ embeddings = Embeddings({"path": "sentence-transformers/nli-mpnet-base-v2", "content": True, "query": {"path": "neuml/t5-small-txtsql"}})
# Create an index for the list of text
embeddings.index([(uid, text, None) for uid, text in enumerate(self.data)])
diff --git a/test/python/testdatabase/testencoder.py b/test/python/testdatabase/testencoder.py
index b2aad162..c7eb268d 100644
--- a/test/python/testdatabase/testencoder.py
+++ b/test/python/testdatabase/testencoder.py
@@ -1,5 +1,5 @@
"""
-Tests encoding/decoding database objects
+Test encoding/decoding database objects
"""
import glob
@@ -48,7 +48,7 @@ class TestEncoder(unittest.TestCase):
def testDefault(self):
"""
- Tests an index with default encoder
+ Test an index with default encoder
"""
try:
@@ -67,7 +67,7 @@ class TestEncoder(unittest.TestCase):
def testImages(self):
"""
- Tests an index with image encoder
+ Test an index with image encoder
"""
# Create an index for the list of images
@@ -80,7 +80,7 @@ class TestEncoder(unittest.TestCase):
def testPickle(self):
"""
- Tests an index with pickle encoder
+ Test an index with pickle encoder
"""
try:
@@ -99,7 +99,7 @@ class TestEncoder(unittest.TestCase):
def testReindex(self):
"""
- Tests reindex with objects
+ Test reindex with objects
"""
# Create an index for the list of images
@@ -115,7 +115,7 @@ class TestEncoder(unittest.TestCase):
def testReindexFunction(self):
"""
- Tests reindex with objects and a function
+ Test reindex with objects and a function
"""
try:
diff --git a/test/python/testdatabase/testsql.py b/test/python/testdatabase/testsql.py
index 9cf6e3fa..2c396703 100644
--- a/test/python/testdatabase/testsql.py
+++ b/test/python/testdatabase/testsql.py
@@ -9,7 +9,7 @@ from txtai.database import SQL, SQLError, SQLite
class TestSQL(unittest.TestCase):
"""
- Tests SQL parsing and generation.
+ Test SQL parsing and generation.
"""
@classmethod
@@ -140,7 +140,7 @@ class TestSQL(unittest.TestCase):
def testIsSQL(self):
"""
- Tests SQL detection method.
+ Test SQL detection method.
"""
self.assertTrue(self.sql.issql("select text from txtai where id = 1"))
@@ -238,7 +238,7 @@ class TestSQL(unittest.TestCase):
def testUpper(self):
"""
- Tests SQL statements are case insensitive.
+ Test SQL statements are case insensitive.
"""
self.assertSql("groupby", "SELECT * FROM TXTAI WHERE a = 1 GROUP BY id", "s.id")
diff --git a/test/python/testgraph.py b/test/python/testgraph.py
index 154bab0a..6ed7a3b1 100644
--- a/test/python/testgraph.py
+++ b/test/python/testgraph.py
@@ -156,7 +156,7 @@ class TestGraph(unittest.TestCase):
def testNotImplemented(self):
"""
- Tests exceptions for non-implemented methods
+ Test exceptions for non-implemented methods
"""
graph = Graph({})
@@ -206,7 +206,7 @@ class TestGraph(unittest.TestCase):
def testSimple(self):
"""
- Tests creating a simple graph
+ Test creating a simple graph
"""
graph = GraphFactory.create({"topics": {}})
diff --git a/test/python/testmodels.py b/test/python/testmodels.py
index f14dd73c..edffa4ae 100644
--- a/test/python/testmodels.py
+++ b/test/python/testmodels.py
@@ -17,7 +17,7 @@ class TestModels(unittest.TestCase):
@patch("torch.cuda.is_available")
def testDeviceid(self, cuda):
"""
- Tests the deviceid method
+ Test the deviceid method
"""
cuda.return_value = True
diff --git a/test/python/testoptional.py b/test/python/testoptional.py
index 432f4b68..bc227cf4 100644
--- a/test/python/testoptional.py
+++ b/test/python/testoptional.py
@@ -96,10 +96,10 @@ class TestOptional(unittest.TestCase):
Test missing cloud dependencies
"""
- from txtai.embeddings import Cloud
+ from txtai.cloud import ObjectStorage
with self.assertRaises(ImportError):
- Cloud(None)
+ ObjectStorage(None)
def testDatabase(self):
"""
diff --git a/test/python/testpipeline/testextractor.py b/test/python/testpipeline/testextractor.py
index b80a9039..36c9fb77 100644
--- a/test/python/testpipeline/testextractor.py
+++ b/test/python/testpipeline/testextractor.py
@@ -71,14 +71,14 @@ class TestExtractor(unittest.TestCase):
def testEmptyQuery(self):
"""
- Tests an empty extractor queries list
+ Test an empty extractor queries list
"""
self.assertEqual(self.extractor.query(None, None), [])
def testGeneration(self):
"""
- Tests support for generator models
+ Test support for generator models
"""
extractor = Extractor(self.embeddings, "facebook/opt-125m")
@@ -179,7 +179,7 @@ class TestExtractor(unittest.TestCase):
def testTasks(self):
"""
- Tests loading models with task parameter
+ Test loading models with task parameter
"""
for task, model in [
diff --git a/test/python/testpipeline/testquantization.py b/test/python/testpipeline/testquantization.py
index c65c1fc3..cda90179 100644
--- a/test/python/testpipeline/testquantization.py
+++ b/test/python/testpipeline/testquantization.py
@@ -18,7 +18,7 @@ class TestQuantization(unittest.TestCase):
@unittest.skipIf(platform.system() == "Darwin", "Quantized models not supported on macOS")
def testModel(self):
"""
- Tests quantizing a model through HFModel.
+ Test quantizing a model through HFModel.
"""
model = HFModel(quantize=True, gpu=False)
@@ -28,7 +28,7 @@ class TestQuantization(unittest.TestCase):
@unittest.skipIf(platform.system() == "Darwin", "Quantized models not supported on macOS")
def testPipeline(self):
"""
- Tests quantizing a model through HFPipeline.
+ Test quantizing a model through HFPipeline.
"""
pipeline = HFPipeline("text-classification", "google/bert_uncased_L-2_H-128_A-2", True, False)
diff --git a/test/python/testpipeline/testtabular.py b/test/python/testpipeline/testtabular.py
index cfb5bd63..9b633166 100644
--- a/test/python/testpipeline/testtabular.py
+++ b/test/python/testpipeline/testtabular.py
@@ -25,7 +25,7 @@ class TestTabular(unittest.TestCase):
def testContent(self):
"""
- Tests parsing additional content
+ Test parsing additional content
"""
tabular = Tabular("id", ["text"], True)
@@ -53,7 +53,7 @@ class TestTabular(unittest.TestCase):
def testCSV(self):
"""
- Tests parsing a CSV file
+ Test parsing a CSV file
"""
rows = self.tabular([Utils.PATH + "/tabular.csv"])
@@ -64,7 +64,7 @@ class TestTabular(unittest.TestCase):
def testDict(self):
"""
- Tests parsing a dict
+ Test parsing a dict
"""
rows = self.tabular([{"id": 0, "text": "This is a test"}])
@@ -75,7 +75,7 @@ class TestTabular(unittest.TestCase):
def testList(self):
"""
- Tests parsing a list
+ Test parsing a list
"""
rows = self.tabular([[{"id": 0, "text": "This is a test"}]])
@@ -86,7 +86,7 @@ class TestTabular(unittest.TestCase):
def testMissingColumns(self):
"""
- Tests rows with uneven or missing columns
+ Test rows with uneven or missing columns
"""
tabular = Tabular("id", ["text"], True)
@@ -101,7 +101,7 @@ class TestTabular(unittest.TestCase):
def testNoColumns(self):
"""
- Tests creating text without specifying columns
+ Test creating text without specifying columns
"""
tabular = Tabular("id")
diff --git a/test/python/testpipeline/testtextractor.py b/test/python/testpipeline/testtextractor.py
index c6569056..96b84535 100644
--- a/test/python/testpipeline/testtextractor.py
+++ b/test/python/testpipeline/testtextractor.py
@@ -17,7 +17,7 @@ class TestTextractor(unittest.TestCase):
def testBeautifulSoup(self):
"""
- Tests text extraction using Beautiful Soup
+ Test text extraction using Beautiful Soup
"""
textractor = Textractor(tika=False)
@@ -26,7 +26,7 @@ class TestTextractor(unittest.TestCase):
def testCheckJava(self):
"""
- Tests the checkjava method
+ Test the checkjava method
"""
textractor = Textractor()
@@ -34,7 +34,7 @@ class TestTextractor(unittest.TestCase):
def testLines(self):
"""
- Tests extraction to lines
+ Test extraction to lines
"""
textractor = Textractor(lines=True)
@@ -47,7 +47,7 @@ class TestTextractor(unittest.TestCase):
def testParagraphs(self):
"""
- Tests extraction to paragraphs
+ Test extraction to paragraphs
"""
textractor = Textractor(paragraphs=True)
@@ -60,7 +60,7 @@ class TestTextractor(unittest.TestCase):
def testSentences(self):
"""
- Tests extraction to sentences
+ Test extraction to sentences
"""
textractor = Textractor(sentences=True)
@@ -73,7 +73,7 @@ class TestTextractor(unittest.TestCase):
def testSingle(self):
"""
- Tests a single extraction with no tokenization of the results
+ Test a single extraction with no tokenization of the results
"""
textractor = Textractor()
diff --git a/test/python/testpipeline/testtexttospeech.py b/test/python/testpipeline/testtexttospeech.py
index 2c8ef6e2..e3fd249f 100644
--- a/test/python/testpipeline/testtexttospeech.py
+++ b/test/python/testpipeline/testtexttospeech.py
@@ -16,7 +16,7 @@ class TestTextToSpeech(unittest.TestCase):
def testTextToSpeech(self):
"""
- Tests generating speech for text
+ Test generating speech for text
"""
tts = TextToSpeech()
diff --git a/test/python/testpipeline/testtrainer.py b/test/python/testpipeline/testtrainer.py
index 0ec1f23b..b5afdc54 100644
--- a/test/python/testpipeline/testtrainer.py
+++ b/test/python/testpipeline/testtrainer.py
@@ -40,7 +40,7 @@ class TestTrainer(unittest.TestCase):
def testCLM(self):
"""
- Tests training a model with causal language modeling.
+ Test training a model with causal language modeling.
"""
trainer = HFTrainer()
@@ -179,14 +179,14 @@ class TestTrainer(unittest.TestCase):
def testEmpty(self):
"""
- Tests an empty training data object
+ Test an empty training data object
"""
self.assertIsNone(Data(None, None, None).process(None))
def testMLM(self):
"""
- Tests training a model with masked language modeling.
+ Test training a model with masked language modeling.
"""
trainer = HFTrainer()
@@ -197,7 +197,7 @@ class TestTrainer(unittest.TestCase):
def testMultiLabel(self):
"""
- Tests training model with labels provided as a list
+ Test training model with labels provided as a list
"""
data = []
@@ -212,7 +212,7 @@ class TestTrainer(unittest.TestCase):
def testQA(self):
"""
- Tests training a QA model
+ Test training a QA model
"""
# Training data
@@ -234,7 +234,7 @@ class TestTrainer(unittest.TestCase):
def testRegression(self):
"""
- Tests training a model with a regression (continuous) output
+ Test training a model with a regression (continuous) output
"""
data = []
@@ -251,7 +251,7 @@ class TestTrainer(unittest.TestCase):
def testRTD(self):
"""
- Tests training a language model with replaced token detection
+ Test training a language model with replaced token detection
"""
# Save directory
@@ -269,7 +269,7 @@ class TestTrainer(unittest.TestCase):
def testSeqSeq(self):
"""
- Tests training a sequence-sequence model
+ Test training a sequence-sequence model
"""
data = [
diff --git a/test/python/testpipeline/testtranslation.py b/test/python/testpipeline/testtranslation.py
index 7544097e..ef8a0982 100644
--- a/test/python/testpipeline/testtranslation.py
+++ b/test/python/testpipeline/testtranslation.py
@@ -15,7 +15,7 @@ class TestTranslation(unittest.TestCase):
def testLongTranslation(self):
"""
- Tests a translation longer than max tokenization length
+ Test a translation longer than max tokenization length
"""
translate = Translation()
@@ -29,7 +29,7 @@ class TestTranslation(unittest.TestCase):
@unittest.skipIf(os.name == "nt", "M2M100 skipped on Windows")
def testM2M100Translation(self):
"""
- Tests a translation using M2M100 models
+ Test a translation using M2M100 models
"""
translate = Translation()
@@ -41,7 +41,7 @@ class TestTranslation(unittest.TestCase):
def testMarianTranslation(self):
"""
- Tests a translation using Marian models
+ Test a translation using Marian models
"""
translate = Translation()
@@ -66,7 +66,7 @@ class TestTranslation(unittest.TestCase):
def testNoModel(self):
"""
- Tests no known available model found
+ Test no known available model found
"""
translate = Translation()
@@ -74,7 +74,7 @@ class TestTranslation(unittest.TestCase):
def testNoTranslation(self):
"""
- Tests translation skipped when text already in destination language
+ Test translation skipped when text already in destination language
"""
translate = Translation()
@@ -87,7 +87,7 @@ class TestTranslation(unittest.TestCase):
def testTranslationWithShowmodels(self):
"""
- Tests a translation using Marian models and showmodels flag to return
+ Test a translation using Marian models and showmodels flag to return
model and language.
"""
diff --git a/test/python/testscoring.py b/test/python/testscoring.py
index 7d29aff6..9f4fd73e 100644
--- a/test/python/testscoring.py
+++ b/test/python/testscoring.py
@@ -218,7 +218,7 @@ class TestScoring(unittest.TestCase):
def empty(self, config):
"""
- Tests scoring index properly handles an index call when no data present.
+ Test scoring index properly handles an index call when no data present.
Args:
config: scoring config
diff --git a/test/python/testvectors/testvectors.py b/test/python/testvectors/testvectors.py
index ebfa30de..188d7e88 100644
--- a/test/python/testvectors/testvectors.py
+++ b/test/python/testvectors/testvectors.py
@@ -14,7 +14,7 @@ class TestVectors(unittest.TestCase):
def testNotImplemented(self):
"""
- Tests exceptions for non-implemented methods
+ Test exceptions for non-implemented methods
"""
vectors = Vectors(None, None)
diff --git a/test/python/testworkflow.py b/test/python/testworkflow.py
index 9ff5597d..a4649bfe 100644
--- a/test/python/testworkflow.py
+++ b/test/python/testworkflow.py
@@ -63,7 +63,7 @@ class TestWorkflow(unittest.TestCase):
def testBaseWorkflow(self):
"""
- Tests a basic workflow
+ Test a basic workflow
"""
translate = Translation()
@@ -77,7 +77,7 @@ class TestWorkflow(unittest.TestCase):
def testChainWorkflow(self):
"""
- Tests a chain of workflows
+ Test a chain of workflows
"""
workflow1 = Workflow([Task(lambda x: [y * 2 for y in x])])
@@ -89,7 +89,7 @@ class TestWorkflow(unittest.TestCase):
@unittest.skipIf(os.name == "nt", "testComplexWorkflow skipped on Windows")
def testComplexWorkflow(self):
"""
- Tests a complex workflow
+ Test a complex workflow
"""
textractor = Textractor(paragraphs=True, minlength=150, join=True)
@@ -130,7 +130,7 @@ class TestWorkflow(unittest.TestCase):
def testConcurrentWorkflow(self):
"""
- Tests running concurrent task actions
+ Test running concurrent task actions
"""
nop = Nop()
@@ -149,7 +149,7 @@ class TestWorkflow(unittest.TestCase):
def testConsoleWorkflow(self):
"""
- Tests a console task
+ Test a console task
"""
# Excel export
@@ -163,7 +163,7 @@ class TestWorkflow(unittest.TestCase):
def testExportWorkflow(self):
"""
- Tests an export task
+ Test an export task
"""
# Excel export
@@ -189,7 +189,7 @@ class TestWorkflow(unittest.TestCase):
def testExtractWorkflow(self):
"""
- Tests column extraction tasks
+ Test column extraction tasks
"""
workflow = Workflow([Task(lambda x: x, unpack=False, column=0)], batch=1)
@@ -205,7 +205,7 @@ class TestWorkflow(unittest.TestCase):
def testImageWorkflow(self):
"""
- Tests an image task
+ Test an image task
"""
workflow = Workflow([ImageTask()])
@@ -216,7 +216,7 @@ class TestWorkflow(unittest.TestCase):
def testInvalidWorkflow(self):
"""
- Tests task with invalid parameters
+ Test task with invalid parameters
"""
with self.assertRaises(TypeError):
@@ -224,7 +224,7 @@ class TestWorkflow(unittest.TestCase):
def testMergeWorkflow(self):
"""
- Tests merge tasks
+ Test merge tasks
"""
task = Task([lambda x: [pow(y, 2) for y in x], lambda x: [pow(y, 3) for y in x]], merge="hstack")
@@ -281,7 +281,7 @@ class TestWorkflow(unittest.TestCase):
def testNumpyWorkflow(self):
"""
- Tests a numpy workflow
+ Test a numpy workflow
"""
task = Task([lambda x: np.power(x, 2), lambda x: np.power(x, 3)], merge="hstack")
@@ -303,7 +303,7 @@ class TestWorkflow(unittest.TestCase):
def testRetrieveWorkflow(self):
"""
- Tests a retrieve task
+ Test a retrieve task
"""
# Test retrieve with generated temporary directory
@@ -318,7 +318,7 @@ class TestWorkflow(unittest.TestCase):
def testScheduleWorkflow(self):
"""
- Tests workflow schedules
+ Test workflow schedules
"""
# Test workflow schedule with Python
@@ -351,7 +351,7 @@ class TestWorkflow(unittest.TestCase):
def testScheduleErrorWorkflow(self):
"""
- Tests workflow schedules with errors
+ Test workflow schedules with errors
"""
def action(elements):
@@ -366,7 +366,7 @@ class TestWorkflow(unittest.TestCase):
def testStorageWorkflow(self):
"""
- Tests a storage task
+ Test a storage task
"""
workflow = Workflow([StorageTask()])
@@ -377,7 +377,7 @@ class TestWorkflow(unittest.TestCase):
def testTensorTransformWorkflow(self):
"""
- Tests a tensor workflow with list transformations
+ Test a tensor workflow with list transformations
"""
# Test one-one list transformation
@@ -394,7 +394,7 @@ class TestWorkflow(unittest.TestCase):
def testTorchWorkflow(self):
"""
- Tests a torch workflow
+ Test a torch workflow
"""
# pylint: disable=E1101,E1102
@@ -417,7 +417,7 @@ class TestWorkflow(unittest.TestCase):
def testYamlFunctionWorkflow(self):
"""
- Tests YAML workflow with a function action
+ Test YAML workflow with a function action
"""
# Create function and add to module
@@ -438,7 +438,7 @@ class TestWorkflow(unittest.TestCase):
def testYamlIndexWorkflow(self):
"""
- Tests reading a YAML index workflow in Python.
+ Test reading a YAML index workflow in Python.
"""
app = API(self.config)
@@ -480,7 +480,7 @@ class TestWorkflow(unittest.TestCase):
def testYamlWorkflowTask(self):
"""
- Tests YAML workflow with a workflow task
+ Test YAML workflow with a workflow task
"""
# Create function and add to module
@@ -513,7 +513,7 @@ class TestWorkflow(unittest.TestCase):
def testYamlError(self):
"""
- Tests reading a YAML workflow with errors.
+ Test reading a YAML workflow with errors.
"""
# Read from string