-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnoxfile.py
111 lines (92 loc) · 3.51 KB
/
noxfile.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from __future__ import annotations
import os
import nox
from laminci.nox import (
build_docs,
login_testuser1,
login_testuser2,
run,
run_pre_commit,
)
nox.options.default_venv_backend = "none"
COVERAGE_ARGS = "--cov=lamindb_setup --cov-append --cov-report=term-missing"
@nox.session
def lint(session: nox.Session) -> None:
run_pre_commit(session)
@nox.session
@nox.parametrize(
"group",
["hub-local", "hub-prod", "hub-cloud", "storage", "docs"],
)
def install(session: nox.Session, group: str) -> None:
no_deps_packages = "git+https://github.com/laminlabs/lamindb git+https://github.com/laminlabs/wetlab git+https://github.com/laminlabs/lamin-cli"
modules_deps = f"""uv pip install --system git+https://github.com/laminlabs/bionty
uv pip install --system --no-deps {no_deps_packages}
"""
if group == "hub-cloud":
cmds = (
modules_deps + "uv pip install --system ./laminhub/rest-hub line_profiler"
)
elif group == "docs":
cmds = """uv pip install --system git+https://github.com/laminlabs/lamindb"""
elif group == "storage":
cmds = modules_deps + "uv pip install --system gcsfs huggingface_hub"
elif group == "hub-prod":
# cmds = "git clone --depth 1 https://github.com/django/django\n"
# cmds += "uv pip install --system -e ./django\n"
cmds = ""
cmds += modules_deps.strip()
cmds += """\nuv pip install --system huggingface_hub"""
elif group == "hub-local":
cmds = modules_deps.strip()
# current package
cmds += """\nuv pip install --system -e '.[aws,dev]'"""
# above downgrades django, I don't understand why, try this
if group == "hub-local":
cmds += "\nuv pip install --system -e ./laminhub/rest-hub line_profiler"
[run(session, line) for line in cmds.splitlines()]
@nox.session
@nox.parametrize(
"group",
["hub-prod", "hub-cloud"],
)
@nox.parametrize(
"lamin_env",
["staging", "prod"],
)
def build(session: nox.Session, group: str, lamin_env: str):
env = {"LAMIN_ENV": lamin_env, "LAMIN_TESTING": "true"}
login_testuser1(session, env=env)
login_testuser2(session, env=env)
if group == "hub-prod":
run(session, f"pytest {COVERAGE_ARGS} ./tests/hub-prod", env=env)
run(session, f"pytest -s {COVERAGE_ARGS} ./docs/hub-prod", env=env)
elif group == "hub-cloud":
run(session, f"pytest {COVERAGE_ARGS} ./tests/hub-cloud", env=env)
run(session, f"pytest -s {COVERAGE_ARGS} ./docs/hub-cloud", env=env)
@nox.session
def hub_local(session: nox.Session):
os.environ["AWS_SECRET_ACCESS_KEY_DEV_S3"] = os.environ["AWS_ACCESS_KEY_ID"]
# the -n 1 is to ensure that supabase thread exits properly
run(
session,
f"pytest -n 1 {COVERAGE_ARGS} ./tests/hub-local",
env=os.environ,
)
@nox.session
def storage(session: nox.Session):
# we need AWS to retrieve credentials for testuser1, but want to eliminate
# them after that
os.environ["AWS_ACCESS_KEY_ID"] = os.environ["TMP_AWS_ACCESS_KEY_ID"]
os.environ["AWS_SECRET_ACCESS_KEY"] = os.environ["TMP_AWS_SECRET_ACCESS_KEY"]
login_testuser1(session)
# mimic anonymous access
del os.environ["AWS_ACCESS_KEY_ID"]
del os.environ["AWS_SECRET_ACCESS_KEY"]
run(session, f"pytest {COVERAGE_ARGS} ./tests/storage", env=os.environ)
@nox.session
def docs(session: nox.Session):
import lamindb_setup as ln_setup
login_testuser1(session)
ln_setup.init(storage="./docsbuild")
build_docs(session, strip_prefix=True)