Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher splitting for Github Actions and Cache venv #1213

Merged
merged 68 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
6833203
making changes to yaml and dev-requirements.txt
rahulgaur104 Aug 21, 2024
77249ad
adding -n auto to the rest of the yml files
rahulgaur104 Aug 21, 2024
8b629d3
increase splitting
YigitElma Aug 21, 2024
f13d157
try to cache pip dependencies
YigitElma Aug 21, 2024
602cfd7
small fix
YigitElma Aug 21, 2024
0b72272
use cached env for tests
YigitElma Aug 21, 2024
d2aa717
try to fix
YigitElma Aug 21, 2024
7410101
fix the typo
YigitElma Aug 21, 2024
c655ae5
only use cached files
YigitElma Aug 21, 2024
96ff396
fix
YigitElma Aug 21, 2024
c41867d
switch back to cache
YigitElma Aug 21, 2024
886a7c3
try venv strategy
YigitElma Aug 21, 2024
b9cb7d8
run pytonpip.yml for once
YigitElma Aug 21, 2024
f3ca1b6
delete the redundant lines
YigitElma Aug 21, 2024
8df6657
update
YigitElma Aug 21, 2024
e12fdce
try smth
YigitElma Aug 21, 2024
1ddd718
try new restore for black/linting and regression tests
YigitElma Aug 21, 2024
ae8d854
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 21, 2024
4927894
fix
YigitElma Aug 21, 2024
bf158a0
add restore to rest of the workflows
YigitElma Aug 21, 2024
77d2cea
change frequency of caching
YigitElma Aug 21, 2024
e84ffab
fix source thing
YigitElma Aug 22, 2024
f75a08f
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 22, 2024
199a14d
Merge remote-tracking branch 'origin' into rg/parallel-testing
YigitElma Aug 22, 2024
368058e
don't use venv for lintin, for some reason it is 6 minutes slower
YigitElma Aug 22, 2024
de409c9
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 22, 2024
7058bf9
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 23, 2024
ba5334a
update the hash of the cache to have requirements.txt to account for …
YigitElma Aug 23, 2024
52cb5af
to rerun the tests
YigitElma Aug 23, 2024
008036d
change cache workflow to save
YigitElma Aug 23, 2024
c76a5e5
add delete old cache files
YigitElma Aug 23, 2024
ac9024c
add delete old cache files
YigitElma Aug 23, 2024
af9af47
add delete old cache files
YigitElma Aug 23, 2024
49a7ff8
add delete old cache files
YigitElma Aug 23, 2024
7d68c2b
add delete old cache files
YigitElma Aug 23, 2024
c42e16b
try * for unknown cache
YigitElma Aug 24, 2024
bfa3448
try for unknown cache
YigitElma Aug 24, 2024
cf85a3b
split regression 6, notebook tests to 4 parts, remove redundant prints
YigitElma Aug 24, 2024
feec422
try splitting benchmarks
YigitElma Aug 24, 2024
8314f2d
re distribute splitting
YigitElma Aug 24, 2024
f8bfd3b
something broke cache use, try to revert
YigitElma Aug 24, 2024
f8600b5
remove extra run for caching
YigitElma Aug 24, 2024
eec95c3
try 1
YigitElma Aug 24, 2024
56128e2
try 2
YigitElma Aug 24, 2024
f4f7474
make a single hash for the cache name, re write caches
YigitElma Aug 24, 2024
dfdb291
try 3
YigitElma Aug 24, 2024
168777f
add dummy test
YigitElma Aug 24, 2024
4c54962
add dummy test
YigitElma Aug 24, 2024
c00781d
add dummy test
YigitElma Aug 24, 2024
03d1c6f
add dummy test
YigitElma Aug 24, 2024
d309419
add dummy test
YigitElma Aug 24, 2024
1af7453
add dummy test
YigitElma Aug 24, 2024
bbc655b
add dummy test
YigitElma Aug 24, 2024
c4fe39c
remove dummy test
YigitElma Aug 24, 2024
eaf110f
test
YigitElma Aug 24, 2024
5066874
remove python 3.8 from weekly tests, we stoped using it 3 months ago
YigitElma Aug 26, 2024
8b480b5
re run tests
YigitElma Aug 26, 2024
94e9f3a
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 26, 2024
4a73d3a
update benchmarks to work with splitting
YigitElma Aug 27, 2024
1cc625b
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 27, 2024
b4e5060
make workflow file names consistent and more descriptive, use specifi…
YigitElma Aug 27, 2024
0429433
Merge branch 'rg/parallel-testing' of github.com:PlasmaControl/DESC i…
YigitElma Aug 27, 2024
7318805
add pip list
YigitElma Aug 27, 2024
e7e040b
Merge branch 'master' into rg/parallel-testing
dpanici Aug 27, 2024
9a7a222
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 28, 2024
d14ef72
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 28, 2024
6ce96e0
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 28, 2024
76dad87
Merge branch 'master' into rg/parallel-testing
YigitElma Aug 28, 2024
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
76 changes: 65 additions & 11 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ concurrency:
jobs:
benchmark:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
strategy:
matrix:
python-version: ['3.9']
group: [1, 2]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure if we want to split the benchmarks, since they need to run on the same hardware for it to be a meaningful comparison

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we split master and latest PR still runs on the same hardware. The only difference is some portion of the benchmarks runs on the second job. I am assuming pytest-split always splits the same tests. SO, compile and jac tests may run on different hardware but the same test for aster and PR runs on the same job and thus hardware


