diff --git a/tests/executors/crafters/image/test_crop.py b/tests/executors/crafters/image/test_crop.py index 05a65ffd64ba5..445699713379a 100644 --- a/tests/executors/crafters/image/test_crop.py +++ b/tests/executors/crafters/image/test_crop.py @@ -1,4 +1,5 @@ import unittest + import numpy as np from jina.executors.crafters.image.crop import ImageCropper, CenterImageCropper, RandomImageCropper, FiveImageCropper, \ @@ -17,11 +18,11 @@ def test_crop(self): crafter = ImageCropper(left, top, width, height) crafted_chunk = crafter.craft(img_array, 0, 0) np.testing.assert_array_equal( - crafted_chunk['blob'], np.asarray(img_array[top:top+height, left:left+width, :]), + crafted_chunk['blob'], np.asarray(img_array[top:top + height, left:left + width, :]), 'img_array: {}\ntest: {}\ncontrol:{}'.format( img_array.shape, crafted_chunk['blob'].shape, - np.asarray(img_array[left:left+width, top:top+height, :]).shape)) + np.asarray(img_array[left:left + width, top:top + height, :]).shape)) def test_center_crop(self): img_size = 217 diff --git a/tests/executors/crafters/nlp/split.py b/tests/executors/crafters/nlp/split.py index 7b75e9b2ef4da..eefed53c29e37 100644 --- a/tests/executors/crafters/nlp/split.py +++ b/tests/executors/crafters/nlp/split.py @@ -1,6 +1,7 @@ import unittest -from tests import JinaTestCase + from jina.executors.crafters.nlp.split import Sentencizer, JiebaSegmenter +from tests import JinaTestCase class MyTestCase(JinaTestCase): @@ -22,5 +23,6 @@ def test_jieba_crafter(self): crafted_chunk_list = jieba_crafter.craft(raw_bytes, 0) self.assertEqual(len(crafted_chunk_list), 14) + if __name__ == '__main__': unittest.main() diff --git a/tests/executors/encoders/image/test_onnx.py b/tests/executors/encoders/image/test_onnx.py index f27e0757e9f36..48b542cfd3008 100644 --- a/tests/executors/encoders/image/test_onnx.py +++ b/tests/executors/encoders/image/test_onnx.py @@ -1,5 +1,4 @@ import unittest -import os from jina.executors.encoders.image.onnx import OnnxImageEncoder from . import ImageTestCase diff --git a/tests/executors/encoders/nlp/__init__.py b/tests/executors/encoders/nlp/__init__.py index 30583704e5ee3..2a78620ab1c91 100644 --- a/tests/executors/encoders/nlp/__init__.py +++ b/tests/executors/encoders/nlp/__init__.py @@ -4,7 +4,6 @@ import numpy as np from jina.executors import BaseExecutor -from jina.executors.encoders.nlp.paddlehub import TextPaddlehubEncoder from tests import JinaTestCase diff --git a/tests/executors/encoders/numeric/__init__.py b/tests/executors/encoders/numeric/__init__.py index 81f795d2a4df0..a10e76fb5d6e2 100644 --- a/tests/executors/encoders/numeric/__init__.py +++ b/tests/executors/encoders/numeric/__init__.py @@ -1,8 +1,9 @@ -import numpy as np import os -from tests import JinaTestCase +import numpy as np + from jina.executors import BaseExecutor +from tests import JinaTestCase class NumericTestCase(JinaTestCase): diff --git a/tests/executors/encoders/numeric/test_pca.py b/tests/executors/encoders/numeric/test_pca.py index 53d2e37aa45a8..95ca2827518b2 100644 --- a/tests/executors/encoders/numeric/test_pca.py +++ b/tests/executors/encoders/numeric/test_pca.py @@ -2,8 +2,8 @@ import numpy as np -from . import NumericTestCase from jina.executors.encoders.numeric.pca import IncrementalPCAEncoder +from . import NumericTestCase class MyTestCase(NumericTestCase): diff --git a/tests/executors/indexers/keyvalue/test_leveldb.py b/tests/executors/indexers/keyvalue/test_leveldb.py index eb465d055e35e..b188716285c92 100644 --- a/tests/executors/indexers/keyvalue/test_leveldb.py +++ b/tests/executors/indexers/keyvalue/test_leveldb.py @@ -1,10 +1,12 @@ -import unittest import os -from tests import JinaTestCase -from jina.executors.indexers.keyvalue.leveldb import LeveldbIndexer +import unittest + +from google.protobuf.json_format import MessageToJson + import jina.proto.jina_pb2 as jina_pb2 from jina.executors.indexers import BaseIndexer -from google.protobuf.json_format import MessageToJson +from jina.executors.indexers.keyvalue.leveldb import LeveldbIndexer +from tests import JinaTestCase class MyTestCase(JinaTestCase): diff --git a/tests/executors/indexers/vector/test_annoy.py b/tests/executors/indexers/vector/test_annoy.py index ecf61cb4f7e0b..410d0bd849e21 100644 --- a/tests/executors/indexers/vector/test_annoy.py +++ b/tests/executors/indexers/vector/test_annoy.py @@ -2,6 +2,7 @@ import unittest import numpy as np + from jina.executors.indexers import BaseIndexer from jina.executors.indexers.vector.annoy import AnnoyIndexer from jina.executors.indexers.vector.nmslib import NmslibIndexer diff --git a/tests/executors/rankers/__init__.py b/tests/executors/rankers/__init__.py index 3f9a761340e0c..89a6926614930 100644 --- a/tests/executors/rankers/__init__.py +++ b/tests/executors/rankers/__init__.py @@ -45,4 +45,3 @@ def test_ranker(self): self.assertEqual(doc_idx[1][0], 4294967294) # check the number of matched docs self.assertEqual(len(doc_idx), 2) - diff --git a/tests/test_container.py b/tests/test_container.py index 3e8ba83d60182..6168ed83be449 100644 --- a/tests/test_container.py +++ b/tests/test_container.py @@ -27,7 +27,6 @@ def random_docs(num_docs, chunks_per_doc=5, embed_dim=10): built = False img_name = 'jina/mwu-encoder' - defaulthost = '0.0.0.0' localhost = defaulthost if (platform == "linux" or platform == "linux2") else 'host.docker.internal' @@ -44,7 +43,6 @@ def build_image(): # @unittest.skipUnless(os.getenv('JINA_TEST_CONTAINER', False), 'skip the container test if not set') class MyTestCase(JinaTestCase): - def tearDown(self) -> None: super().tearDown() time.sleep(2) diff --git a/tests/test_flow.py b/tests/test_flow.py index 872a6f417043f..8ef298711a624 100644 --- a/tests/test_flow.py +++ b/tests/test_flow.py @@ -1,19 +1,7 @@ import unittest import requests -from jina import JINA_GLOBAL -from jina.enums import FlowOptimizeLevel -from jina.flow import Flow -from jina.main.checker import NetworkChecker -from jina.main.parser import set_pea_parser, set_ping_parser -from jina.main.parser import set_pod_parser -from jina.peapods.pea import BasePea -from jina.peapods.pod import BasePod -from jina.proto import jina_pb2 -from tests import JinaTestCase -import unittest -import requests from jina import JINA_GLOBAL from jina.enums import FlowOptimizeLevel from jina.flow import Flow diff --git a/tests/test_index.py b/tests/test_index.py index 855efa1e7f420..ca2ed77a66a1d 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -4,6 +4,7 @@ import unittest import numpy as np + from jina.drivers.helper import array2pb from jina.enums import FlowOptimizeLevel from jina.executors.indexers.vector.numpy import NumpyIndexer diff --git a/tests/test_index_remote.py b/tests/test_index_remote.py index 12b81e5180677..a7a558f66e7f2 100644 --- a/tests/test_index_remote.py +++ b/tests/test_index_remote.py @@ -4,6 +4,7 @@ import unittest import numpy as np + from jina.drivers.helper import array2pb from jina.enums import FlowOptimizeLevel from jina.executors.indexers.vector.numpy import NumpyIndexer diff --git a/tests/test_loadbalance.py b/tests/test_loadbalance.py index 6c734b0611113..c8dfd81e2ecb4 100644 --- a/tests/test_loadbalance.py +++ b/tests/test_loadbalance.py @@ -2,16 +2,7 @@ import time import numpy as np -from jina.drivers.helper import array2pb -from jina.enums import SchedulerType -from jina.executors.crafters import BaseDocCrafter -from jina.flow import Flow -from jina.proto import jina_pb2 -from tests import JinaTestCase -import os -import time -import numpy as np from jina.drivers.helper import array2pb from jina.enums import SchedulerType from jina.executors.crafters import BaseDocCrafter diff --git a/tests/test_quant.py b/tests/test_quant.py index 038ef0c1e2d82..6be580cd0eeca 100644 --- a/tests/test_quant.py +++ b/tests/test_quant.py @@ -1,6 +1,7 @@ import os import numpy as np + from jina.drivers.helper import array2pb, pb2array from jina.flow import Flow from jina.proto import jina_pb2 @@ -52,6 +53,16 @@ def f1(self, quant): with f as fl: fl.index(random_docs, output_fn=get_output, in_proto=True) + def f2(self, quant): + os.environ['JINA_ARRAY_QUANT'] = quant + + f = Flow(callback_on_body=True, compress_hwm=1024).add(yaml_path='_forward').add(yaml_path='_forward').add( + yaml_path='_forward').add( + yaml_path='_forward').add(yaml_path='_forward').add(yaml_path='_forward').add(yaml_path='_forward') + with f as fl: + fl.index(random_docs, output_fn=get_output, in_proto=True) + def test_quant(self): for j in ('fp32', 'fp16', 'uint8'): self.f1(j) + self.f2(j)