Skip to content

Commit ed5d912

Browse files
authored
Merge branch 'main' into suqi-localtest
2 parents 791fb51 + 4ba6552 commit ed5d912

File tree

83 files changed

+1119
-791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1119
-791
lines changed

.github/workflows/main.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ jobs:
3737
run: |
3838
python -m pip install --progress-bar off --upgrade pip
3939
pip install --progress-bar off Django django-guardian
40-
pip install --progress-bar off pylint==2.6.0 flake8==3.8.2 mypy==0.790 pytest==5.1.3 black==20.8b1
40+
pip install --progress-bar off pylint==2.10.2 flake8==3.8.2
41+
pip install --progress-bar off mypy==0.910 pytest==5.1.3 black==21.8b0
4142
pip install --progress-bar off coverage codecov ddt
43+
pip install types-termcolor types-PyYAML
4244
- name: Install deep learning frameworks
4345
run: |
4446
pip install --progress-bar off torch==${{ matrix.torch-version }}
@@ -119,14 +121,11 @@ jobs:
119121
then
120122
pip install ${{ matrix.test-details.extra }}
121123
fi
122-
- name: Install Forte
124+
- name: Install Forte from source to test the latest version.
123125
run: |
124126
git clone https://github.com/asyml/forte.git
125127
cd forte
126128
pip install --progress-bar off .
127-
cd ..
128-
# Remove them to avoid confusing pytest.
129-
rm -rf forte
130129
- name: Start elastic server if test elastic search
131130
if: ${{ matrix.test-details.dep == 'elastic' }}
132131
run: |
@@ -168,6 +167,11 @@ jobs:
168167
do
169168
pip install "src/"$dep
170169
done
170+
- name: Install Forte from source to use the latest version.
171+
run: |
172+
git clone https://github.com/asyml/forte.git
173+
cd forte
174+
pip install --progress-bar off .
171175
- name: Build Docs
172176
run: |
173177
cd docs

.github/workflows/pypi.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ on:
1212
jobs:
1313
deploy:
1414
runs-on: ubuntu-latest
15-
# Upload to PYPI only on tagged commits.
16-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
15+
# Only run PyPI publish on main repo.
16+
if: github.repository == ‘asyml/forte’
1717
strategy:
1818
matrix:
1919
wrapper: [ spacy, allennlp, elastic, faiss, gpt2, huggingface, nltk, stanza, tweepy, vader ]
20-
2120
env:
2221
python-version: 3.7
2322
steps:

VERSION

-1
This file was deleted.

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import sys
1717

1818
# We should be in the `docs` directory, so the VERSION is one step up.
19-
with open(os.path.join("..", 'VERSION')) as version_file:
19+
with open(os.path.join("..", "scripts", "VERSION")) as version_file:
2020
version = version_file.read().strip()
2121

2222
# from unittest.mock import MagicMock

docs/wrappers.rst

+17-15
Original file line numberDiff line numberDiff line change
@@ -8,69 +8,71 @@ AllenNLP
88
========
99
:hidden:`AllenNLP Processors`
1010
-----------------------------
11-
.. autoclass:: forte.allennlp.AllenNLPProcessor
11+
.. autoclass:: fortex.allennlp.AllenNLPProcessor
1212
:members:
1313

1414
SpaCy
1515
=====
1616
:hidden:`SpaCy Processors`
1717
----------------------------
18-
.. autoclass:: forte.spacy.SpacyProcessor
18+
.. autoclass:: fortex.spacy.SpacyProcessor
1919
:members:
2020

21+
.. autoclass:: fortex.spacy.SpacyBatchedProcessor
22+
:members:
2123

2224
NLTK
2325
=====
2426
:hidden:`NLTK Processors`
2527
----------------------------
26-
.. autoclass:: forte.nltk.NLTKPOSTagger
28+
.. autoclass:: fortex.nltk.NLTKPOSTagger
2729
:members:
2830

29-
.. autoclass:: forte.nltk.NLTKSentenceSegmenter
31+
.. autoclass:: fortex.nltk.NLTKSentenceSegmenter
3032
:members:
3133

32-
.. autoclass:: forte.nltk.NLTKWordTokenizer
34+
.. autoclass:: fortex.nltk.NLTKWordTokenizer
3335
:members:
3436

35-
.. autoclass:: forte.nltk.NLTKLemmatizer
37+
.. autoclass:: fortex.nltk.NLTKLemmatizer
3638
:members:
3739

38-
.. autoclass:: forte.nltk.NLTKChunker
40+
.. autoclass:: fortex.nltk.NLTKChunker
3941
:members:
4042

41-
.. autoclass:: forte.nltk.NLTKNER
43+
.. autoclass:: fortex.nltk.NLTKNER
4244
:members:
4345

4446
Stanza
4547
======
4648
:hidden:`Stanza Processors`
4749
----------------------------
48-
.. autoclass:: forte.stanza.StandfordNLPProcessor
50+
.. autoclass:: fortex.stanza.StandfordNLPProcessor
4951
:members:
5052