steps:
# Enable tmate debugging of manually-triggered workflows if the input option was provided
Expand All @@ -31,41 +37,68 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python 3.9

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
python-version: ${{ matrix.python-version }}

- name: Restore Python environment cache
id: restore-env
uses: actions/cache/restore@v4
with:
path: .venv-${{ matrix.python-version }}
key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt', 'requirements.txt') }}

- name: Set up virtual environment if not restored from cache
if: steps.restore-env.outputs.cache-hit != 'true'
run: |
gh cache list
python -m venv .venv-${{ matrix.python-version }}
source .venv-${{ matrix.python-version }}/bin/activate
python -m pip install --upgrade pip
pip install -r devtools/dev-requirements.txt
- name: Benchmark with pytest-benchmark

- name: Benchmark with pytest-benchmark (PR)
run: |
source .venv-${{ matrix.python-version }}/bin/activate
pwd
lscpu
cd tests/benchmarks
python -m pytest benchmark_cpu_small.py -vv \
--benchmark-save='Latest_Commit' \
--durations=0 \
--benchmark-save-data
--benchmark-save-data \
--splits 2 \
--group ${{ matrix.group }} \
--splitting-algorithm least_duration

- name: Checkout current master
uses: actions/checkout@v4
with:
ref: master
clean: false

- name: Checkout benchmarks from PR head
run: git checkout ${{ github.event.pull_request.head.sha }} -- tests/benchmarks
- name: Benchmark with pytest-benchmark

- name: Benchmark with pytest-benchmark (MASTER)
run: |
source .venv-${{ matrix.python-version }}/bin/activate
pwd
lscpu
cd tests/benchmarks
python -m pytest benchmark_cpu_small.py -vv \
--benchmark-save='master' \
--durations=0 \
--benchmark-save-data
- name: put benchmark results in same folder
--benchmark-save-data \
--splits 2 \
--group ${{ matrix.group }} \
--splitting-algorithm least_duration

- name: Put benchmark results in same folder
run: |
source .venv-${{ matrix.python-version }}/bin/activate
pwd
cd tests/benchmarks
find .benchmarks/ -type f -printf "%T@ %p\n" | sort -n | cut -d' ' -f 2- | tail -n 1 > temp1
Expand All @@ -75,22 +108,43 @@ jobs:
mkdir compare_results
cp $t1 compare_results
cp $t2 compare_results

- name: Download artifact
if: always()
uses: actions/download-artifact@v4
with:
pattern: benchmark_artifact_*
path: tests/benchmarks

- name: Unzip artifacts if downloaded
run: |
cd tests/benchmarks
ls
if [ -f tests/benchmarks/benchmark_artifact_*.zip ]; then
unzip tests/benchmarks/benchmark_artifact_*.zip -d tests/benchmarks
else
echo "No benchmark artifact file found."
fi

- name: Compare latest commit results to the master branch results
run: |
pwd
source .venv-${{ matrix.python-version }}/bin/activate
cd tests/benchmarks
pwd
python compare_bench_results.py
cat commit_msg.txt
- name: comment PR with the results

- name: Comment PR with the results
uses: thollander/actions-comment-pull-request@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filePath: tests/benchmarks/commit_msg.txt
comment_tag: benchmark

- name: Upload benchmark data
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark_artifact
name: benchmark_artifact_${{ matrix.group }}
path: tests/benchmarks/.benchmarks
28 changes: 25 additions & 3 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,48 @@ jobs:
black_format:

runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
strategy:
matrix:
python-version: ['3.10']

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
python-version: ${{ matrix.python-version }}

- name: Restore Python environment cache
id: restore-env
uses: actions/cache/restore@v4
with:
path: .venv-${{ matrix.python-version }}
key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt', 'requirements.txt') }}

- name: Set up virtual environment if not restored from cache
if: steps.restore-env.outputs.cache-hit != 'true'
run: |
gh cache list
python -m venv .venv-${{ matrix.python-version }}
source .venv-${{ matrix.python-version }}/bin/activate
python -m pip install --upgrade pip
pip install -r devtools/dev-requirements.txt

