Re-implement benchmarks in pytest #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PR half of the bare metal benchmark pipeline: build the benchmark image and hand | ||
| # it off as an artifact. Nothing here needs (or is given) the Bencher API key. | ||
| # | ||
| # `pull_request` runs fork code, so it gets no secrets. benchmarks_track.yml picks | ||
| # the artifact up on `workflow_run` and does the pushing and reporting. The fork's | ||
| # code is only ever executed here (building the image) and inside Bencher's | ||
| # sandboxed runner — never in the trusted context that holds the key. | ||
| name: Benchmarks (PR) | ||
| on: | ||
| pull_request: | ||
| permissions: {} | ||
| env: | ||
| PYBAMM_DISABLE_TELEMETRY: "true" | ||
| FORCE_COLOR: 3 | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| changes: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: read | ||
| contents: read | ||
| outputs: | ||
| benchmark: ${{ steps.filter.outputs.benchmark }} | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2 | ||
| id: filter | ||
| with: | ||
| filters: | | ||
| benchmark: | ||
| - 'packages/pybamm/**' | ||
| - 'packages/pybammsolvers/**' | ||
| - 'pyproject.toml' | ||
| - 'uv.lock' | ||
| - 'noxfile.py' | ||
| - '.github/workflows/benchmarks_pr.yml' | ||
| - '.github/workflows/benchmarks_track.yml' | ||
| build_solver: | ||
| needs: changes | ||
| if: needs.changes.outputs.benchmark == 'true' | ||
| permissions: | ||
| contents: read | ||
| uses: ./.github/workflows/_build_solver_wheels.yml | ||
| with: | ||
| cache_wheels: true | ||
| build_sdist: false | ||
| platforms: '["linux"]' | ||
| macos_runners: '[]' | ||
| build_image: | ||
| name: Build benchmark image | ||
| needs: [changes, build_solver] | ||
| if: needs.changes.outputs.benchmark == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Check out PyBaMM repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Download in-repo solver wheels | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: wheels_manylinux | ||
| path: solver-wheels | ||
| - name: Build benchmark image | ||
| run: | | ||
| docker build \ | ||
| --file packages/pybamm/tests/benchmarks/Dockerfile \ | ||
| --tag pybamm-benchmarks:pr \ | ||
| . | ||
| # zstd rather than the upload action's zip: the layers are already | ||
| # compressed, so deflate costs minutes and saves little. | ||
| - name: Export benchmark image | ||
| run: docker save pybamm-benchmarks:pr | zstd -T0 -3 -o benchmark-image.tar.zst | ||
| - name: Upload benchmark image | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: benchmark-image | ||
| path: benchmark-image.tar.zst | ||
| compression-level: 0 | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
| # benchmarks_track.yml runs on `workflow_run`, whose payload describes this | ||
| # workflow rather than the pull request; it reads the PR refs back from here. | ||
| - name: Upload pull request event | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: pr-event | ||
| path: ${{ github.event_path }} | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
| # Memory benchmarks assert against fixed memray limits rather than tracking a | ||
| # series, so they stay on the GitHub runner — bare metal buys them nothing. | ||
| benchmark_memory: | ||
| name: Memory benchmarks | ||
| needs: [changes, build_solver] | ||
| if: needs.changes.outputs.benchmark == 'true' | ||
| permissions: | ||
| contents: read | ||
| uses: ./.github/workflows/_nox.yml | ||
| with: | ||
| sessions: benchmark-memory | ||
| legs: '[{"os": "ubuntu-latest", "python": "3.13"}]' | ||
| job_name: Memory benchmarks | ||
|
Check failure on line 123 in .github/workflows/benchmarks_pr.yml
|
||
| texlive: false | ||