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

[WIP] Download IDAKLU from pybammsolvers #4487

Draft
wants to merge 27 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c09b6be
Removing IDAKLU, local install of pybammsolvers
kratman Sep 30, 2024
57d8641
Fix test with local install
kratman Sep 30, 2024
f84ce60
remove test option, temp change to nox file
kratman Sep 30, 2024
4ee52cd
Uncomment pybammsolvers dependency
kratman Oct 1, 2024
62a77a8
Start removing release and docs references
kratman Oct 1, 2024
f2299bd
Merge branch 'develop' of github.com:kratman/PyBaMM into feat/removeI…
kratman Oct 2, 2024
a8203d4
Merge branch 'develop' of github.com:kratman/PyBaMM into feat/removeI…
kratman Oct 3, 2024
270bb6a
Merge branch 'develop' of github.com:kratman/PyBaMM into feat/removeI…
kratman Oct 3, 2024
a774a57
Minor changes
kratman Oct 3, 2024
5d2eae0
Fix for casadi import
kratman Oct 3, 2024
382b38b
Cleanup
kratman Oct 3, 2024
28ea704
Second attempt
kratman Oct 3, 2024
77219ae
Fix regex error in fix
kratman Oct 4, 2024
a319bd2
Change path method
kratman Oct 4, 2024
848e868
Merge branch 'develop' into feat/removeIDAKLU
kratman Oct 9, 2024
969cadb
Merge branch 'develop' into feat/removeIDAKLU
kratman Oct 15, 2024
d4ce27d
Merge branch 'develop' of github.com:kratman/PyBaMM into feat/removeI…
kratman Oct 19, 2024
4a31ff8
Merge branch 'feat/removeIDAKLU' of github.com:kratman/PyBaMM into fe…
kratman Oct 19, 2024
90ee509
Merge branch 'develop' of github.com:kratman/PyBaMM into feat/removeI…
kratman Nov 7, 2024
c89e190
Merge branch 'develop' of github.com:kratman/PyBaMM into feat/removeI…
kratman Nov 13, 2024
772e782
Merge branch 'develop' of github.com:kratman/PyBaMM into feat/removeI…
kratman Nov 14, 2024
baf25df
Merge branch 'develop' into feat/removeIDAKLU
kratman Nov 19, 2024
14b7e43
Merge branch 'develop' of github.com:kratman/PyBaMM into feat/removeI…
kratman Nov 22, 2024
0a75b84
Fix changelog
kratman Nov 22, 2024
59ef0f2
Merge branch 'develop' of github.com:kratman/PyBaMM into feat/removeI…
kratman Nov 25, 2024
fb33d93
Style
kratman Nov 25, 2024
7c7ecc1
Merge branch 'develop' into feat/removeIDAKLU
kratman Nov 25, 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
7 changes: 0 additions & 7 deletions .github/release_workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ If a new release is required after the release of `vYY.MM.{x-1}` -

Some other essential things to check throughout the release process -

- If updating our custom vcpkg registry entries
[sundials-vcpkg-registry][SUNDIALS_VCPKG]
or [casadi-vcpkg-registry][CASADI_VCPKG] (used to build Windows
wheels), make sure to update the baseline of the registries in
vcpkg-configuration.json to the latest commit id.
- Update jax and jaxlib to the latest version in `pybamm.util` and
`pyproject.toml`, fixing any bugs that arise.
- If changes are made to the API, console scripts, entry points, new optional
Expand All @@ -79,7 +74,5 @@ Some other essential things to check throughout the release process -
PR **must** bump the build number in `meta.yaml` and **must** be from a
personal fork of the repository.

[SUNDIALS_VCPKG]: https://github.com/pybamm-team/sundials-vcpkg-registry
[CASADI_VCPKG]: https://github.com/pybamm-team/casadi-vcpkg-registry
[PYBAMM_FEED]: https://github.com/conda-forge/pybamm-feedstock
[FEED_GUIDE]: https://conda-forge.org/docs/maintainer/updating_pkgs.html#updating-the-feedstock-repository
5 changes: 1 addition & 4 deletions .github/workflows/benchmark_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ jobs:

- name: Install python dependencies
run: |
python -m uv pip install --upgrade pip wheel setuptools wget cmake casadi numpy
python -m uv pip install --upgrade pip wheel setuptools wget numpy
python -m uv pip install asv[virtualenv]

- name: Install SuiteSparse and SUNDIALS
run: python scripts/install_KLU_Sundials.py

