Skip to content

CI

CI #1525

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
schedule:
- cron: '5 0 * * *'
jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
# matches compat target in setup.py
python-version: '3.7'
- name: Run flake8
run: |
pip install -U flake8 pep8-naming flake8-quotes flake8-comprehensions flake8-isort types-psutil numpy flake8-bugbear
flake8 setup.py doc/conf.py logpyle bin/* examples/*.py test/*.py
examples:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.x']
os: [ubuntu-latest, macos-13]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install prerequisites
run: |
[[ $(uname) == "Darwin" ]] && brew install open-mpi
[[ $(uname) == "Linux" ]] && sudo apt-get update && sudo apt-get install -y mpich libmpich-dev
pip install wheel matplotlib mpi4py psutil
pip install -e .
- name: Run and test examples
run: |
set -x
python examples/log.py
runalyzer-gather summary.sqlite log.sqlite
runalyzer -m summary.sqlite -c 'dbplot(q("select $t_sim, $t_step"))'
# Perform some simple tests on the output file
## Check for warnings and logging
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from warnings"))'
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' | grep Oof
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from logging"))'
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from logging"))' | grep WARNING
## Check that t_log is within [0, 2]
runalyzer -m summary.sqlite -c 'assert all([0 < r[0] < 2 for r in q("select $t_log.max")])'
## Check that gathered and auto-gathered are equivalent for t_log non-mpi case
manual_gather=$(runalyzer summary.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))')
auto_gather=$(runalyzer log.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_log values match"; else exit 1; fi
## Check that t_init is within [0, 20], and that there is only one value
runalyzer -m summary.sqlite -c 'assert all([0 < r[0] < 20 for r in q("select $t_init.max")])'
runalyzer -m summary.sqlite -c 'assert len([r[0] for r in q("select $t_init.max")]) == 1'
## Check that gathered and auto-gathered are equivalent for t_sim non-mpi case
manual_gather=$(runalyzer summary.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))')
auto_gather=$(runalyzer log.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_init values match"; else exit 1; fi
# Allow oversubscription of ranks to cores with Open MPI
export OMPI_MCA_rmaps_base_oversubscribe=1
export RDMAV_FORK_SAFE=1
mpirun --map-by :OVERSUBSCRIBE -n 4 python -m mpi4py examples/log-mpi.py
rm summary.sqlite
runalyzer-gather summary.sqlite mpi-log*.sqlite
runalyzer -m summary.sqlite -c 'dbplot(q("select $t_sim.max, $t_step.max"))'
# Perform some simple tests on the output file
## Check for warnings and logging
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from warnings"))'
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' | grep Oof
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from logging"))'
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from logging"))' | grep WARNING
## Check that t_log is within [0, 2]
runalyzer -m summary.sqlite -c 'assert all([0 < r[0] < 2 for r in q("select $t_log.max")])'
## Check that gathered and auto-gathered are equivalent for t_log mpi case
manual_gather=$(runalyzer summary.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))')
auto_gather=$(runalyzer mpi-log*.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_log values match"; else exit 1; fi
## Check that t_init is within [0, 20], and that there is only one value
runalyzer -m summary.sqlite -c 'assert all([0 < r[0] < 20 for r in q("select $t_init.max")])'
runalyzer -m summary.sqlite -c 'assert len([r[0] for r in q("select $t_init.max")]) == 1'
## Check that gathered and auto-gathered are equivalent for t_init mpi case
manual_gather=$(runalyzer summary.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))')
auto_gather=$(runalyzer mpi-log*.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_init values match"; else exit 1; fi
## Gather and autogather multiple runs together and compare output
runalyzer-gather summary_multirun.sqlite mpi-log*.sqlite log.sqlite
manual_gather=$(runalyzer summary_multirun.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))')
auto_gather=$(runalyzer mpi-log*.sqlite log.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_log values match"; else exit 1; fi
manual_gather=$(runalyzer summary_multirun.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))')
auto_gather=$(runalyzer mpi-log*.sqlite log.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_init values match"; else exit 1; fi
# ensure that gathering gathered files raises exception
set +e
runalyzer summary.sqlite summary_multirun.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))'
if [ $? -eq 0 ]; then echo "Exception was not raised when gathering gathered files"; exit 1; else echo "Exception was raised"; fi
set -e
- name: Test signal handling
run: |
set -x
# {{{ test SIGTERM handling
set +e
python examples/log.py & pid=$!
sleep 2; kill $pid
wait $pid
ret=$?
set -e
[[ $ret -eq 15 ]] || { echo "Expected return code 15, got $ret"; exit 1; }
len=$(runalyzer log.sqlite -c 'print(len(db.q("select $t_log.max").fetchall()))' | tail -1)
[[ $len -ge 10 ]] || { echo "Expected at least 10 t_log values, got $len"; exit 1; }
# }}}
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: "Main Script"
run: |
curl -L -O https://tiker.net/ci-support-v0
. ci-support-v0
build_py_project_in_venv
build_docs
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: "Main Script"
run: |
curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/main/prepare-and-run-mypy.sh
export EXTRA_INSTALL="pytools numpy types-psutil pymbolic"
. ./prepare-and-run-mypy.sh python3
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Run tests
run: |
set -x
sudo apt-get update && sudo apt-get install -y libopenmpi-dev
pip install -e .
python -m pip install pytest pymbolic psutil matplotlib mpi4py
# run current test coverage
python -m pytest --durations=5 --tb=native -rxsw test/
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Compare coverage with 'main' branch
run: |
set -x
sudo apt-get update && sudo apt-get install -y libopenmpi-dev
pip install -e .
python -m pip install pytest pytest-cov pymbolic psutil matplotlib mpi4py
# run current test coverage
python -m pytest --durations=0 --tb=native -rxsw --cov-report term --cov-report json:new_cov.json --cov=logpyle test/
# get main's test coverage
pip uninstall logpyle -y
cd ..
git clone https://github.com/illinois-ceesd/logpyle.git logpyle_main
cd logpyle_main
pip install -e .
python -m pytest --durations=0 --tb=native -rxsw --cov-report term --cov-report json:old_cov.json --cov=logpyle test/
# ensure that coverage can only increase
cd test
ls -l ..
python -c 'from conftest import assert_cov; assert_cov("../old_cov.json", "../../logpyle/new_cov.json")'
htmlalyzer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Run
run: |
pip install -e .
python -m pip install pymbolic psutil matplotlib
# open default html
htmlalyzer
# open html after being built
htmlalyzer -b
upgrade-db:
name: Upgrade-Database
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Upgrade v2 to v3
run: |
pip install -e .
# test ungathered_v2 default name
upgrade-db .github/workflows/log_ungathered_v2.sqlite
# utilize nogather flag to ensure schema is from modification
# instead of gathering, which builds schema v3
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered_v2 default name
upgrade-db .github/workflows/log_gathered_v2.sqlite
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered custom name
upgrade-db .github/workflows/log_gathered_v2.sqlite --suffix '_new'
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
- name: Upgrade v3 to v3
# Tests upgrades on current version for stability and allows users
# to blindly upgrade databases safely
run: |
pip install -e .
# test ungathered_v3 default name
upgrade-db .github/workflows/log_ungathered_v3.sqlite
# utilize nogather flag to ensure schema is from modification
# instead of gathering, which builds schema v3
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered_v3 default name
upgrade-db .github/workflows/log_gathered_v3.sqlite
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered custom name
upgrade-db .github/workflows/log_gathered_v3.sqlite --suffix '_new'
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'