Skip to content

Commit d1943d9

Browse files
committed
Add benchmarking script
- Fold CI scripts into local benchmark script - Remove CI workflow - Use importlib for pytest for identical file names across different test modules
1 parent 2b2dbcf commit d1943d9

7 files changed

Lines changed: 395 additions & 276 deletions

File tree

.github/scripts/compare_benchmarks.py

Lines changed: 0 additions & 177 deletions
This file was deleted.

.github/scripts/run_benchmarks.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/benchmark.yaml

Lines changed: 21 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,88 +2,38 @@ name: Benchmark
22

33
on:
44
pull_request:
5-
branches: [ "main" ]
5+
branches: ["main"]
66

7-
permissions:
8-
pull-requests: write
97
jobs:
10-
prep:
11-
runs-on: ubuntu-latest
12-
outputs:
13-
tag: ${{ steps.last_tag.outputs.tag }}
14-
short_sha: ${{ steps.short.outputs.sha }}
15-
steps:
16-
- uses: actions/checkout@v6
17-
with:
18-
fetch-tags: true
19-
fetch-depth: 0
20-
- id: last_tag
21-
run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
22-
- id: short
23-
run: echo "sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
24-
258
benchmark:
26-
needs: prep
279
runs-on: ubuntu-latest
28-
strategy:
29-
fail-fast: false
30-
matrix:
31-
target:
32-
- name: ${{ needs.prep.outputs.short_sha }}
33-
ref: ${{ github.sha }}
34-
- name: main
35-
ref: main
36-
# Tag comparison disabled until next release (missing benchmark dependencies)
37-
# - name: ${{ needs.prep.outputs.tag }}
38-
# ref: ${{ needs.prep.outputs.tag }}
3910
steps:
4011
- uses: actions/checkout@v6
4112
with:
42-
ref: ${{ matrix.target.ref }}
4313
submodules: true
4414
- uses: astral-sh/setup-uv@v8.1.0
45-
- run: uv sync --extra "cloud"
15+
- run: uv sync --frozen --all-extras
4616
- name: Run benchmarks
17+
id: run-benchmarks
4718
run: |
48-
FILENAME="benchmark-${{ matrix.target.name }}-PR-${{ github.event.pull_request.number }}.json"
49-
uv run .github/scripts/run_benchmarks.py --output "$FILENAME"
50-
echo "REPORT_PATH=$FILENAME" >> $GITHUB_ENV
19+
uv run python scripts/benchmark.py --branch ${{ github.sha }}
5120
- uses: actions/upload-artifact@v7
5221
with:
53-
name: benchmark-${{ matrix.target.name }}-PR-${{
54-
github.event.pull_request.number }}
55-
path: ${{ env.REPORT_PATH }}
56-
retention-days: 1
57-
overwrite: true
58-
59-
report:
60-
needs: [ prep, benchmark ]
61-
runs-on: ubuntu-latest
62-
steps:
63-
- uses: actions/checkout@v6
64-
- uses: astral-sh/setup-uv@v8.1.0
65-
- uses: actions/download-artifact@v8
66-
with:
67-
pattern: benchmark-*
68-
merge-multiple: true
69-
path: benchmark-results
70-
- name: Generate report
71-
run: |
72-
uv run .github/scripts/compare_benchmarks.py \
73-
--output "benchmarks.md" \
74-
--pattern "benchmark-results/benchmark-*-PR-${{ github.event.pull_request.number }}.json"
75-
- name: Find Comment
76-
uses: peter-evans/find-comment@v3
77-
id: fc
78-
with:
79-
issue-number: ${{ github.event.pull_request.number }}
80-
comment-author: "github-actions[bot]"
81-
body-includes: "Benchmark Results"
22+
name: benchmark-${{ matrix.target.name }}
23+
path: ${{ steps.run-benchmarks.outputs.report_file }}
8224

83-
- name: Create / update comment
84-
uses: peter-evans/create-or-update-comment@v5
85-
with:
86-
comment-id: ${{ steps.fc.outputs.comment-id }}
87-
issue-number: ${{ github.event.pull_request.number }}
88-
body-path: "benchmarks.md"
89-
edit-mode: replace
25+
# report:
26+
# needs: [benchmark]
27+
# runs-on: ubuntu-latest
28+
# steps:
29+
# - uses: actions/checkout@v6
30+
# - uses: astral-sh/setup-uv@v8.1.0
31+
# - run: uv sync --group "benchmark"
32+
# - uses: actions/download-artifact@v8
33+
# with:
34+
# pattern: benchmark-*
35+
# - name: Generate report
36+
# run: |
37+
# uv run .github/scripts/compare_benchmarks.py \
38+
# --output benchmarks.md \
39+
# --pattern benchmark-*.json

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ htmlcov
2626

2727
# Local data and scratch
2828
.scratch
29+
benchmarks/
2930

3031
# Local virtual environment
3132
.venv

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pybids = ["pandas>=2.0.0"]
3737
[dependency-groups]
3838
dev = [
3939
"pdoc>=16.0.0",
40+
"polars>=1.40.1",
4041
"pre-commit>=4.6.0",
4142
"pytest>=9.0.3",
4243
"pytest-benchmark>=5.2.3",
@@ -69,6 +70,7 @@ lint.extend-select = ["I"]
6970
[tool.pytest.ini_options]
7071
log_cli = true
7172
log_cli_level = "INFO"
73+
addopts = "--import-mode=importlib"
7274
markers = [
7375
"benchmark: Tests used for benchmarking",
7476
"cloud: Tests requiring cloud group dependencies",

0 commit comments

Comments
 (0)