Skip to content

Commit 5851400

Browse files
authored
Curate dependencies and improve testing (#25)
* Curate dependencies and improve testing * Fix tutorials test workflow
1 parent cce7d32 commit 5851400

File tree

7 files changed

+232
-66
lines changed

7 files changed

+232
-66
lines changed

.github/workflows/tests.yml

Lines changed: 92 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,107 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
build:
11-
runs-on: ubuntu-latest
10+
lint:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
python-version: [3.8]
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
steps:
17+
- uses: actions/checkout@v1
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- if: matrix.os == 'windows-latest'
23+
name: Install dependencies - Windows
24+
run: pip install 'torch>=1,<2' -f https://download.pytorch.org/whl/torch_stable.html
25+
- name: Install package
26+
run: pip install invoke .[dev]
27+
- name: invoke lint
28+
run: invoke lint
29+
30+
readme:
31+
runs-on: ${{ matrix.os }}
1232
strategy:
1333
matrix:
1434
python-version: [3.6, 3.7, 3.8]
35+
os: [ubuntu-latest, macos-latest]
36+
steps:
37+
- uses: actions/checkout@v1
38+
- name: Set up Python ${{ matrix.python-version }}
39+
uses: actions/setup-python@v1
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
- name: Install package and dependencies
43+
run: pip install invoke rundoc .
44+
- name: invoke readme
45+
run: invoke readme
1546

47+
unit:
48+
runs-on: ${{ matrix.os }}
49+
strategy:
50+
matrix:
51+
python-version: [3.6, 3.7, 3.8]
52+
os: [ubuntu-latest, macos-latest, windows-latest]
1653
steps:
1754
- uses: actions/checkout@v1
1855
- name: Set up Python ${{ matrix.python-version }}
1956
uses: actions/setup-python@v1
2057
with:
2158
python-version: ${{ matrix.python-version }}
59+
- if: matrix.os == 'windows-latest'
60+
name: Install dependencies - Windows
61+
run: pip install 'torch>=1,<2' -f https://download.pytorch.org/whl/torch_stable.html
62+
- name: Install package and dependencies
63+
run: pip install invoke .[test]
64+
- name: invoke pytest
65+
run: invoke pytest
2266

23-
- name: Install dependencies
24-
run: |
25-
sudo apt-get install pandoc
26-
python -m pip install --upgrade pip
27-
pip install tox tox-gh-actions
67+
minimum:
68+
runs-on: ${{ matrix.os }}
69+
strategy:
70+
matrix:
71+
python-version: [3.6, 3.7, 3.8]
72+
os: [ubuntu-latest, macos-latest, windows-latest]
73+
steps:
74+
- uses: actions/checkout@v1
75+
- name: Set up Python ${{ matrix.python-version }}
76+
uses: actions/setup-python@v1
77+
with:
78+
python-version: ${{ matrix.python-version }}
79+
- if: matrix.os == 'windows-latest'
80+
name: Install dependencies - Windows
81+
run: pip install 'torch==1.4' -f https://download.pytorch.org/whl/torch_stable.html
82+
- name: Install package and dependencies
83+
run: pip install invoke .[test]
84+
- name: invoke minimum
85+
run: invoke minimum
2886

29-
- name: Test with tox
30-
run: tox
87+
tutorials:
88+
runs-on: ${{ matrix.os }}
89+
strategy:
90+
matrix:
91+
python-version: [3.6, 3.7, 3.8]
92+
os: [ubuntu-latest]
93+
steps:
94+
- uses: actions/checkout@v1
95+
- name: Set up Python ${{ matrix.python-version }}
96+
uses: actions/setup-python@v1
97+
with:
98+
python-version: ${{ matrix.python-version }}
99+
- if: matrix.os == 'ubuntu-latest'
100+
name: Install dependencies - Ubuntu
101+
run: sudo apt-get install graphviz
102+
- if: matrix.os == 'macos-latest'
103+
name: Install dependencies - MacOS
104+
run: brew install graphviz
105+
- if: matrix.os == 'windows-latest'
106+
name: Install dependencies - Windows
107+
run: |
108+
pip install 'torch>=1,<2' -f https://download.pytorch.org/whl/torch_stable.html
109+
choco install graphviz
110+
- name: Install package and dependencies
111+
run: pip install invoke jupyter .
112+
- name: invoke tutorials
113+
run: invoke tutorials

.travis.yml

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

Makefile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ lint-tests: ## check style with flake8 and isort
9797
isort -c --recursive tests
9898

9999
.PHONY: lint
100-
lint:lint-deepecho lint-tests ## Run all code style checks
100+
lint: ## Run all code style checks
101+
invoke lint
101102

102103
.PHONY: fix-lint
103104
fix-lint: ## fix lint issues using autoflake, autopep8, and isort
@@ -108,29 +109,27 @@ fix-lint: ## fix lint issues using autoflake, autopep8, and isort
108109

109110
# TEST TARGETS
110111

111-
.PHONY: test-unit
112-
test-unit: ## run tests quickly with the default Python
113-
python -m pytest --cov=deepecho
112+
.PHONY: test-pytest
113+
test-pytest: ## run all the tests using pytest
114+
invoke pytest
114115

115116
.PHONY: test-readme
116117
test-readme: ## run the readme snippets
117-
rm -rf tests/readme_test && mkdir tests/readme_test
118-
cd tests/readme_test && rundoc run --single-session python3 -t python3 ../../README.md
119-
rm -rf tests/readme_test
118+
invoke readme
120119

121120
.PHONY: test-tutorials
122121
test-tutorials: ## run the tutorial notebooks
123-
jupyter nbconvert --execute --ExecutePreprocessor.timeout=600 tutorials/*.ipynb --stdout > /dev/null
122+
invoke tutorials
124123

125124
.PHONY: check-dependencies
126125
check-dependencies: ## test if there are any broken dependencies
127126
pip check
128127

129128
.PHONY: test
130-
test: test-unit test-readme ## test everything that needs test dependencies
129+
test: test-pytest test-readme test-tutorials ## test everything that needs test dependencies
131130

132131
.PHONY: test-devel
133-
test-devel: check-dependencies lint docs ## test everything that needs development dependencies
132+
test-devel: lint docs ## test everything that needs development dependencies
134133

135134
.PHONY: test-all
136135
test-all: ## run tests on every Python version with tox

conda/meta.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,29 @@ build:
1515

1616
requirements:
1717
host:
18-
- numpy >=1.15.4,<2
19-
- pandas >=0.22,<1.1.5
2018
- pip
21-
- python
22-
- pytorch >=1,<2
23-
- tqdm >=4,<5
2419
- pytest-runner
20+
- python >=3.6,<3.9
21+
- numpy >=1.18.0,<2
22+
- pandas >=1.1,<1.1.5
23+
- pytorch >=1.4,<2
24+
- tqdm >=4.10,<5
2525
run:
26-
- numpy >=1.15.4,<2
27-
- pandas >=0.22,<1.1.5
28-
- python
29-
- pytorch >=1,<2
30-
- tqdm >=4,<5
26+
- python >=3.6,<3.9
27+
- numpy >=1.18.0,<2
28+
- pandas >=1.1,<1.1.5
29+
- pytorch >=1.4,<2
30+
- tqdm >=4.10,<5
3131

3232
about:
3333
home: "https://github.com/sdv-dev/DeepEcho"
3434
license: MIT
3535
license_family: MIT
36-
license_file:
36+
license_file:
3737
summary: "Mixed-type multivariate time series modeling with generative adversarial networks."
38-
doc_url:
39-
dev_url:
38+
doc_url:
39+
dev_url:
4040

4141
extra:
4242
recipe-maintainers:
43-
- sdv-dev
43+
- sdv-dev

setup.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
history = history_file.read()
1313

1414
install_requires = [
15-
'pandas>=1,<1.1.5',
16-
'numpy>=1.15.4,<2',
17-
'torch>=1,<2',
18-
'tqdm>=4,<5',
15+
'numpy>=1.18.0,<2',
16+
'pandas>=1.1,<1.1.5',
17+
'torch>=1.4,<2',
18+
'tqdm>=4.10,<5',
1919
]
2020

2121
setup_requires = [
@@ -25,6 +25,7 @@
2525
tests_require = [
2626
'pytest>=3.4.2',
2727
'pytest-cov>=2.6.0',
28+
'pytest-rerunfailures>=9.0.0,<10',
2829
'jupyter>=1.0.0,<2',
2930
'rundoc>=0.4.3,<0.5',
3031
]
@@ -62,6 +63,9 @@
6263
# Advanced testing
6364
'coverage>=4.5.1,<6',
6465
'tox>=2.9.1,<4',
66+
67+
# Invoking test commands
68+
'invoke'
6569
]
6670

6771
setup(

tasks.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import glob
2+
import os
3+
import re
4+
import shutil
5+
import stat
6+
from pathlib import Path
7+
8+
from invoke import task
9+
10+
11+
@task
12+
def pytest(c):
13+
c.run('python -m pytest --cov=deepecho --reruns 3')
14+
15+
16+
@task
17+
def install_minimum(c):
18+
with open('setup.py', 'r') as setup_py:
19+
lines = setup_py.read().splitlines()
20+
21+
versions = []
22+
started = False
23+
for line in lines:
24+
if started:
25+
if line == ']':
26+
break
27+
28+
line = line.strip()
29+
line = re.sub(r',?<=?[\d.]*,?', '', line)
30+
line = re.sub(r'>=?', '==', line)
31+
line = re.sub(r"""['",]""", '', line)
32+
versions.append(line)
33+
34+
elif line.startswith('install_requires = ['):
35+
started = True
36+
37+
c.run(f'python -m pip install {" ".join(versions)}')
38+
39+
40+
@task
41+
def minimum(c):
42+
install_minimum(c)
43+
c.run('python -m pip check')
44+
c.run('python -m pytest --reruns 3')
45+
46+
47+
@task
48+
def readme(c):
49+
test_path = Path('tests/readme_test')
50+
if test_path.exists() and test_path.is_dir():
51+
shutil.rmtree(test_path)
52+
53+
cwd = os.getcwd()
54+
os.makedirs(test_path, exist_ok=True)
55+
shutil.copy('README.md', test_path / 'README.md')
56+
os.chdir(test_path)
57+
c.run('rundoc run --single-session python3 -t python3 README.md')
58+
os.chdir(cwd)
59+
shutil.rmtree(test_path)
60+
61+
62+
@task
63+
def tutorials(c):
64+
for ipynb_file in glob.glob('tutorials/*.ipynb') + glob.glob('tutorials/**/*.ipynb'):
65+
if '.ipynb_checkpoints' not in ipynb_file:
66+
c.run((
67+
'jupyter nbconvert --execute --ExecutePreprocessor.timeout=3600 '
68+
f'--to=html --stdout "{ipynb_file}"'
69+
), hide='out')
70+
71+
72+
@task
73+
def lint(c):
74+
c.run('flake8 deepecho')
75+
c.run('flake8 tests --ignore=D,SFS2')
76+
c.run('isort -c --recursive deepecho tests')
77+
c.run('pylint deepecho --rcfile=setup.cfg')
78+
79+
80+
def remove_readonly(func, path, _):
81+
"Clear the readonly bit and reattempt the removal"
82+
os.chmod(path, stat.S_IWRITE)
83+
func(path)
84+
85+
86+
@task
87+
def rmdir(c, path):
88+
try:
89+
shutil.rmtree(path, onerror=remove_readonly)
90+
except PermissionError:
91+
pass

tox.ini

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
[tox]
2-
envlist = py3{6,7,8}, test-devel
2+
envlist = py3{6,7,8}-{lint,readme,pytest,minimum}
33

44
[gh-actions]
55
python =
6-
3.8: py38, test-devel
7-
3.7: py37
8-
3.6: py36
6+
3.8: py38-lint, py38-readme, py38-pytest, py38-minimum, py38-tutorials
7+
3.7: py37-lint, py37-readme, py37-pytest, py37-minimum, py37-tutorials
8+
3.6: py36-lint, py36-readme, py36-pytest, py36-minimum, py36-tutorials
99

1010
[testenv]
1111
passenv = CI TRAVIS TRAVIS_*
1212
skipsdist = false
1313
skip_install = false
14-
extras = test
14+
deps =
15+
invoke
16+
readme: rundoc
17+
extras =
18+
lint: dev
19+
pytest: test
20+
minimum: test
21+
tutorials: tutorials
1522
commands =
16-
/usr/bin/env make test
17-
18-
[testenv:test-devel]
19-
extras = dev
20-
commands =
21-
/usr/bin/env make test-devel
23+
lint: invoke lint
24+
readme: invoke readme
25+
pytest: invoke pytest
26+
minimum: invoke minimum
27+
tutorials: invoke tutorials
28+
invoke rmdir --path {envdir}

0 commit comments

Comments
 (0)