Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .github/workflows/performance-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Performance Checks

# Runs performance benchmark scripts from other_resources/performance-checks/
# manually on demand. Use the `scripts` input to choose which scripts to run.

on:
push: # TODO: consider running on a schedule (e.g. weekly) but not on every push
branches: ["main", "reroll"]
workflow_dispatch:
inputs:
scripts:
description: >-
Comma-separated list of script filenames to run from
other_resources/performance-checks/ (e.g.
"fast-channel-random.py" or "fast-channel-random.py,other-script.py").
Use "all" to run every *.py script found in that directory.
required: false
default: "all"
type: string
python-version:
description: >-
Python version to use (must be available via setup-python and
compatible with the uv.lock in this repo).
required: false
default: "3.11"
type: string

jobs:
discover:
name: Discover scripts
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.build-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v6

- name: Build script matrix
id: build-matrix
shell: python
run: |
import json, os, pathlib, sys

scripts_dir = pathlib.Path("other_resources/performance-checks")
requested = "${{ inputs.scripts }}".strip()

all_scripts = sorted(p.name for p in scripts_dir.glob("*.py"))

if not all_scripts:
print("::error::No *.py scripts found in other_resources/performance-checks/")
sys.exit(1)

# Empty string occurs on push/schedule triggers where inputs are not set;
# treat it the same as the explicit "all" keyword.
if not requested or requested.lower() == "all":
selected = all_scripts
else:
candidates = [s.strip() for s in requested.split(",") if s.strip()]
missing = [c for c in candidates if c not in all_scripts]
if missing:
print(f"::error::The following requested scripts were not found: {missing}")
print(f"::error::Available scripts: {all_scripts}")
sys.exit(1)
selected = candidates

matrix = {"script": selected}
print(f"Selected scripts: {selected}")
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
fh.write(f"matrix={json.dumps(matrix)}\n")

run-script:
name: "Run ${{ matrix.script }} (${{ matrix.os }})"
needs: discover
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
script: ${{ fromJson(needs.discover.outputs.matrix).script }}

# Force UTF-8 I/O on Windows (default console encoding is cp1252 which
# cannot represent box-drawing characters used in benchmark output).
env:
PYTHONUTF8: "1"

defaults:
run:
# bash is available on all GitHub-hosted runners (Git Bash on Windows)
# and gives us consistent behaviour for tee, path separators, etc.
shell: bash

steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python ${{ inputs.python-version || '3.11' }}
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version || '3.11' }}

- name: Install activitysim
run: |
uv sync --locked

- name: Run ${{ matrix.script }}
run: |
set -o pipefail
uv run python other_resources/performance-checks/${{ matrix.script }} \
2>&1 | tee perf-output-${{ matrix.os }}-${{ matrix.script }}.txt

- name: Upload output
if: always()
uses: actions/upload-artifact@v7
with:
# artifact names must be unique across the matrix, so include the OS
name: perf-output-${{ matrix.os }}-${{ matrix.script }}
path: perf-output-${{ matrix.os }}-${{ matrix.script }}.txt
retention-days: 90
6 changes: 0 additions & 6 deletions activitysim/abm/test/test_pipeline/output/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion activitysim/abm/test/test_pipeline/output/cache/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion activitysim/abm/test/test_pipeline/output/trace/.gitignore

This file was deleted.

Loading
Loading