Skip to content

Commit 49eeb0f

Browse files
standard-tests: add benchmarks (#31302)
Co-authored-by: Sydney Runkle <[email protected]>
1 parent 6d39e59 commit 49eeb0f

32 files changed

+5467
-217
lines changed

.github/scripts/check_diff.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ def _get_configs_for_single_dir(job: str, dir_: str) -> List[Dict[str, str]]:
119119
if job == "test-pydantic":
120120
return _get_pydantic_test_configs(dir_)
121121

122-
if dir_ == "libs/core":
122+
if job == "codspeed":
123+
py_versions = ["3.12"] # 3.13 is not yet supported
124+
elif dir_ == "libs/core":
123125
py_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"]
124126
# custom logic for specific directories
125127
elif dir_ == "libs/partners/milvus":
@@ -210,6 +212,8 @@ def _get_configs_for_multi_dirs(
210212
)
211213
elif job == "extended-tests":
212214
dirs = list(dirs_to_run["extended-test"])
215+
elif job == "codspeed":
216+
dirs = list(dirs_to_run["codspeed"])
213217
else:
214218
raise ValueError(f"Unknown job: {job}")
215219

@@ -225,6 +229,7 @@ def _get_configs_for_multi_dirs(
225229
"lint": set(),
226230
"test": set(),
227231
"extended-test": set(),
232+
"codspeed": set(),
228233
}
229234
docs_edited = False
230235

@@ -248,6 +253,8 @@ def _get_configs_for_multi_dirs(
248253
dirs_to_run["extended-test"].update(LANGCHAIN_DIRS)
249254
dirs_to_run["lint"].add(".")
250255

256+
if file.startswith("libs/core"):
257+
dirs_to_run["codspeed"].add(f"libs/core")
251258
if any(file.startswith(dir_) for dir_ in LANGCHAIN_DIRS):
252259
# add that dir and all dirs after in LANGCHAIN_DIRS
253260
# for extended testing
@@ -286,6 +293,7 @@ def _get_configs_for_multi_dirs(
286293
if not filename.startswith(".")
287294
] != ["README.md"]:
288295
dirs_to_run["test"].add(f"libs/partners/{partner_dir}")
296+
dirs_to_run["codspeed"].add(f"libs/partners/{partner_dir}")
289297
# Skip if the directory was deleted or is just a tombstone readme
290298
elif file == "libs/packages.yml":
291299
continue
@@ -311,6 +319,7 @@ def _get_configs_for_multi_dirs(
311319
"compile-integration-tests",
312320
"dependencies",
313321
"test-pydantic",
322+
"codspeed",
314323
]
315324
}
316325
map_job_to_configs["test-doc-imports"] = (

.github/workflows/check_diffs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ jobs:
152152
# grep will exit non-zero if the target message isn't found,
153153
# and `set -e` above will cause the step to fail.
154154
echo "$STATUS" | grep 'nothing to commit, working tree clean'
155+
155156
ci_success:
156157
name: "CI Success"
157158
needs: [build, lint, test, compile-integration-tests, extended-tests, test-doc-imports, test-pydantic]

.github/workflows/codspeed.yml

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,73 @@ on:
77
pull_request:
88
paths:
99
- 'libs/core/**'
10-
# `workflow_dispatch` allows CodSpeed to trigger backtest
11-
# performance analysis in order to generate initial data.
10+
- 'libs/partners/**'
11+
1212
workflow_dispatch:
1313

14+
env:
15+
AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }}
16+
AZURE_OPENAI_API_BASE: ${{ secrets.AZURE_OPENAI_API_BASE }}
17+
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_CHAT_DEPLOYMENT_NAME }}
18+
AZURE_OPENAI_LEGACY_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_LEGACY_CHAT_DEPLOYMENT_NAME }}
19+
DEEPSEEK_API_KEY: foo
20+
FIREWORKS_API_KEY: foo
21+
1422
jobs:
23+
prepare_matrix:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v6
29+
with:
30+
python-version: "3.12"
31+
- id: files
32+
uses: Ana06/[email protected]
33+
- id: set-matrix
34+
run: |
35+
uv venv
36+
uv pip install packaging requests
37+
uv run .github/scripts/check_diff.py ${{ steps.files.outputs.all }} >> $GITHUB_OUTPUT
38+
outputs:
39+
codspeed: ${{ steps.set-matrix.outputs.codspeed }}
1540
codspeed:
1641
name: Run benchmarks
17-
if: (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-codspeed-benchmarks')) || github.event_name == 'workflow_dispatch' || github.event_name == 'push'
42+
needs: [ prepare_matrix ]
43+
if: ${{ needs.prepare_matrix.outputs.codspeed != '[]' }}
1844
runs-on: ubuntu-latest
45+
strategy:
46+
matrix:
47+
job-configs: ${{ fromJson(needs.prepare_matrix.outputs.codspeed) }}
48+
fail-fast: false
49+
1950
steps:
2051
- uses: actions/checkout@v4
2152

22-
# We have to use 3.12, 3.13 is not yet supported
53+
# We have to use 3.12 as 3.13 is not yet supported
2354
- name: Install uv
2455
uses: astral-sh/setup-uv@v6
2556
with:
26-
python-version: "3.12"
57+
python-version: ${{ matrix.job-configs.python-version }}
2758

28-
# Using this action is still necessary for CodSpeed to work
2959
- uses: actions/setup-python@v5
3060
with:
31-
python-version: "3.12"
61+
python-version: ${{ matrix.job-configs.python-version }}
3262

33-
- name: install deps
63+
- name: Install dependencies
3464
run: uv sync --group test
35-
working-directory: ./libs/core
65+
working-directory: ${{ matrix.job-configs.working-directory }}
3666

37-
- name: Run benchmarks
67+
- name: Run benchmarks ${{ matrix.job-configs.working-directory }}
3868
uses: CodSpeedHQ/action@v3
3969
with:
4070
token: ${{ secrets.CODSPEED_TOKEN }}
4171
run: |
42-
cd libs/core
43-
uv run --no-sync pytest ./tests/benchmarks --codspeed
44-
mode: walltime
72+
cd ${{ matrix.job-configs.working-directory }}
73+
if [ "${{ matrix.job-configs.working-directory }}" = "libs/core" ]; then
74+
uv run --no-sync pytest ./tests/benchmarks --codspeed
75+
else
76+
uv run --no-sync pytest ./tests/ --codspeed
77+
fi
78+
mode: ${{ matrix.job-configs.working-directory == 'libs/core' && 'walltime' || 'instrumentation' }}
79+

0 commit comments

Comments
 (0)