-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtasks.py
More file actions
59 lines (45 loc) · 1.14 KB
/
tasks.py
File metadata and controls
59 lines (45 loc) · 1.14 KB
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
from invoke import Collection, task
@task
def test(c, cov=False, html=False, k=None):
cmd = "uv run pytest tests/ -v"
if k:
cmd += f" -k {k}"
if cov or html:
cmd += " --cov=forge --cov-report=term-missing"
if html:
cmd += " --cov-report=html"
c.run(cmd, pty=True)
@task
def lint(c, fix=False):
cmd = "uv run ruff check ."
if fix:
cmd += " --fix"
c.run(cmd, pty=True)
@task
def format(c, check=False):
cmd = "uv run ruff format ."
if check:
cmd += " --check"
c.run(cmd, pty=True)
@task(pre=[lint, format])
def check(c):
test(c, cov=True)
@task
def setup(c, cpu=False):
extras = "--extra dev"
if not cpu:
extras += " --extra training --extra hub"
c.run(f"uv sync {extras}", pty=True)
@task
def validate(c, config):
c.run(
f"uv run python -c \"from forge.config import load_task_config; c = load_task_config('{config}'); print(c.model_dump_json(indent=2))\"",
pty=True,
)
ns = Collection()
ns.add_task(test)
ns.add_task(lint)
ns.add_task(format, name="format")
ns.add_task(check)
ns.add_task(setup)
ns.add_task(validate)