Skip to content

Commit c5bfb09

Browse files
committed
Remove GitLab CI, introduce GitHub CI
Also removes legacy test.py and brings tools/ upto lint standards. Also adds full lint tests in pre-push
1 parent 96050b6 commit c5bfb09

10 files changed

Lines changed: 105 additions & 148 deletions

File tree

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ ignore = E203, E266, E501, W503
55
max-line-length = 80
66
max-complexity = 18
77
select = B,C,E,F,W,T4,B9
8+
exclude = tools/kaldi_decoder

.github/workflows/pythonapp.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SpeechBrain lint and unit tests to ease continuous integration
2+
# NOTE: Caching these offers no speedup
3+
name: SpeechBrain toolkit CI
4+
5+
# Runs on pushes to master and all pull requests
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
11+
jobs:
12+
linters:
13+
name: Linters
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python 3.7
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: 3.7
21+
- name: Lint dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install -r lint-requirements.txt
25+
- name: Show errors separately
26+
uses: samuelmeuli/lint-action@v1
27+
with:
28+
github_token: ${{ secrets.github_token }}
29+
# Enable linters
30+
black: true
31+
flake8: true
32+
- name: Run lint again for error code
33+
run: |
34+
flake8 . --count --show-source --statistics
35+
black --check --diff .
36+
37+
unittests:
38+
name: Unit Tests
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Set up Python 3.7
43+
uses: actions/setup-python@v1
44+
with:
45+
python-version: 3.7
46+
- name: Install libsndfile
47+
run: |
48+
sudo apt-get install -y libsndfile1
49+
- name: Full dependencies
50+
run: |
51+
pip install -r requirements.txt
52+
pip install --editable .
53+
- name: Unittests with pytest
54+
run: |
55+
pytest tests
56+
- name: Doctests with pytest
57+
run: |
58+
pytest --doctest-modules speechbrain

.gitlab-ci.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.pre-push-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
repos:
2+
- repo: local
3+
hooks:
4+
- id: flake8-lint
5+
name: flake8-lint
6+
entry: flake8 . --count --show-source --statistics
7+
language: python
8+
pass_filenames: false
9+
always_run: true
10+
require_serial: false
11+
12+
- repo: local
13+
hooks:
14+
- id: black-lint
15+
name: black-lint
16+
entry: black --check --diff .
17+
language: python
18+
pass_filenames: false
19+
always_run: true
20+
require_serial: false
21+
222
- repo: local
323
hooks:
424
- id: unittests

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exclude = '''
1010
| \.mypy_cache
1111
| \.tox
1212
| \.venv
13+
| tools/kaldi_decoder
1314
)/
1415
)
1516
'''

setup.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env python3
22
from distutils.core import setup
33

4-
setup(name="SpeechBrain",
5-
version="0.0.1",
6-
description="All-in-one speech toolkit in pure Python and Pytorch",
7-
author="Mirco Ravanelli",
8-
author_email = "[email protected]",
9-
packages = ["speechbrain"],
10-
python_requires = ">=3.6",
4+
setup(
5+
name="SpeechBrain",
6+
version="0.0.1",
7+
description="All-in-one speech toolkit in pure Python and Pytorch",
8+
author="Mirco Ravanelli",
9+
author_email="[email protected]",
10+
packages=["speechbrain"],
11+
python_requires=">=3.6",
1112
)

test.py

Lines changed: 0 additions & 104 deletions
This file was deleted.

tools/compute_wer.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/usr/bin/env python3
2-
import sys
3-
import collections
42
import speechbrain.utils.edit_distance as edit_distance
53
import speechbrain.data_io.wer as wer_io
64

@@ -47,6 +45,7 @@ def _utt2spk_keydict(path):
4745
utt2spk[utt] = spk
4846
return utt2spk
4947

48+
5049
if __name__ == "__main__":
5150
import argparse
5251

@@ -58,8 +57,10 @@ def _split_lines(self, text, width):
5857
return argparse.HelpFormatter._split_lines(self, text, width)
5958

6059
parser = argparse.ArgumentParser(
61-
description=("Compute word error rate or a Levenshtein alignment"
62-
"between a hypothesis and a reference."),
60+
description=(
61+
"Compute word error rate or a Levenshtein alignment"
62+
"between a hypothesis and a reference."
63+
),
6364
formatter_class=SmartFormatter,
6465
)
6566
parser.add_argument(
@@ -89,14 +90,18 @@ def _split_lines(self, text, width):
8990
parser.add_argument(
9091
"--print-alignments",
9192
action="store_true",
92-
help=("Print alignments for between all refs and hyps."
93-
"Also has details for individual hyps. Outputs a lot of text."),
93+
help=(
94+
"Print alignments for between all refs and hyps."
95+
"Also has details for individual hyps. Outputs a lot of text."
96+
),
9497
)
9598
parser.add_argument(
9699
"--align-separator",
97100
default=" ; ",
98-
help=("When printing alignments, separate tokens with this."
99-
"Note the spaces in the default."),
101+
help=(
102+
"When printing alignments, separate tokens with this."
103+
"Note the spaces in the default."
104+
),
100105
)
101106
parser.add_argument(
102107
"--align_empty",

tools/merge_scp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
from utils import scp_to_dict, dict_to_str, logger_write
2525

2626

27-
if __name__ == '__main__':
27+
if __name__ == "__main__":
2828

2929
scp_lst = sys.argv[1:]
3030

3131
# Check if the input scp files exist
3232
for inp_scp_file in scp_lst[:-1]:
33-
if not(os.path.isfile(inp_scp_file)):
33+
if not (os.path.isfile(inp_scp_file)):
3434
err_msg = 'the file "%s" does not exist' % (inp_scp_file)
3535
logger_write(err_msg)
3636

tools/visualize_pkl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
import sys
1919
import pickle
2020

21-
if __name__ == '__main__':
21+
if __name__ == "__main__":
2222

2323
# Try to import matplotlib.pyplot
2424
try:
2525

2626
import matplotlib.pyplot as plt
2727

2828
except Exception:
29-
err_msg = 'cannot import matplotlib. Make sure it is installed.'
29+
err_msg = "cannot import matplotlib. Make sure it is installed."
3030
raise
3131

3232
for pkl_file in sys.argv[1:]:

0 commit comments

Comments
 (0)