-
Notifications
You must be signed in to change notification settings - Fork 14
211 lines (206 loc) · 8.44 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
name: Python Build
on:
push:
pull_request:
branches: [ main ]
repository_dispatch:
types: [ trigger-forte-wrappers ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
tmate_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.7, 3.8 ]
torch-version: [ 1.5.0, 1.7.1, 1.8.1 ]
tensorflow-version: [ 1.15.0, 2.2.0, 2.5.0]
test-details:
- { dep: "huggingface elastic nltk", testfile: tests/wrappers/bio_ner_predictor_test.py}
- { project: "stanza", dep: stanza, testfile: tests/wrappers/stanfordnlp_processor_test.py }
- { project: "spacy", dep: spacy, testfile: tests/wrappers/spacy_processors_test.py }
- { project: "allennlp", dep: "nltk allennlp", testfile: tests/wrappers/allennlp_processors_test.py}
- { project: "nltk", dep: nltk, testfile: tests/wrappers/nltk_processors_test.py }
- { project: "vader", dep: "vader nltk ", testfile: tests/wrappers/sentiment_processor_test.py }
- { project: "gpt2", dep: "nltk gpt2", extra: "termcolor>=1.1.0", testfile: examples/gpt2_test.py }
- { project: "elastic", dep: elastic, testfile: tests/wrappers/elastic_indexers_test.py }
- { project: "faiss", dep: faiss, testfile: tests/wrappers/faiss_indexers_test.py }
- { project: "huggingface", dep: "huggingface nltk", extra: "'tensorflow>=2.5.0,<2.8.0'", testfile: tests/wrappers/huggingface }
exclude:
- python-version: 3.7
torch-version: 1.7.1
- python-version: 3.7
torch-version: 1.8.1
- python-version: 3.7
tensorflow-version: 2.2.0
- python-version: 3.7
tensorflow-version: 2.5.0
- python-version: 3.8
torch-version: 1.5.0
- python-version: 3.8
tensorflow-version: 1.15.0
- python-version: 3.8
tensorflow-version: 2.5.0
# To add 3.9 tests, will need to figure out the right versions for allennlp.
# - python-version: 3.9
# torch-version: 1.5.0
# - python-version: 3.9
# tensorflow-version: 1.15.0
# - python-version: 3.9
# tensorflow-version: 2.2.0
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Format check with Black
run: |
pip install --progress-bar off black==22.3.0
black --line-length 80 --check src/
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip
pip install --progress-bar off Django django-guardian
- 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: Install Texar
run: |
git clone https://github.com/asyml/texar-pytorch.git
cd texar-pytorch
pip install --progress-bar off .
cd ..
# Remove them to avoid confusing pytest.
rm -rf texar-pytorch
- name: Setup tmate session
# Add a tmate step before the project installation.
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.tmate_enabled }}
- name: Install the project dependencies
run: |
# Install Wrappers
for d in ${{ matrix.test-details.dep }}; do pip install "src/"$d; done
# Install Extras
if [ ! -z ${{ matrix.test-details.extra }} ]
then
pip install ${{ matrix.test-details.extra }}
fi
- name: Install linting tools
run: |
# Better run after other installations (e.g. tensorflow), since those packages may ask for different versions.
pip install --progress-bar off pylint==2.15.8 flake8==5.0.4
pip install --progress-bar off mypy==0.910 pytest==5.1.3
pip install --progress-bar off coverage codecov ddt
pip install types-termcolor types-PyYAML
- name: Setup tmate session
# Add a tmate step after most of the installation.
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.tmate_enabled }}
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics
# The GitHub editor is 127 chars wide
flake8 src/ --count --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with mypy
# Lint only the project that is being installed and tested.
run: |
if [ ! -z ${{ matrix.test-details.project }} ]
then
mypy "src/"${{ matrix.test-details.project }}"/fortex"
fi
- name: Lint with pylint
# Lint only the project that is being installed and tested.
run: |
if [ ! -z ${{ matrix.test-details.project }} ]
then
mypy "src/"${{ matrix.test-details.project }}"/fortex"
fi
- name: Install Forte from source to test the latest version.
run: |
git clone https://github.com/asyml/forte.git
cd forte
pip install --progress-bar off .
cd ..
# Remove forte source to avoid pytest collecting its test files.
rm -rf forte/
- name: Start elastic server if test elastic search
if: ${{ matrix.test-details.dep == 'elastic' ||
contains(matrix.test-details.dep, 'elastic')
}}
run: |
wget -q https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.2-linux-x86_64.tar.gz
tar -zxf elasticsearch-7.4.2-linux-x86_64.tar.gz
rm -rf elasticsearch-7.4.2-linux-x86_64.tar.gz
elasticsearch-7.4.2/bin/elasticsearch -d
chmod +x tests/wait_elastic.sh
tests/wait_elastic.sh
- name: Test with pytest and run coverage
run: |
coverage run -m pytest ${{ matrix.test-details.testfile}}
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
pip install --progress-bar off -r docs/requirements.txt
# Install Wrappers
for dep in allennlp elastic faiss gpt2 huggingface nltk spacy stanza tweepy vader
do
pip install "src/"$dep
done
- name: Install Forte from source to use the latest version.
run: |
git clone https://github.com/asyml/forte.git
cd forte
pip install --progress-bar off .
- 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, docs ]
runs-on: ubuntu-latest
if: github.repository == 'asyml/forte-wrappers' && github.ref == 'refs/heads/main'
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_DISPATCH_PAT_HECTOR }}
repository: petuum/composing_information_system
event-type: trigger-composable-workflow