- name: Fetch base branch
run: |
# This workflow also runs for merge commits
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/periodic_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,13 @@ jobs:

- name: Install python dependencies
run: |
python -m uv pip install --upgrade pip wheel setuptools wget cmake casadi numpy
python -m uv pip install --upgrade pip wheel setuptools wget numpy
python -m uv pip install asv[virtualenv]

- name: Install SuiteSparse and SUNDIALS
run: python scripts/install_KLU_Sundials.py

- name: Run benchmarks
run: |
asv machine --machine "GitHubRunner"
asv run --machine "GitHubRunner" NEW --show-stderr -v
env:
SUNDIALS_INST: $HOME/.local
LD_LIBRARY_PATH: $HOME/.local/lib

- name: Upload results as artifact
uses: actions/[email protected]
Expand Down
97 changes: 2 additions & 95 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ jobs:
with open(output_file, "a", encoding="utf-8") as output_stream:
output_stream.write(f"count={num_cpus}\n")

- name: Clone pybind11 repo (no history)
run: git clone --depth 1 --branch v2.12.0 https://github.com/pybind/pybind11.git -c advice.detachedHead=false

- name: Install vcpkg on Windows
run: |
cd C:\
Expand Down Expand Up @@ -91,7 +88,6 @@ jobs:
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair --add-path C:/Windows/System32 -w {dest_dir} {wheel}
CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
python -m pytest -m cibw {project}/tests/unit
- name: Upload Windows wheels
uses: actions/[email protected]
Expand All @@ -112,24 +108,17 @@ jobs:
with:
python-version: 3.11

- name: Clone pybind11 repo (no history)
run: git clone --depth 1 --branch v2.12.0 https://github.com/pybind/pybind11.git -c advice.detachedHead=false

- name: Build wheels on Linux
run: pipx run cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: >
PYBAMM_DISABLE_TELEMETRY="true"
CIBW_ARCHS_LINUX: x86_64
CIBW_BEFORE_ALL_LINUX: >
yum -y install openblas-devel lapack-devel &&
bash scripts/install_sundials.sh 6.0.3 6.5.0
CIBW_BEFORE_BUILD_LINUX: python -m pip install cmake casadi setuptools wheel
CIBW_BEFORE_BUILD_LINUX: python -m pip install setuptools wheel
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel}
CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
set -e -x
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
python -m pytest -m cibw {project}/tests/unit

- name: Upload wheels for Linux
Expand All @@ -152,9 +141,6 @@ jobs:
with:
python-version: '3.11'

- name: Clone pybind11 repo (no history)
run: git clone --depth 1 --branch v2.12.0 https://github.com/pybind/pybind11.git -c advice.detachedHead=false

- name: Install cibuildwheel
run: python -m pip install cibuildwheel

Expand All @@ -163,95 +149,17 @@ jobs:
run: |
set -e -x

# Set LLVM-OpenMP URL
if [[ $(uname -m) == "x86_64" ]]; then
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-64/llvm-openmp-11.1.0-hda6cdc1_1.tar.bz2"
elif [[ $(uname -m) == "arm64" ]]; then
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-arm64/llvm-openmp-11.1.0-hf3c4609_1.tar.bz2"
fi

# Download gfortran with proper macOS minimum version (11.0)
if [[ $(uname -m) == "x86_64" ]]; then
GFORTRAN_URL="https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-x86_64-native.tar.gz"
KNOWN_SHA256="981367dd0ad4335613e91bbee453d60b6669f5d7e976d18c7bdb7f1966f26ae4 gfortran.tar.gz"
elif [[ $(uname -m) == "arm64" ]]; then
GFORTRAN_URL="https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-arm64-native.tar.gz"
KNOWN_SHA256="84364eee32ba843d883fb8124867e2bf61a0cd73b6416d9897ceff7b85a24604 gfortran.tar.gz"
fi

# Validate gfortran tarball
curl -L $GFORTRAN_URL -o gfortran.tar.gz
if ! echo "$KNOWN_SHA256" != "$(shasum --algorithm 256 gfortran.tar.gz)"; then
echo "Checksum failed"
exit 1
fi

mkdir -p gfortran_installed
tar -xv -C gfortran_installed/ -f gfortran.tar.gz

