From 8422f1acdfccde2321dbf6f9600cdd7a482df523 Mon Sep 17 00:00:00 2001 From: "jingzhi.pang@petuum.com" Date: Thu, 10 Jun 2021 17:26:18 -0700 Subject: [PATCH 1/5] test branch --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..d25c715 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +“some test file” From 2bd4ffece5bc017d71302a9ebc5aaabdaf74724c Mon Sep 17 00:00:00 2001 From: "jingzhi.pang@petuum.com" Date: Fri, 11 Jun 2021 21:46:54 -0700 Subject: [PATCH 2/5] add unittest to check import --- test.txt | 1 - tests/wrappers/elastic_processor_test.py | 42 ++++++++++++++++++++ tests/wrappers/elastic_query_creator_test.py | 32 +++++++++++++++ tests/wrappers/my_test.py | 0 tests/wrappers/twitter_processor_test.py | 17 ++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) delete mode 100644 test.txt create mode 100644 tests/wrappers/elastic_processor_test.py create mode 100644 tests/wrappers/elastic_query_creator_test.py create mode 100644 tests/wrappers/my_test.py create mode 100644 tests/wrappers/twitter_processor_test.py diff --git a/test.txt b/test.txt deleted file mode 100644 index d25c715..0000000 --- a/test.txt +++ /dev/null @@ -1 +0,0 @@ -“some test file” diff --git a/tests/wrappers/elastic_processor_test.py b/tests/wrappers/elastic_processor_test.py new file mode 100644 index 0000000..04ea02e --- /dev/null +++ b/tests/wrappers/elastic_processor_test.py @@ -0,0 +1,42 @@ +import unittest +from ddt import ddt +from forte.data.multi_pack import MultiPack +from forte.data.readers import MultiPackTerminalReader +from forte.data.data_pack import DataPack +from forte.pipeline import Pipeline +from forte.data.readers import StringReader +from forte.elastic import ElasticSearchProcessor, \ + ElasticSearchPackIndexProcessor, ElasticSearchTextIndexProcessor + + +@ddt +class TestElasticSearchProcessor(unittest.TestCase): + def setUp(self): + self.nlp: Pipeline[MultiPack] = Pipeline() + self.nlp.set_reader(reader=MultiPackTerminalReader()) + + def test_init(self): + self.nlp.add(ElasticSearchProcessor()) + self.nlp.initialize() + + +@ddt +class TestElasticSearchPackIndexProcessor(unittest.TestCase): + def setUp(self): + self.nlp = Pipeline[DataPack]() + self.nlp.set_reader(StringReader()) + + def test_init(self): + self.nlp.add(ElasticSearchPackIndexProcessor()) + self.nlp.initialize() + + +@ddt +class TestElasticSearchTextIndexProcessor(unittest.TestCase): + def setUp(self): + self.nlp = Pipeline[DataPack]() + self.nlp.set_reader(StringReader()) + + def test_init(self): + self.nlp.add(ElasticSearchTextIndexProcessor()) + self.nlp.initialize() \ No newline at end of file diff --git a/tests/wrappers/elastic_query_creator_test.py b/tests/wrappers/elastic_query_creator_test.py new file mode 100644 index 0000000..a284a82 --- /dev/null +++ b/tests/wrappers/elastic_query_creator_test.py @@ -0,0 +1,32 @@ +from ddt import ddt, data +import unittest +from forte.data.caster import MultiPackBoxer +from forte.elastic import ElasticSearchQueryCreator +from forte.data.data_pack import DataPack +from forte.pipeline import Pipeline +from forte.data.readers import StringReader +from forte.data.ontology.top import Query + + +@ddt +class TestElasticSearchQueryCreator(unittest.TestCase): + def setUp(self): + self.nlp = Pipeline[DataPack]() + self.nlp.set_reader(StringReader()) + self.nlp.add(MultiPackBoxer(), config={'pack_name': "query"}) + self.nlp.add(ElasticSearchQueryCreator(), + config={"size": 1, + "field": "content", + "query_pack_name": "query" + }) + self.nlp.initialize() + + @data("test") + def test_process_query(self, query): + m_pack = self.nlp.process_one([query]) + + query_pack = m_pack.get_pack("query") + test_query = query_pack.get_single(Query) + + self.assertEqual({'query': {'match': {'content': query}}, 'size': 1}, + test_query.value) diff --git a/tests/wrappers/my_test.py b/tests/wrappers/my_test.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/wrappers/twitter_processor_test.py b/tests/wrappers/twitter_processor_test.py new file mode 100644 index 0000000..c3baf3d --- /dev/null +++ b/tests/wrappers/twitter_processor_test.py @@ -0,0 +1,17 @@ +from ddt import ddt +import unittest +from forte.data.multi_pack import MultiPack +from forte.data.readers import MultiPackTerminalReader +from forte.pipeline import Pipeline +from forte.tweepy import TweetSearchProcessor + + +@ddt +class TestTweetSearchProcessor(unittest.TestCase): + def setUp(self): + self.nlp: Pipeline[MultiPack] = Pipeline() + self.nlp.set_reader(reader=MultiPackTerminalReader()) + + def test_init(self): + self.nlp.add(TweetSearchProcessor()) + self.nlp.initialize() \ No newline at end of file From 912c2f56524350c7548a8aacc6ab2328a5378eb5 Mon Sep 17 00:00:00 2001 From: "jingzhi.pang@petuum.com" Date: Fri, 11 Jun 2021 21:59:37 -0700 Subject: [PATCH 3/5] update pytest workflow --- .github/workflows/main.yml | 3 ++- tests/wrappers/{ => elastic}/elastic_indexers_test.py | 0 tests/wrappers/{ => elastic}/elastic_processor_test.py | 0 tests/wrappers/{ => elastic}/elastic_query_creator_test.py | 0 4 files changed, 2 insertions(+), 1 deletion(-) rename tests/wrappers/{ => elastic}/elastic_indexers_test.py (100%) rename tests/wrappers/{ => elastic}/elastic_processor_test.py (100%) rename tests/wrappers/{ => elastic}/elastic_query_creator_test.py (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8878c11..1ff3d8c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -85,9 +85,10 @@ jobs: - { dep: spacy, testfile: tests/wrappers/spacy_processors_test.py } - { dep: stanza, testfile: tests/wrappers/stanfordnlp_processor_test.py } - { dep: "nltk gpt2", extra: "termcolor>=1.1.0", testfile: examples/gpt2_test.py } - - { dep: elastic, testfile: tests/wrappers/elastic_indexers_test.py } + - { dep: elastic, testfile: tests/wrappers/elastic } - { dep: faiss, testfile: tests/wrappers/faiss_indexers_test.py } - { dep: "huggingface nltk", testfile: tests/wrappers/huggingface } + - { dep: tweepy, testfile: tests/wrappers/twitter_processor_test.py } steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/tests/wrappers/elastic_indexers_test.py b/tests/wrappers/elastic/elastic_indexers_test.py similarity index 100% rename from tests/wrappers/elastic_indexers_test.py rename to tests/wrappers/elastic/elastic_indexers_test.py diff --git a/tests/wrappers/elastic_processor_test.py b/tests/wrappers/elastic/elastic_processor_test.py similarity index 100% rename from tests/wrappers/elastic_processor_test.py rename to tests/wrappers/elastic/elastic_processor_test.py diff --git a/tests/wrappers/elastic_query_creator_test.py b/tests/wrappers/elastic/elastic_query_creator_test.py similarity index 100% rename from tests/wrappers/elastic_query_creator_test.py rename to tests/wrappers/elastic/elastic_query_creator_test.py From 0dc65f96158e62f83cfd15b37e9316433d1da078 Mon Sep 17 00:00:00 2001 From: "jingzhi.pang@petuum.com" Date: Fri, 11 Jun 2021 21:59:56 -0700 Subject: [PATCH 4/5] remove unused import --- tests/wrappers/spacy_processors_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wrappers/spacy_processors_test.py b/tests/wrappers/spacy_processors_test.py index f20c54c..9093d56 100644 --- a/tests/wrappers/spacy_processors_test.py +++ b/tests/wrappers/spacy_processors_test.py @@ -21,7 +21,7 @@ import spacy from spacy.language import Language -from forte.common import ProcessExecutionException, ProcessorConfigError +from forte.common import ProcessorConfigError from forte.data.data_pack import DataPack from forte.data.readers import StringReader from forte.pipeline import Pipeline From 37715cfe9c298b9fb51bbdca9ec1ad48ca8260c9 Mon Sep 17 00:00:00 2001 From: "jingzhi.pang@petuum.com" Date: Mon, 14 Jun 2021 15:53:03 -0700 Subject: [PATCH 5/5] remove usused files --- tests/wrappers/my_test.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/wrappers/my_test.py diff --git a/tests/wrappers/my_test.py b/tests/wrappers/my_test.py deleted file mode 100644 index e69de29..0000000