-
Notifications
You must be signed in to change notification settings - Fork 62
/
noxfile.py
105 lines (90 loc) · 2.73 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
import nox
nox.options.default_venv_backend = "uv"
SUPPORTED_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]
PY313_INCOMPATIBLE_SHARDS = [
"anthropic",
"cohere",
"dspy",
"langchain",
"litellm",
"notdiamond",
"google_ai_studio",
"scorers_tests",
]
@nox.session
def lint(session):
session.install("pre-commit", "jupyter")
session.run("pre-commit", "run", "--hook-stage=pre-push", "--all-files")
@nox.session(python=SUPPORTED_PYTHON_VERSIONS)
@nox.parametrize(
"shard",
[
"trace",
"trace_server",
"anthropic",
"cerebras",
"cohere",
"dspy",
"google_ai_studio",
"groq",
"instructor",
"langchain",
"litellm",
"llamaindex",
"mistral0",
"mistral1",
"notdiamond",
"openai",
"scorers_tests",
"pandas-test",
],
)
def tests(session, shard):
if session.python.startswith("3.13") and shard in PY313_INCOMPATIBLE_SHARDS:
session.skip(f"Skipping {shard=} as it is not compatible with Python 3.13")
session.install("-e", f".[{shard},test]")
session.chdir("tests")
env = {
k: session.env.get(k)
for k in [
"WEAVE_SENTRY_ENV",
"CI",
"WB_SERVER_HOST",
"WF_CLICKHOUSE_HOST",
"WEAVE_SERVER_DISABLE_ECOSYSTEM",
]
}
# Add the GOOGLE_API_KEY environment variable for the "google" shard
if shard == "google_ai_studio":
env["GOOGLE_API_KEY"] = session.env.get("GOOGLE_API_KEY")
# we are doing some integration test in test_llm_integrations.py that requires
# setting some environment variables for the LLM providers
if shard == "scorers_tests":
env["GOOGLE_API_KEY"] = session.env.get("GOOGLE_API_KEY")
env["ANTHROPIC_API_KEY"] = session.env.get("ANTHROPIC_API_KEY")
env["MISTRAL_API_KEY"] = session.env.get("MISTRAL_API_KEY")
env["OPENAI_API_KEY"] = session.env.get("OPENAI_API_KEY")
default_test_dirs = [f"integrations/{shard}/"]
test_dirs_dict = {
"trace": ["trace/"],
"trace_server": ["trace_server/"],
"mistral0": ["integrations/mistral/v0/"],
"mistral1": ["integrations/mistral/v1/"],
"scorers_tests": ["scorers/"],
}
test_dirs = test_dirs_dict.get(shard, default_test_dirs)
# seems to resolve ci issues
if shard == "llamaindex":
session.posargs.insert(0, "-n4")
session.run(
"pytest",
"--cov=weave",
"--cov-report=html",
"--cov-branch",
*session.posargs,
*test_dirs,
env=env,
)
# Configure pytest
nox.options.reuse_existing_virtualenvs = True
nox.options.stop_on_first_error = True