if [[ $(uname -m) == "x86_64" ]]; then
export FC=$(pwd)/gfortran_installed/gfortran-darwin-x86_64-native/bin/gfortran
export PATH=$(pwd)/gfortran_installed/gfortran-darwin-x86_64-native/bin:$PATH
elif [[ $(uname -m) == "arm64" ]]; then
export FC=$(pwd)/gfortran_installed/gfortran-darwin-arm64-native/bin/gfortran
export PATH=$(pwd)/gfortran_installed/gfortran-darwin-arm64-native/bin:$PATH
fi

# link libgfortran dylibs and place them in $HOME/.local/lib
# and then change rpath to $HOME/.local/lib for each of them
# Note: libgcc_s.1.dylib not available on macOS arm64; skip for now
mkdir -p $HOME/.local/lib
if [[ $(uname -m) == "x86_64" ]]; then
lib_dir=$(pwd)/gfortran_installed/gfortran-darwin-x86_64-native/lib
for lib in libgfortran.5.dylib libgfortran.dylib libquadmath.0.dylib libquadmath.dylib libgcc_s.1.dylib libgcc_s.1.1.dylib; do
cp $lib_dir/$lib $HOME/.local/lib/
install_name_tool -id $HOME/.local/lib/$lib $HOME/.local/lib/$lib
codesign --force --sign - $HOME/.local/lib/$lib
done
elif [[ $(uname -m) == "arm64" ]]; then
lib_dir=$(pwd)/gfortran_installed/gfortran-darwin-arm64-native/lib
for lib in libgfortran.5.dylib libgfortran.dylib libquadmath.0.dylib libquadmath.dylib libgcc_s.1.1.dylib; do
cp $lib_dir/$lib $HOME/.local/lib/
install_name_tool -id $HOME/.local/lib/$lib $HOME/.local/lib/$lib
codesign --force --sign - $HOME/.local/lib/$lib
done
fi

export SDKROOT=${SDKROOT:-$(xcrun --show-sdk-path)}

# Can't download LLVM-OpenMP directly, use conda/mamba and set environment variables
brew install miniforge
mamba create -n pybamm-dev $OPENMP_URL
if [[ $(uname -m) == "x86_64" ]]; then
PREFIX="/usr/local/Caskroom/miniforge/base/envs/pybamm-dev"
elif [[ $(uname -m) == "arm64" ]]; then
PREFIX="/opt/homebrew/Caskroom/miniforge/base/envs/pybamm-dev"
fi

# Copy libomp.dylib from PREFIX to $HOME/.local/lib, needed for wheel repair
cp $PREFIX/lib/libomp.dylib $HOME/.local/lib/
install_name_tool -id $HOME/.local/lib/libomp.dylib $HOME/.local/lib/libomp.dylib
codesign --force --sign - $HOME/.local/lib/libomp.dylib

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
export CFLAGS="$CFLAGS -I$PREFIX/include"
export CXXFLAGS="$CXXFLAGS -I$PREFIX/include"
export LDFLAGS="$LDFLAGS -L$PREFIX/lib -lomp"

# cibuildwheel not recognising its environment variable, so set manually
export CIBUILDWHEEL="1"

python scripts/install_KLU_Sundials.py
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: >
PYBAMM_DISABLE_TELEMETRY="true"
# 10.13 for Intel (macos-13), 11.0 for Apple Silicon (macos-14 and macos-latest)
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-14' && '11.0' || '10.13' }}
CIBW_ARCHS_MACOS: auto
CIBW_BEFORE_BUILD: python -m pip install cmake casadi setuptools wheel delocate
CIBW_BEFORE_BUILD: python -m pip install setuptools wheel delocate
CIBW_REPAIR_WHEEL_COMMAND: |
if [[ $(uname -m) == "x86_64" ]]; then
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
Expand All @@ -263,7 +171,6 @@ jobs:
CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
set -e -x
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
python -m pytest -m cibw {project}/tests/unit

- name: Upload wheels for macOS (amd64, arm64)
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/run_periodic_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ on:
env:
PYBAMM_DISABLE_TELEMETRY: "true"
FORCE_COLOR: 3
PYBAMM_IDAKLU_EXPR_CASADI: ON
PYBAMM_IDAKLU_EXPR_IREE: ON

concurrency:
# github.workflow: name of the workflow, so that we don't cancel other workflows
Expand Down Expand Up @@ -75,11 +73,6 @@ jobs:
- name: Install nox
run: python -m uv pip install nox[uv]

- name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS
timeout-minutes: 10
if: matrix.os != 'windows-latest'
run: python -m nox -s pybamm-requires

