Skip to content

Commit d2380d0

Browse files
authored
Merge branch 'main' into feat/producer-graph
2 parents 4c12ed0 + e597f92 commit d2380d0

21 files changed

Lines changed: 907 additions & 12 deletions

File tree

.github/workflows/benchmarks.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Benchmarks
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
jobs:
10+
lint:
11+
name: Benchmark tests
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python_version: [3.12]
16+
steps:
17+
- name: Checkout branch
18+
uses: actions/checkout@v4
19+
with:
20+
path: pr
21+
22+
- name: Checkout main
23+
uses: actions/checkout@v4
24+
with:
25+
ref: main
26+
path: main
27+
28+
- name: Install python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{matrix.python_version}}
32+
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v4
35+
with:
36+
enable-cache: true
37+
cache-dependency-glob: "main/uv.lock"
38+
39+
- name: Setup benchmarks
40+
run: |
41+
echo "BASE_SHA=$(echo ${{ github.event.pull_request.base.sha }} | cut -c1-8)" >> $GITHUB_ENV
42+
echo "HEAD_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-8)" >> $GITHUB_ENV
43+
echo "PR_COMMENT=$(mktemp)" >> $GITHUB_ENV
44+
45+
- name: Run benchmarks on PR
46+
working-directory: ./pr
47+
run: |
48+
uv sync --group test
49+
uv run pytest --benchmark-only --benchmark-save=pr
50+
51+
- name: Run benchmarks on main
52+
working-directory: ./main
53+
continue-on-error: true
54+
run: |
55+
uv sync --group test
56+
uv run pytest --benchmark-only --benchmark-save=base
57+
58+
- name: Compare results
59+
continue-on-error: false
60+
run: |
61+
uvx pytest-benchmark compare **/.benchmarks/**/*.json | tee cmp_results
62+
63+
echo 'Benchmark comparison for [`${{ env.BASE_SHA }}`](${{ github.event.repository.html_url }}/commit/${{ github.event.pull_request.base.sha }}) (base) vs [`${{ env.HEAD_SHA }}`](${{ github.event.repository.html_url }}/commit/${{ github.event.pull_request.head.sha }}) (PR)' >> pr_comment
64+
echo '```' >> pr_comment
65+
cat cmp_results >> pr_comment
66+
echo '```' >> pr_comment
67+
cat pr_comment > ${{ env.PR_COMMENT }}
68+
69+
- name: Comment on PR
70+
uses: actions/github-script@v7
71+
with:
72+
github-token: ${{ secrets.GITHUB_TOKEN }}
73+
script: |
74+
github.rest.issues.createComment({
75+
issue_number: context.issue.number,
76+
owner: context.repo.owner,
77+
repo: context.repo.repo,
78+
body: require('fs').readFileSync('${{ env.PR_COMMENT }}').toString()
79+
});
80+

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ coverage.json
5454
.pytest_cache/
5555
cover/
5656

57+
# Benchmarking
58+
.benchmarks/
59+
5760
# Translations
5861
*.mo
5962
*.pot
@@ -166,3 +169,6 @@ cython_debug/
166169

167170
# MacOS
168171
.DS_Store
172+
173+
# Optuna database files
174+
*.db

docs/examples/tutorials/hello-world.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ In many cases, we want to define components once, with suitable parameters, and
5555
!!! note
5656
Notice how we use `type` to tell Plugboard where our components are defined within Python code (within the `hello_world` module). Creating models in yaml format like this also makes it easy to track and adjust their configurable parameters: try editing the file path or `iters` parameter to change the behaviour of the model.
5757

58+
!!! tip
59+
If you have already defined a model in code, you can export it to YAML by calling the [`dump`][plugboard.process.Process.dump] method on your [`Process`][plugboard.process.Process] object.
60+
5861
We can now run this model using the plugboard CLI with the command:
5962
```shell
6063
plugboard process run model.yaml
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tags:
2+
- optimisation

0 commit comments

Comments
 (0)