-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtasks.py
97 lines (78 loc) · 1.71 KB
/
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
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
"""
tasks to kick-off the project
"""
from invoke import task
@task
def formatter(tsk, fix=False):
"""
python format
"""
auto_fix = "" if fix else "--check --diff"
cmd = " && ".join(
[
f"python -m black . {auto_fix}",
]
)
tsk.run(cmd, echo=True, pty=True)
@task
def lint(tsk, fix=False):
"""
python lint
"""
flags = "--fix" if fix else ""
cmd = " && ".join(
[
f"ruff *.py {flags} ai21_tokenizer/ tests/",
]
)
tsk.run(cmd, echo=True, pty=True)
@task(optional=["coverage"], help={"coverage": "[true|false]"})
def test(tsk, coverage=False):
"""
Run unit tests
"""
cov = "--cov --cov-report=term-missing" if coverage else ""
cmd = f"poetry run pytest {cov}"
tsk.run(cmd, echo=True, pty=True)
@task
def audit(tsk):
"""
Run audit check on the dependent packages
"""
cmd = "safety check --full-report"
tsk.run(cmd, echo=True, pty=True)
@task
def staticcheck(tsk):
"""
Run static check on the projects files
"""
cmd = "mypy ai21_tokenizer tests"
tsk.run(cmd, echo=True, pty=True)
@task
def isort(tsk):
"""
Run static check on the projects files
"""
cmd = "isort ai21_tokenizer tests"
tsk.run(cmd, echo=True, pty=True)
@task
def build(tsk):
"""
generate a package for ai21_tokenizer
"""
cmd = "poetry build"
tsk.run(cmd, echo=True, pty=True)
@task
def update(tsk):
"""
update outdated packages
"""
cmd = "poetry update"
tsk.run(cmd, echo=True, pty=True)
@task
def outdated(tsk):
"""
update outdated packages
"""
cmd = "poetry show --outdated --top-level"
tsk.run(cmd, echo=True, pty=True)