Skip to content

Commit

Permalink
Merge branch 'develop' into release/1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
davidorme committed May 15, 2024
2 parents a8c081f + 290938a commit 5758f3c
Show file tree
Hide file tree
Showing 5 changed files with 1,679 additions and 2,032 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/pyrealm_profiling_after_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Profiling after push

# This runs when code is pushed to main or develop
on:
push:
branches: [main, develop]

jobs:
test:
uses: ./.github/workflows/pyrealm_ci.yaml
secrets: inherit

profiling:
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.2.2

- name: Install dependencies and add env vars
run: |
poetry install
sudo apt-get install graphviz
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Run the profiling test suite, using time to get peak memory usage
id: profiling
run: poetry run /usr/bin/time -v pytest -m "profiling" --profile-svg

# This step only runs if the profiling succeeds
- name: Benchmark performance
id: benchmarking
if: ${{steps.profiling.outcome == 'success'}}
run: poetry run python profiling/run_benchmarking.py prof/combined.prof profiling/profiling-database.csv profiling/benchmark-fails.csv ${{ env.COMMIT_SHORT_SHA }} --update-on-pass --plot-path profiling/performance-plot.png

# This step copies over the updated call graph
- name: Copy call graph
id: update-call-graph
if: always() && steps.benchmarking.outcome != 'skipped'
run: cp prof/combined.svg profiling/call-graph.svg

# Creates a PR to update the profiling stats if the benchmark passes or fails and
# skips if the profiling step fails.
- name: Create pull request
id: cpr
if: always() && steps.benchmarking.outcome != 'skipped'
uses: peter-evans/create-pull-request@v6
with:
commit-message: Updating profiling stats for ${{ env.COMMIT_SHORT_SHA }}
title: Updating profiling stats for ${{ env.COMMIT_SHORT_SHA }}
add-paths: profiling/*
body: |
Automatic update of profiling stats.
- Profiling update for merge of ${{ env.COMMIT_SHORT_SHA }} into ${{ github.head_ref }}
- Updated call graph, benchmark plot and profiling stats database.
- Auto-generated by `pyrealm_profiling.yaml` workflow
${{ steps.benchmarking.outcome != 'passed' && 'Benchmarking passed' || 'Benchmarking **failed**: review failures.' }}
- name: Check outputs
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Profiling
name: Profiling on approve

# This runs when code is pushed to main or develop
# This runs when a pull request is submitted
on:
push:
branches: [main, develop]
pull_request_review:
types: [submitted]

jobs:
test:
if: github.event.review.state == 'APPROVED'
uses: ./.github/workflows/pyrealm_ci.yaml
secrets: inherit

Expand All @@ -19,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
ref: ${{ github.ref }}

- uses: actions/setup-python@v5
with:
Expand All @@ -30,25 +31,25 @@ jobs:
with:
poetry-version: 1.2.2

- name: Install dependencies
run: poetry install

- name: Run the profiling test suite
id: profiling
- name: Install dependencies and add env vars
run: |
poetry install
sudo apt-get install graphviz
poetry run pytest -m "profiling" --profile-svg
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Run the profiling test suite, using time to get peak memory usage
id: profiling
run: poetry run /usr/bin/time -v pytest -m "profiling" --profile-svg

# This step only runs if the profiling succeeds
- name: Benchmark performance and copy call graph
- name: Benchmark performance
id: benchmarking
if: ${{steps.profiling.outcome == 'success'}}
run: poetry run /usr/bin/time -v python profiling/run_benchmarking.py prof/combined.prof profiling/profiling-database.csv profiling/benchmark-fails.csv ${{ env.COMMIT_SHORT_SHA }} --update-on-pass --plot-path profiling/performance-plot.png
run: poetry run python profiling/run_benchmarking.py prof/combined.prof profiling/profiling-database.csv profiling/benchmark-fails.csv ${{ env.COMMIT_SHORT_SHA }} --update-on-pass --plot-path profiling/performance-plot.png

# This step copies over the updated call graph
- name: Benchmark performance and copy call graph
- name: Copy call graph
id: update-call-graph
if: always() && steps.benchmarking.outcome != 'skipped'
run: cp prof/combined.svg profiling/call-graph.svg
Expand All @@ -60,3 +61,4 @@ jobs:
with:
commit_message: Auto-generated profiling results [skip actions]
file_pattern: 'profiling/*'
branch: ${{ github.event.pull_request.head.ref }}
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: isort
additional_dependencies: [toml]
- repo: https://github.com/psf/black
rev: "24.4.0"
rev: "24.4.2"
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
Expand All @@ -24,14 +24,14 @@ repos:
- id: flake8
additional_dependencies: [flake8-docstrings]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.9.0"
rev: "v1.10.0"
hooks:
- id: mypy
additional_dependencies: [numpy, types-tabulate, pandas-stubs]
exclude: "pyrealm_build_data/splash/splash_py_version/.*\\.py"
# https://stackoverflow.com/a/75447331/3401916
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
rev: v0.40.0
hooks:
- id: markdownlint

Loading

0 comments on commit 5758f3c

Please sign in to comment.