Skip to content

31 ci benchmarking #136

31 ci benchmarking

31 ci benchmarking #136

Workflow file for this run

name: PR Benchmark and Plot Generation
on:
pull_request:
branches:
- main
permissions:
pull-requests: write
jobs:
generate_plots:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python environment
run: |
sudo apt-get update
sudo apt-get install -y python3-pip python3-venv
python3 -m venv ~/gt4py-venv
source ~/gt4py-venv/bin/activate
python3 -m pip install --upgrade pip
pip install -i https://test.pypi.org/simple/ atlas4py
- name: Install GT4Py from specific branch
run: |
source ~/gt4py-venv/bin/activate
git clone --branch fix_python_interp_path_in_cmake https://github.com/tehrengruber/gt4py.git ~/gt4py
cd ~/gt4py
pip install -r requirements-dev.txt
pip install -e .
- uses: julia-actions/setup-julia@v1
with:
version: "1.8"
- uses: actions/cache@v3
name: Cache Julia packages
with:
path: ~/.julia
key: ${{ runner.os }}-julia-${{ hashFiles('**/Project.toml', '**/Manifest.toml') }}
restore-keys: |
${{ runner.os }}-julia-
- uses: actions/cache@v3
name: Cache Python packages
with:
path: ~/gt4py-venv
key: ${{ runner.os }}-python-${{ hashFiles('**/requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-python-
- name: Configure PyCall
run: |
source ~/gt4py-venv/bin/activate
julia --project=. -e 'using Pkg; Pkg.add("PyCall"); ENV["PYTHON"]="python"; Pkg.build("PyCall");'
julia --project=. -e 'using PyCall; @show PyCall.python'
- name: Extract Package Name from Project.toml
id: extract-package-name
run: |
PACKAGE_NAME=$(grep "^name" Project.toml | sed 's/^name = "\(.*\)"$/\1/')
echo "::set-output name=package_name::$PACKAGE_NAME"
- name: Benchmark and Generate Plots
env:
JULIA_NUM_THREADS: 2
run: |
source ~/gt4py-venv/bin/activate
julia --project=. -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; using Pkg; Pkg.add(url="https://github.com/MilesCranmer/AirspeedVelocity.jl.git"); Pkg.build("AirspeedVelocity")'
echo "$HOME/.julia/bin" >> $GITHUB_PATH
mkdir results
mkdir plots
benchpkg ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --url=${{ github.event.repository.clone_url }} --bench-on="${{github.event.repository.default_branch}}" --output-dir=results/ --tune
benchpkgplot ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --npart=10 --format=png --input-dir=results/ --output-dir=plots/
benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --input-dir=results/ --ratio > table.md
echo '### Benchmark Results' > body.md
cat table.md >> body.md
echo '### Benchmark Plots' >> body.md
echo 'A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.' >> body.md
echo 'Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).' >> body.md
- name: Upload plot as artifact
uses: actions/upload-artifact@v3
with:
name: plots
path: plots
- name: Comment on PR
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body-path: body.md
edit-mode: replace