-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathnoxfile.py
141 lines (121 loc) · 4.1 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import os
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",
"langchain_nvidia_ai_endpoints",
"litellm",
"notdiamond",
"google_ai_studio",
"bedrock",
"scorers",
"crewai",
]
PY39_INCOMPATIBLE_SHARDS = ["crewai", "google_genai"]
@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",
[
# The `custom` shard is included if you want to run your own tests. By default,
# no tests are specified, which means ALL tests will run. To run just your own
# subset, you can pass `-- test_your_thing.py` to nox.
# For example,
# nox -e "tests-3.12(shard='custom')" -- test_your_thing.py
"custom",
"trace",
"trace_server",
"anthropic",
"cerebras",
"cohere",
"crewai",
"dspy",
"google_ai_studio",
"google_genai",
"groq",
"instructor",
"langchain_nvidia_ai_endpoints",
"langchain",
"litellm",
"llamaindex",
"mistral0",
"mistral1",
"notdiamond",
"openai",
"openai_agents",
"vertexai",
"bedrock",
"scorers",
"pandas-test",
"huggingface",
],
)
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")
if session.python.startswith("3.9") and shard in PY39_INCOMPATIBLE_SHARDS:
session.skip(f"Skipping {shard=} as it is not compatible with Python 3.9")
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",
"DD_TRACE_ENABLED",
]
}
# Add the GOOGLE_API_KEY environment variable for the "google" shard
if shard in ["google_ai_studio", "google_genai"]:
env["GOOGLE_API_KEY"] = session.env.get("GOOGLE_API_KEY")
if shard == "google_ai_studio":
env["GOOGLE_API_KEY"] = os.getenv("GOOGLE_API_KEY", "MISSING")
# Add the NVIDIA_API_KEY environment variable for the "langchain_nvidia_ai_endpoints" shard
if shard == "langchain_nvidia_ai_endpoints":
env["NVIDIA_API_KEY"] = os.getenv("NVIDIA_API_KEY", "MISSING")
# we are doing some integration test in test_llm_integrations.py that requires
# setting some environment variables for the LLM providers
if shard == "scorers":
env["GOOGLE_API_KEY"] = os.getenv("GOOGLE_API_KEY", "MISSING")
env["GEMINI_API_KEY"] = os.getenv("GEMINI_API_KEY", "MISSING")
env["ANTHROPIC_API_KEY"] = os.getenv("ANTHROPIC_API_KEY", "MISSING")
env["MISTRAL_API_KEY"] = os.getenv("MISTRAL_API_KEY", "MISSING")
env["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY", "MISSING")
if shard == "openai_agents":
env["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY", "MISSING")
default_test_dirs = [f"integrations/{shard}/"]
test_dirs_dict = {
"custom": [],
"trace": ["trace/"],
"trace_server": ["trace_server/"],
"mistral0": ["integrations/mistral/v0/"],
"mistral1": ["integrations/mistral/v1/"],
"scorers": ["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",
"--strict-markers",
"--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