forked from asyml/forte
-
Notifications
You must be signed in to change notification settings - Fork 0
241 lines (234 loc) · 9.59 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: Python Build
on:
push:
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.6, 3.7 ]
torch-version: [ 1.5.0, 1.6.0 ]
tensorflow-version: [ 1.15.0 ]
include:
- python-version: 3.8
torch-version: 1.7.1
tensorflow-version: 2.2.0
- python-version: 3.8
torch-version: 1.8.1
tensorflow-version: 2.2.0
- python-version: 3.9
torch-version: 1.7.1
tensorflow-version: 2.5.0
- python-version: 3.9
torch-version: 1.8.1
tensorflow-version: 2.5.0
notebook-details:
- { dep: "huggingface nltk", extra: "'tensorflow>=2.5.0,<2.8.0,termcolor>=1.1.0'"}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
sudo apt-get install -y libsndfile1-dev
python -m pip install --progress-bar off --upgrade pip
pip install --progress-bar off Django django-guardian
pip install --progress-bar off pylint==2.10.2 flake8==3.9.2 mypy==0.931 pytest==5.1.3 black==22.3.0
pip install --progress-bar off types-PyYAML==5.4.8 types-typed-ast==1.4.4 types-requests==2.25.6 types-dataclasses==0.1.7
pip install --progress-bar off coverage codecov
python -m pip install ipykernel
python -m ipykernel install --user
pip install --progress-bar off asyml-utilities
- name: Format check with Black
run: |
black --line-length 80 --check forte/
- name: Obtain Stave Database Examples
run: |
git clone https://github.com/asyml/stave.git
cd stave/simple-backend
python manage.py migrate
cat sample_sql/*.sql | sqlite3 db.sqlite3
cd ../..
# Simply keep the database file but remove the repo.
cp stave/simple-backend/db.sqlite3 .
rm -rf stave
- name: Install Forte
run: |
pip install --use-feature=in-tree-build --progress-bar off .[data_aug,ir,remote,audio_ext,stave,models,test,wikipedia,nlp,extractor]
- name: Install deep learning frameworks
run: |
pip install --progress-bar off torch==${{ matrix.torch-version }}
pip install --progress-bar off tensorflow==${{ matrix.tensorflow-version }}
- name: Build ontology
run: |
./scripts/build_ontology_specs.sh
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 forte/ examples/ ft/ scripts/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 forte/ examples/ ft/ scripts/ tests/ --ignore E203,W503 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with pylint
run: |
pylint forte/
- name: Lint main code with mypy when torch version is not 1.5.0 and python is 3.9
run: |
if [[ ${{ matrix.torch-version }} != "1.5.0" && ${{ matrix.python-version }} == "3.9" ]]; then mypy forte; fi
- name: Test with pytest and run coverage
run: |
coverage run -m pytest tests --ignore=tests/forte/notebooks --ignore=tests/forte/forte_backbone_test.py
coverage run --append -m pytest --doctest-modules forte
- name: Upload coverage
run: |
codecov
- name: Test notebook tutorials with installing Fortex
run: |
if [ ${{ matrix.torch-version }} == "1.5.0" ]
then
git clone https://github.com/asyml/forte-wrappers.git
cd forte-wrappers
for d in ${{ matrix.notebook-details.dep }}; do pip install "src/"$d; done
cd ..
pip install --use-feature=in-tree-build --progress-bar off .[data_aug,ir,remote,audio_ext,stave,models,test,wikipedia,nlp,extractor]
coverage run -m pytest tests/forte/notebooks
fi
test_backbone:
runs-on: ubuntu-latest
env:
python-version: 3.7
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Test backbone Forte import test
run: |
# Try to install Forte backbone only and test basic imports.
pip install --use-feature=in-tree-build --progress-bar off .
python tests/forte/forte_backbone_test.py
test_modules:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.6 ]
torch-version: [ 1.5.0 ]
tensorflow-version: [ 1.15.0 ]
modules:
- { module: "data_aug", test_file: "tests/forte/processors/data_augment"}
- { module: "ir",test_file: "tests/forte/processors/ir/"}
- { module: "remote", test_file: "tests/forte/remote_processor_test.py"}
- { module: "audio_ext",test_file: "tests/forte/data/readers/audio_reader_test.py"}
- { module: "stave",test_file: "tests/forte/data/readers/stave_reader_test.py tests/forte/processors/stave_processor_test.py"}
- { module: "models", test_file: "tests/forte/models"}
- { module: "wikipedia", test_file: "tests/forte/datasets/wikipedia"}
- { module: "nlp",test_file: "tests/forte/processors/subword_tokenizer_test.py tests/forte/processors/pretrained_encoder_processors_test.py"}
- { module: "extractor",test_file: "tests/forte/train_preprocessor_test.py forte/data/extractors tests/forte/data/data_pack_dataset_test.py tests/forte/data/converter/converter_test.py"}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: install forte
run: |
pip install --use-feature=in-tree-build --progress-bar off .
- name: install dependencies
run: |
sudo apt-get install -y libsndfile1-dev
python -m pip install --progress-bar off --upgrade pip
pip install --progress-bar off Django django-guardian
- name: Obtain Stave Database Examples
run: |
git clone https://github.com/asyml/stave.git
cd stave/simple-backend
python manage.py migrate
cat sample_sql/*.sql | sqlite3 db.sqlite3
cd ../..
# Simply keep the database file but remove the repo.
cp stave/simple-backend/db.sqlite3 .
rm -rf stave
- name: Test modules need extra packages
run: |
pip install --use-feature=in-tree-build --progress-bar off .[test]
pip install --use-feature=in-tree-build --progress-bar off .[${{ matrix.modules.module }}]
pip install --progress-bar off torch==${{ matrix.torch-version }}
pip install --progress-bar off pytest==5.1.3
pytest ${{ matrix.modules.test_file }}
docs:
needs: build
runs-on: ubuntu-latest
env:
python-version: 3.7
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip
sudo apt-get install pandoc
pip install --progress-bar off -r requirements.txt
pip install --progress-bar off -r docs/requirements.txt
git clone https://github.com/asyml/texar-pytorch.git
cd texar-pytorch
pip install --progress-bar off .
cd ..
rm -rf texar-pytorch
- name: Build Docs
run: |
cd docs
sphinx-build -W -b html -d _build/doctrees . _build/html
sphinx-build -W -b spelling -d _build/doctrees . _build/spelling
cd ..
dispatch:
needs: build
runs-on: ubuntu-latest
if: github.repository == 'asyml/forte' && github.ref == 'refs/heads/master'
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_DISPATCH_PAT_HECTOR }}
repository: asyml/forte-wrappers
event-type: trigger-forte-wrappers