-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtasks.py
81 lines (58 loc) · 1.68 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
from invoke import Collection, Exit, task
# Root invoke namespace.
ns = Collection()
###############
# Setup #
###############
@task
def install(c):
"""Install the project into the current environment."""
c.run("python -m pip install --upgrade pip")
c.run("python -m pip install -r requirements.txt")
c.run("python -m spacy download en_core_web_sm")
c.run("python -W ignore -m nltk.downloader punkt cmudict")
ns.add_task(install)
###############
# Code health #
###############
@task
def presubmit_black(c, fix=False):
"""Lint with black."""
cmd = "python -m black remedi scripts --config pyproject.toml"
if not fix:
cmd += " --check"
c.run(cmd)
@task
def presubmit_isort(c, fix=False):
"""Lint with isort."""
cmd = "python -m isort remedi scripts"
if not fix:
cmd += " --check"
c.run(cmd)
@task
def presubmit_mypy(c):
"""Run mypy type checker."""
c.run("python -m mypy remedi scripts")
@task
def presubmit_pytest(c):
"""Run pytest for all unit tests."""
c.run("python -m pytest tests")
@task
def presubmit(c, fix=False):
"""Run lint, testing, and type checking."""
presubmit_black(c, fix=fix)
presubmit_isort(c, fix=fix)
presubmit_mypy(c)
presubmit_pytest(c)
ns_presubmit = Collection("presubmit")
ns_presubmit.add_task(presubmit_black, "black")
ns_presubmit.add_task(presubmit_isort, "isort")
ns_presubmit.add_task(presubmit_mypy, "mypy")
ns_presubmit.add_task(presubmit_pytest, "pytest")
ns_presubmit.add_task(presubmit, default=True)
ns.add_collection(ns_presubmit)
###############
# Experiments #
###############
import experiments
ns.add_collection(Collection.from_module(experiments))