- name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.12'
run: python -m nox -s unit
Expand All @@ -97,7 +90,6 @@ jobs:
- name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
run: python -m nox -s integration

# Skips IDAKLU module compilation for speedups, which is already tested in other jobs.
run_doctests:
runs-on: ubuntu-latest
name: Doctests (ubuntu-latest / Python 3.11)
Expand Down Expand Up @@ -154,10 +146,6 @@ jobs:
- name: Install nox
run: python -m uv pip install nox[uv]

- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
run: python -m nox -s pybamm-requires

- name: Run example notebooks tests for GNU/Linux with Python 3.12
run: python -m nox -s examples

Expand Down Expand Up @@ -185,9 +173,5 @@ jobs:
- name: Install nox
run: python -m uv pip install nox[uv]

- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
run: python -m nox -s pybamm-requires

- name: Run example scripts tests for GNU/Linux with Python 3.12
run: python -m nox -s scripts
53 changes: 0 additions & 53 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
env:
PYBAMM_DISABLE_TELEMETRY: "true"
FORCE_COLOR: 3
PYBAMM_IDAKLU_EXPR_CASADI: ON
PYBAMM_IDAKLU_EXPR_IREE: ON

concurrency:
# github.workflow: name of the workflow, so that we don't cancel other workflows
Expand Down Expand Up @@ -95,24 +93,6 @@ jobs:
- name: Install nox
run: python -m uv pip install nox[uv]

- name: Cache pybamm-requires nox environment for GNU/Linux and macOS
uses: actions/cache@v4
if: matrix.os != 'windows-latest'
with:
path: |
# Repository files
${{ github.workspace }}/pybind11/
${{ github.workspace }}/install_KLU_Sundials/
# Headers and dynamic library files for SuiteSparse and SUNDIALS
${{ env.HOME }}/.local/lib/
${{ env.HOME }}/.local/include/
key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py', '**/test_on_push.yml') }}

- name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS
timeout-minutes: 10
if: matrix.os != 'windows-latest'
run: python -m nox -s pybamm-requires

- name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.12'
run: python -m nox -s unit
Expand All @@ -130,7 +110,6 @@ jobs:
- name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
run: python -m nox -s integration

# Skips IDAKLU module compilation for speedups, which is already tested in other jobs.
run_doctests:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -211,22 +190,6 @@ jobs:
- name: Install nox
run: python -m uv pip install nox[uv]

- name: Cache pybamm-requires nox environment for GNU/Linux
uses: actions/cache@v4
with:
path: |
# Repository files
${{ github.workspace }}/pybind11/
${{ github.workspace }}/install_KLU_Sundials/
# Headers and dynamic library files for SuiteSparse and SUNDIALS
${{ env.HOME }}/.local/lib/
${{ env.HOME }}/.local/include/
key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py', '**/test_on_push.yml') }}

- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
run: python -m nox -s pybamm-requires

- name: Run example notebooks tests for GNU/Linux with Python 3.12
run: python -m nox -s examples

Expand Down Expand Up @@ -266,21 +229,5 @@ jobs:
- name: Install nox
run: python -m uv pip install nox[uv]

- name: Cache pybamm-requires nox environment for GNU/Linux
uses: actions/cache@v4
with:
path: |
# Repository files
${{ github.workspace }}/pybind11/
${{ github.workspace }}/install_KLU_Sundials/
# Headers and dynamic library files for SuiteSparse and SUNDIALS
${{ env.HOME }}/.local/lib/
${{ env.HOME }}/.local/include/
key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py', '**/test_on_push.yml') }}

- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
run: python -m nox -s pybamm-requires

- name: Run example scripts tests for GNU/Linux with Python 3.12
run: python -m nox -s scripts
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ pyvenv.cfg
.vscode
.ruff_cache/

# sundials
sundials
sundials4
sundials-*
SuiteSparse-*
build_sundials
KLU_module_deps

# downloads
*.gz

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
## Breaking changes

- Double-layer SEI models have been removed (with the corresponding parameters). All models assume now a single SEI layer. ([#4470](https://github.com/pybamm-team/PyBaMM/pull/4470))
- Moved the IDAKLU solver to a standalone `pybammsolvers` package. This will
make pybamm a pure python package and make installing and using the solver
easier. ([#4487](https://github.com/pybamm-team/PyBaMM/pull/4487))

# [v24.11.1](https://github.com/pybamm-team/PyBaMM/tree/v24.11.1) - 2024-11-22

Expand Down
Loading
Loading