forked from sdv-dev/CTGAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
47 lines (35 loc) · 966 Bytes
/
tasks.py
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
import os
import shutil
import stat
from pathlib import Path
from invoke import task
@task
def pytest(c):
c.run('python -m pytest --cov=ctgan')
@task
def readme(c):
test_path = Path('tests/readme_test')
if test_path.exists() and test_path.is_dir():
shutil.rmtree(test_path)
cwd = os.getcwd()
os.makedirs(test_path, exist_ok=True)
shutil.copy('README.md', test_path / 'README.md')
os.chdir(test_path)
c.run('rundoc run --single-session python3 -t python3 README.md')
os.chdir(cwd)
shutil.rmtree(test_path)
@task
def lint(c):
c.run('flake8 ctgan')
c.run('flake8 tests --ignore=D,SFS2')
c.run('isort -c --recursive ctgan tests')
def remove_readonly(func, path, _):
"Clear the readonly bit and reattempt the removal"
os.chmod(path, stat.S_IWRITE)
func(path)
@task
def rmdir(c, path):
try:
shutil.rmtree(path, onerror=remove_readonly)
except PermissionError:
pass