5153
HuggingFace
5254
===========
5355
:hidden:`HuggingFace Processors`
5456
--------------------------------
55-
.. autoclass:: forte.huggingface.ZeroShotClassifier
57+
.. autoclass:: fortex.huggingface.ZeroShotClassifier
5658
:members:
57-
.. autoclass:: forte.huggingface.QuestionAnsweringSingle
59+
.. autoclass:: fortex.huggingface.QuestionAnsweringSingle
5860
:members:
59-
.. autoclass:: forte.huggingface.BERTTokenizer
61+
.. autoclass:: fortex.huggingface.BERTTokenizer
6062
:members:
61-
.. autoclass:: forte.huggingface.BioBERTNERPredictor
63+
.. autoclass:: fortex.huggingface.BioBERTNERPredictor
6264
:members:
6365

6466
Twitter
6567
=======
6668
:hidden:`Twitter Processors`
6769
----------------------------
68-
.. autoclass:: forte.tweepy.TweetSearchProcessor
70+
.. autoclass:: fortex.tweepy.TweetSearchProcessor
6971
:members:
7072

7173
Vader
7274
=====
7375
:hidden:`Vader Processors`
7476
----------------------------
75-
.. autoclass:: forte.vader.VaderSentimentProcessor
77+
.. autoclass:: fortex.vader.VaderSentimentProcessor
7678
:members:

examples/gpt2/sample_multipack_pipeline_gpt.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ forte_ir_version: "0.0.1"
44

55
components:
66

7-
- type: "forte.data.readers.MultiPackSentenceReader"
7+
- type: "fortex.data.readers.MultiPackSentenceReader"
88
configs:
99
input_pack_name: "input_src"
1010
output_pack_name: "output_tgt"
1111

12-
- type: "forte.gpt2.text_generation_processor.TextGenerationProcessor"
12+
- type: "fortex.gpt2.text_generation_processor.TextGenerationProcessor"
1313
configs:
1414
max_decoding_length: 128
1515
temperature: 0.7
@@ -20,17 +20,16 @@ components:
2020
batcher:
2121
batch_size: 64
2222

23-
- type: "forte.nltk.nltk_processors.NLTKWordTokenizer"
23+
- type: "fortex.nltk.nltk_processors.NLTKWordTokenizer"
2424
configs:
2525
selector:
2626
type: "forte.data.selector.NameMatchSelector"
2727
kwargs:
2828
select_name: "output_tgt"
2929

30-
- type: "forte.nltk.nltk_processors.NLTKPOSTagger"
30+
- type: "fortex.nltk.nltk_processors.NLTKPOSTagger"
3131
configs:
3232
selector:
3333
type: "forte.data.selector.NameMatchSelector"
3434
kwargs:
35-
select_name: "output_tgt"
36-
35+
select_name: "output_tgt"

examples/gpt2_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def test_pipeline_construction(self):
3131

3232
# pylint: disable=line-too-long
3333
p_names = [
34-
'forte.gpt2.text_generation_processor.TextGenerationProcessor',
35-
'forte.nltk.nltk_processors.NLTKWordTokenizer',
36-
'forte.nltk.nltk_processors.NLTKPOSTagger',
34+
'fortex.gpt2.text_generation_processor.TextGenerationProcessor',
35+
'fortex.nltk.nltk_processors.NLTKWordTokenizer',
36+
'fortex.nltk.nltk_processors.NLTKPOSTagger',
3737
]
3838

3939
for proc, p_name in zip(p.components, p_names):

scripts/FORTE_VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.2

scripts/VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.2

