Skip to content

Commit 421ef8e

Browse files
authored
Create ci.yml (#5)
Add CI! (And fix lint...)
1 parent 5b80e1a commit 421ef8e

File tree

8 files changed

+140
-17
lines changed

8 files changed

+140
-17
lines changed

.flake8

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# taken from PyTorch
2+
[flake8]
3+
select = B,C,E,F,P,T4,W,B9
4+
max-line-length = 120
5+
# C408 ignored because we like the dict keyword argument syntax
6+
# E501 is not flexible enough, we're using B950 instead
7+
ignore =
8+
E203,E305,E402,E501,E721,E741,F405,F821,F841,F999,W503,W504,C408,E302,W291,E303,
9+
# shebang has extra meaning in fbcode lints, so I think it's not worth trying
10+
# to line this up with executable bit
11+
EXE001,
12+
# these ignores are from flake8-bugbear; please fix!
13+
B007,B008,
14+
# these ignores are from flake8-comprehensions; please fix!
15+
C400,C401,C402,C403,C404,C405,C407,C411,C413,C414,C415,
16+
F403, F401 # Imports...
17+
# per-file-ignores = __init__.py: F401 torch/utils/cpp_extension.py: B950
18+
optional-ascii-coding = True
19+
exclude =
20+
./.git

.github/workflows/ci.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
on:
2+
# Trigger the workflow on push or
3+
# pull request, but only for the
4+
# master branch.
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
branches:
10+
- master
11+
# Weekly run to account for
12+
# changed dependencies.
13+
schedule:
14+
- cron: '17 03 * * 0'
15+
16+
name: CI
17+
jobs:
18+
build:
19+
name: Build and test
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
matrix:
23+
os: [ubuntu-latest]
24+
python-version:
25+
- '3.8'
26+
- '3.9'
27+
include:
28+
- os: ubuntu-20.04
29+
python-version: '3.8'
30+
installTyping: ${{ true }}
31+
fail-fast: true
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v2
36+
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v2
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
42+
- name: Cache pip
43+
uses: actions/cache@v2
44+
with:
45+
# This path is specific to Ubuntu
46+
path: ~/.cache/pip
47+
# Look to see if there is a cache hit for the corresponding requirements file
48+
key: v1-pip-${{ runner.os }}-${{ matrix.python-version }}
49+
restore-keys: |
50+
v1-pip-${{ runner.os }}
51+
v1-pip-
52+
- name: Install dependencies
53+
run: |
54+
pip install torch
55+
pip install pytest
56+
pip install codecov
57+
pip install pytest-codecov
58+
pip install tqdm
59+
# testing
60+
pip install flake8
61+
pip install scipy
62+
pip install sklearn
63+
64+
- name: Install typing for old Python
65+
run: pip install typing
66+
if: matrix.installTyping
67+
68+
- name: Lint
69+
run: python -m flake8
70+
71+
- name: Build the code
72+
run: python ./setup.py build_ext -i
73+
74+
- name: Run tests
75+
run: python -m pytest --cov-report term --cov=torchdrift test/ -v
76+
77+
- name: Cleanup
78+
run: python ./setup.py clean
79+
80+
- name: Re-build with coverage info
81+
run: CFLAGS="-coverage" python ./setup.py build_ext -i
82+
83+
- name: Test with coverage
84+
run: python -m pytest test
85+
86+
- name: Upload coverage to Codecov
87+
uses: codecov/codecov-action@v1
88+
with:
89+
#files: ./coverage1.xml,./coverage2.xml
90+
#directory: ./coverage/reports/
91+
#flags: unittests
92+
#env_vars: OS,PYTHON
93+
name: codecov-python-${{ matrix.python-version }}
94+
#fail_ci_if_error: true
95+
path_to_write_report: ./codecov-report.txt
96+
#verbose: true
97+
98+
- name: Archive code coverage result
99+
uses: 'actions/upload-artifact@v2'
100+
with:
101+
name: code-coverage-${{ matrix.os }}-${{ matrix.python-version }}
102+
path: codecov-report.txt

docs/source/conf.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
# Add any Sphinx extension module names here, as strings. They can be
2828
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2929
# ones.
30-
extensions = ['sphinx.ext.autodoc',
31-
'nbsphinx',
30+
extensions = [
31+
'sphinx.ext.autodoc',
32+
'nbsphinx',
3233
]
3334

3435
# Add any paths that contain templates here, relative to this directory.
@@ -90,7 +91,7 @@ def setup(app):
9091
'display_github': True,
9192
'github_user': 'torchdrift',
9293
'github_repo': 'torchdrift',
93-
}
94+
}
9495
html_theme_options = {
9596
'left_buttons': [],
9697
'right_buttons': ['repo-button.html', ],

setup.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
long_description = fh.read()
66

77
setuptools.setup(
8-
name='torchdrift',
9-
version='0.1.0.post1',
10-
description="Drift Detection for PyTorch",
11-
long_description=long_description,
12-
long_description_content_type='text/markdown',
13-
author='Orobix Srl and MathInf GmbH',
14-
url='https://torchdrift.org/',
15-
install_requires=['torch'],
16-
packages=setuptools.find_packages(),
17-
)
8+
name='torchdrift',
9+
version='0.1.0.post1',
10+
description="Drift Detection for PyTorch",
11+
long_description=long_description,
12+
long_description_content_type='text/markdown',
13+
author='Orobix Srl and MathInf GmbH',
14+
url='https://torchdrift.org/',
15+
install_requires=['torch'],
16+
packages=setuptools.find_packages(),
17+
)

test/test_corruption_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_gaussian_blur():
4141
assert ((a1 - a2)[:, :, 32:-32, 32:-32]).max().abs() < 1e-2
4242
with pytest.raises(RuntimeError):
4343
a3 = torchdrift.data.functional.gaussian_blur(a, severity=6)
44-
44+
4545

4646
if __name__ == "__main__":
4747
pytest.main([__file__])

test/test_detectors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
import torchdrift
33
import torch
4-
import sklearn.decomposition
54

65

76
def test_detector():

torchdrift/detectors/ks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
njit = numba.jit(nopython=True, fastmath=True)
1313
except ImportError: # pragma: no cover
14-
njit = lambda x: x
14+
def njit(x):
15+
return x
1516

1617

1718
# Numerically stable p-Value computation, see

torchdrift/utils/fit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Callable, Union, Iterable, List
1+
from typing import Optional, Union, List
22
import typing
33
from ..reducers import Reducer
44
from ..detectors import Detector

0 commit comments

Comments
 (0)