- name: Check files using the black formatter
run: |
source .venv-${{ matrix.python-version }}/bin/activate
black --version
black --check desc/ tests/ || black_return_code=$?
echo "BLACK_RETURN_CODE=$black_return_code" >> $GITHUB_ENV
black desc/ tests/

- name: Annotate diff changes using reviewdog
uses: reviewdog/action-suggester@v1
with:
tool_name: blackfmt

- name: Fail if not formatted
run: |
exit ${{ env.BLACK_RETURN_CODE }}
11 changes: 9 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,24 @@ on: [pull_request, workflow_dispatch]
jobs:
flake8_linting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']

name: Linting
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}

# For some reason, loading venv makes this way slower
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r devtools/dev-requirements.txt

- name: flake8 Lint
uses: reviewdog/action-flake8@v3
with:
Expand Down
24 changes: 21 additions & 3 deletions .github/workflows/nbtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,46 @@ jobs:
notebook_tests:

runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
strategy:
matrix:
python-version: ['3.10']
group: [1, 2]
group: [1, 2, 3]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies

- name: Restore Python environment cache
id: restore-env
uses: actions/cache/restore@v4
with:
path: .venv-${{ matrix.python-version }}
key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt', 'requirements.txt') }}

- name: Set up virtual environment if not restored from cache
if: steps.restore-env.outputs.cache-hit != 'true'
run: |
gh cache list
python -m venv .venv-${{ matrix.python-version }}
source .venv-${{ matrix.python-version }}/bin/activate
python -m pip install --upgrade pip
pip install -r devtools/dev-requirements.txt

- name: Test notebooks with pytest and nbmake
run: |
source .venv-${{ matrix.python-version }}/bin/activate
pwd
lscpu
export PYTHONPATH=$(pwd)
pytest -v --nbmake "./docs/notebooks" \
--nbmake-timeout=2000 \
--ignore=./docs/notebooks/zernike_eval.ipynb \
--splits 2 \
--splits 3 \
--group ${{ matrix.group }} \
--splitting-algorithm least_duration
54 changes: 54 additions & 0 deletions .github/workflows/pythonpip.yml
YigitElma marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Cache dependencies
# This workflow is triggered every 2 days and updates the Python
# and pip dependencies cache
on:
schedule:
- cron: '30 4 */2 * *' # This triggers the workflow at 4:30 AM every 2 days
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Delete old cached file with same python version
run: |
echo "Current Cached files list"
gh cache list
echo "Deleting cached files with pattern: ${{ runner.os }}-venv-${{ matrix.python-version }}-"
for cache_key in $(gh cache list --json key -q ".[] | select(.key | startswith(\"${{ runner.os }}-venv-${{ matrix.python-version }}-\")) | .key"); do
echo "Deleting cache with key: $cache_key"
gh cache delete "$cache_key"
done

- name: Set up virtual environment
run: |
python -m venv .venv-${{ matrix.python-version }}
source .venv-${{ matrix.python-version }}/bin/activate
python -m pip install --upgrade pip
pip install -r devtools/dev-requirements.txt

- name: Cache Python environment
id: cache-env
uses: actions/cache@v4
with:
path: .venv-${{ matrix.python-version }}
key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt', 'requirements.txt') }}

- name: Verify virtual environment activation
run: |
source .venv-${{ matrix.python-version }}/bin/activate
python --version
pip --version
YigitElma marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 21 additions & 3 deletions .github/workflows/regression_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
regression_tests:

runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
strategy:
matrix:
python-version: ['3.10']
Expand All @@ -29,20 +31,34 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies

- name: Restore Python environment cache
id: restore-env
uses: actions/cache/restore@v4
with:
path: .venv-${{ matrix.python-version }}
key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt', 'requirements.txt') }}

- name: Set up virtual environment if not restored from cache
if: steps.restore-env.outputs.cache-hit != 'true'
run: |
gh cache list
python -m venv .venv-${{ matrix.python-version }}
source .venv-${{ matrix.python-version }}/bin/activate
python -m pip install --upgrade pip
pip install -r devtools/dev-requirements.txt
pip install matplotlib==3.7.2
YigitElma marked this conversation as resolved.
Show resolved Hide resolved

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10

- name: Test with pytest
run: |
source .venv-${{ matrix.python-version }}/bin/activate
pwd
lscpu
python -m pytest -v -m regression \
python -m pytest -v -m regression\
--durations=0 \
--cov-report xml:cov.xml \
--cov-config=setup.cfg \
Expand All @@ -54,6 +70,7 @@ jobs:
--group ${{ matrix.group }} \
--splitting-algorithm least_duration \
--db ./prof.db

- name: save coverage file and plot comparison results
if: always()
uses: actions/upload-artifact@v4
Expand All @@ -63,6 +80,7 @@ jobs:
./cov.xml
./mpl_results.html
./prof.db

- name: Upload coverage
id : codecov
uses: Wandalen/[email protected]
Expand Down
Loading
Loading