scripts/update_all_version.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
#!/bin/bash
2+
3+
# Find this folder
4+
d=`dirname $0`
5+
6+
version=`head -1 ${d}/VERSION`
7+
forte_version=`head -1 ${d}/FORTE_VERSION`
8+
echo "Updating versions to "${version}", depends on Forte "${forte_version}
9+
110
for f in src/*/setup.py; do
211
echo "Processing $f"
3-
sed -r -i"" "s/version=\"[0-9A-Za-z\.]+\",/version=\"$1\",/1" $f
12+
sed -r -i"" "s/version=\"[0-9A-Za-z\.]+\",/version=\"${version}\",/1" $f
13+
sed -r -i"" "s/forte==[0-9A-Za-z\.]+\",/forte==${forte_version}\",/1" $f
414
done

src/allennlp/forte/allennlp/__init__.py

-1
This file was deleted.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from fortex.allennlp.allennlp_processors import AllenNLPProcessor

src/allennlp/forte/allennlp/allennlp_processors.py renamed to src/allennlp/fortex/allennlp/allennlp_processors.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
PredicateArgument,
2727
PredicateMention,
2828
)
29-
3029
from forte.common import ProcessorConfigError
3130
from forte.common.configuration import Config
3231
from forte.common.resources import Resources
3332
from forte.data.data_pack import DataPack
3433
from forte.processors.base import PackProcessor
35-
from forte.allennlp.utils_processor import (
34+
35+
from fortex.allennlp.utils_processor import (
3636
parse_allennlp_srl_tags,
3737
parse_allennlp_srl_results,
3838
)
@@ -150,21 +150,17 @@ def default_configs(cls):
150150
151151
Returns: A dictionary with the default config for this processor.
152152
"""
153-
config = super().default_configs()
154-
config.update(
155-
{
156-
"processors": "tokenize,pos,depparse",
157-
"tag_formalism": "stanford",
158-
"overwrite_entries": False,
159-
"allow_parallel_entries": True,
160-
"stanford_url": MODEL2URL["stanford"],
161-
"srl_url": MODEL2URL["srl"],
162-
"universal_url": MODEL2URL["universal"],
163-
"cuda_devices": [-1],
164-
"infer_batch_size": 0,
165-
}
166-
)
167-
return config
153+
return {
154+
"processors": "tokenize,pos,depparse",
155+
"tag_formalism": "stanford",
156+
"overwrite_entries": False,
157+
"allow_parallel_entries": True,
158+
"stanford_url": MODEL2URL["stanford"],
159+
"srl_url": MODEL2URL["srl"],
160+
"universal_url": MODEL2URL["universal"],
161+
"cuda_devices": [-1],
162+
"infer_batch_size": 0,
163+
}
168164

169165
def _process(self, input_pack: DataPack):
170166
# handle existing entries

src/allennlp/setup.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@
1616

1717
setuptools.setup(
1818
name="forte.allennlp",
19-
version="v0.0.1post2",
19+
version="0.0.2",
2020
url="https://github.com/asyml/forte-wrappers/tree/main/src/allennlp",
2121
description="Provide Forte implementations of a fantastic collection of "
2222
"NLP tools.",
2323
long_description=long_description,
2424
long_description_content_type="text/markdown",
2525
license="Apache License Version 2.0",
26-
packages=["forte.allennlp"],
26+
packages=["fortex.allennlp"],
27+
namespace_packages=["fortex"],
2728
include_package_data=True,
2829
platforms="any",
2930
install_requires=[
30-
"forte==0.1.1",
31+
"forte==0.1.2",
3132
"more-itertools>=8.0.0",
3233
"allennlp==1.2.0",
3334
"allennlp-models==1.2.0",

src/elastic/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ This project is part of the [CASL Open Source](http://casl-project.ai/) family.
2020

2121
### Get Started
2222

23-
- First, install the library along with the desired tools. Let's take AllenNLP
24-
as an example:
23+
- First, install the library along with the elastic search tool:
2524

2625
```shell
2726
git clone https://github.com/asyml/forte-wrappers.git

src/elastic/forte/elastic/__init__.py

-4
This file was deleted.
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from fortex.elastic.elastic_search_processor import *
2+
from fortex.elastic.elastic_indexer import *
3+
from fortex.elastic.elastic_search_index_processor import *
4+
from fortex.elastic.elastic_search_query_creator import *

src/elastic/forte/elastic/elastic_indexer.py renamed to src/elastic/fortex/elastic/elastic_indexer.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@
2222

2323
__all__ = ["ElasticSearchIndexer"]
2424

25+
from forte.common.configurable import Configurable
2526
from forte.common.configuration import Config
2627

2728
# It seems that elastic search shows a lot of debug message, sometimes can
2829
# suffocate travis. Trying to depress the logging.
2930
es_logger.setLevel(logging.INFO)
3031

3132

32-
class ElasticSearchIndexer:
33+
class ElasticSearchIndexer(Configurable):
3334
r"""Indexer class for `Elasticsearch`."""
3435

35-
def __init__(self, config: Optional[Union[Dict, Config]] = None):
36+
def __init__(self, configs: Optional[Union[Dict, Config]] = None):
3637
super().__init__()
37-
self._config = Config(config, self.default_configs())
38-
self.elasticsearch = Elasticsearch(hosts=self._config.hosts)
38+
self._configs = self.make_configs(configs)
39+
self.elasticsearch = Elasticsearch(hosts=self._configs.hosts)
3940

4041
def index(
4142
self,
@@ -88,7 +89,7 @@ def add(
8889
`https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-refresh.html`
8990
for more information on "refresh"
9091
"""
91-
index_name = index_name if index_name else self._config.index_name
92+
index_name = index_name if index_name else self._configs.index_name
9293
self.elasticsearch.index( # pylint: disable=unexpected-keyword-arg
9394
index=index_name, body=document, refresh=refresh
9495
)
@@ -171,10 +172,10 @@ def search(
171172

172173
@property
173174
def hparams(self):
174-
return self._config
175+
return self._configs
175176

176-
@staticmethod
177-
def default_configs() -> Dict[str, Any]:
177+
@classmethod
178+
def default_configs(cls) -> Dict[str, Any]:
178179
r"""Returns a dictionary of default hyperparameters.
179180
180181
.. code-block:: python

0 commit comments

Comments
 (0)