Skip to content

Commit

Permalink
Merge branch 'graded-electrode-example' of github.com:pybamm-team/PyB…
Browse files Browse the repository at this point in the history
…aMM into graded-electrode-example
  • Loading branch information
brosaplanella committed Sep 7, 2024
2 parents f28e687 + d43142b commit b3aeaf1
Show file tree
Hide file tree
Showing 69 changed files with 345 additions and 378 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,15 @@
"code",
"test"
]
},
{
"login": "medha-14",
"name": "Medha Bhardwaj",
"avatar_url": "https://avatars.githubusercontent.com/u/143182673?v=4",
"profile": "https://github.com/medha-14",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
10 changes: 0 additions & 10 deletions .github/release_reminder.md

This file was deleted.

97 changes: 51 additions & 46 deletions .github/release_workflow.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Release workflow

This file contains the workflow required to make a `PyBaMM` release on GitHub, PyPI, and conda-forge by the maintainers.
This file contains the workflow required to make a `PyBaMM` release on
GitHub, PyPI, and conda-forge by the maintainers.

## rc0 releases (automated)
## Initial release (automated)

1. The `update_version.yml` workflow will run on every 1st of January, May and September, updating incrementing the version to `vYY.MMrc0` by running `scripts/update_version.py` in the following files -
1. The `update_version.yml` workflow will run on every 1st of January, May
and September, updating incrementing the version to `vYY.MM.0` by running
`scripts/update_version.py` in the following files:

- `pybamm/version.py`
- `docs/conf.py`
Expand All @@ -13,21 +16,27 @@ This file contains the workflow required to make a `PyBaMM` release on GitHub, P
- `vcpkg.json`
- `CHANGELOG.md`

These changes will be automatically pushed to a new branch `vYY.MM` and a PR from `vvYY.MM` to `develop` will be created (to sync the branches).
These changes will be automatically pushed to a new branch `vYY.MM`
and a PR from `vYY.MM` to `main` will be created.

2. Create a new GitHub _pre-release_ with the tag `vYY.MMrc0` from the `vYY.MM` branch and a description copied from `CHANGELOG.md`.
2. Create a new GitHub _release_ with the tag `vYY.MM.0` from the `vYY.MM`
branch and a description copied from `CHANGELOG.md`.

3. This release will automatically trigger `publish_pypi.yml` and create a _pre-release_ on PyPI.
3. This release will automatically trigger `publish_pypi.yml` and create a
_release_ on PyPI.

## rcX releases (manual)
## Bug fix releases (manual)

If a new release candidate is required after the release of `rc{X-1}` -
If a new release is required after the release of `vYY.MM.{x-1}` -

1. Cherry-pick the bug fix (no new features should be added to `vYY.MM` once `rc{X-1}` is released) commit to `vYY.MM` branch once the fix is merged into `develop`. The CHANGELOG entry for such fixes should go under the `rc{X-1}` heading in `CHANGELOG.md`
1. Create a new branch for the `vYY.MM.x` release using the `vYY.MM.{x-1}` tag.

2. Run `update_version.yml` manually while using `append_to_tag` to specify the release candidate version number (`rc1`, `rc2`, ...).
2. Cherry-pick the bug fixes to `vYY.MM.x` branch once the fix is
merged into `develop`. The CHANGELOG entry for such fixes should go under the
`YY.MM.x` heading in `CHANGELOG.md`

3. This will increment the version to `vYY.MMrcX` by running `scripts/update_version.py` in the following files -
3. Run `scripts/update_version.py` manually while setting `VERSION=vYY.MM.x`
in your environment. This will update the version in the following files:

- `pybamm/version.py`
- `docs/conf.py`
Expand All @@ -36,45 +45,41 @@ If a new release candidate is required after the release of `rc{X-1}` -
- `vcpkg.json`
- `CHANGELOG.md`

These changes will be automatically pushed to the existing `vYY.MM` branch and a PR will be created to update version strings in `develop`.
Commit the changes to your release branch.

4. Create a new GitHub _pre-release_ with the same tag (`vYY.MMrcX`) from the `vYY.MM` branch and a description copied from `CHANGELOG.md`.
4. Create a PR for the release and configure it to merge into the `main` branch.

5. This release will automatically trigger `publish_pypi.yml` and create a _pre-release_ on PyPI.

## Actual release (manual)

Once satisfied with the release candidates -

1. Run `update_version.yml` manually, leaving the `append_to_tag` field blank ("") for an actual release.

2. This will increment the version to `vYY.MMrcX` by running `scripts/update_version.py` in the following files -

- `pybamm/version.py`
- `docs/conf.py`
- `CITATION.cff`
- `pyproject.toml`
- `vcpkg.json`
- `CHANGELOG.md`

These changes will be automatically pushed to the existing `vYY.MM` branch and a PR will be created to update version strings in `develop`.

3. Next, a PR from `vYY.MM` to `main` will be generated that should be merged once all the tests pass.

4. Create a new GitHub _release_ with the same tag from the `main` branch and a description copied from `CHANGELOG.md`.

5. This release will automatically trigger `publish_pypi.yml` and create a _release_ on PyPI.
5. Create a new GitHub release with the same tag (`YY.MM.x`) from the `main`
branch and a description copied from `CHANGELOG.md`. This release will
automatically trigger `publish_pypi.yml` and create a _release_ on PyPI.

## Other checks

Some other essential things to check throughout the release process -

- If updating our custom vcpkg registory entries [pybamm-team/sundials-vcpkg-registry](https://github.com/pybamm-team/sundials-vcpkg-registry) or [pybamm-team/casadi-vcpkg-registry](https://github.com/pybamm-team/casadi-vcpkg-registry) (used to build Windows wheels), make sure to update the baseline of the registories 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
- As the release workflow is initiated by the `release` event, it's important to note that the default `GITHUB_REF` used by `actions/checkout` during the checkout process will correspond to the tag created during the release process. Consequently, the workflows will consistently build PyBaMM based on the commit associated with this tag. Should new commits be introduced to the `vYY.MM` branch, such as those addressing build issues, it becomes necessary to manually update this tag to point to the most recent commit -
```
git tag -f <tag_name> <commit_hash>
git push -f <pybamm-team/PyBaMM_remote_name> <tag_name> # can only be carried out by the maintainers
```
- If changes are made to the API, console scripts, entry points, new optional dependencies are added, support for major Python versions is dropped or added, or core project information and metadata are modified at the time of the release, make sure to update the `meta.yaml` file in the `recipe/` folder of the [conda-forge/pybamm-feedstock](https://github.com/conda-forge/pybamm-feedstock) repository accordingly by following the instructions in the [conda-forge documentation](https://conda-forge.org/docs/maintainer/updating_pkgs.html#updating-the-feedstock-repository) and re-rendering the recipe
- The conda-forge release workflow will automatically be triggered following a stable PyPI release, and the aforementioned updates should be carried out directly in the main repository by pushing changes to the automated PR created by the conda-forge-bot. A manual PR can also be created if the updates are not included in the automated PR for some reason. This manual PR **must** bump the build number in `meta.yaml` and **must** be from a personal fork of the repository.
- 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
dependencies are added, support for major Python versions is dropped or
added, or core project information and metadata are modified at the time
of the release, make sure to update the `meta.yaml` file in the `recipe/`
folder of the [pybamm-feedstock][PYBAMM_FEED] repository accordingly by
following the instructions in the [conda-forge documentation][FEED_GUIDE] and
re-rendering the recipe.
- The conda-forge release workflow will automatically be triggered following
a stable PyPI release, and the aforementioned updates should be carried
out directly in the main repository by pushing changes to the automated PR
created by the conda-forge-bot. A manual PR can also be created if the
updates are not included in the automated PR for some reason. This manual
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
7 changes: 5 additions & 2 deletions .github/workflows/benchmark_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ jobs:
sudo apt-get update
sudo apt install gfortran gcc libopenblas-dev
- name: Set up uv
run: python -m pip install uv

- name: Install python dependencies
run: |
python -m pip install --upgrade pip wheel setuptools wget cmake casadi numpy
python -m pip install asv[virtualenv]
python -m uv pip install --upgrade pip wheel setuptools wget cmake casadi numpy
python -m uv pip install asv[virtualenv]
- name: Install SuiteSparse and SUNDIALS
run: python scripts/install_KLU_Sundials.py
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/periodic_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ jobs:
sudo apt-get update
sudo apt-get install gfortran gcc libopenblas-dev
- name: Set up uv
run: python -m pip install uv

- name: Install python dependencies
run: |
python -m pip install --upgrade pip wheel setuptools wget cmake casadi numpy
python -m pip install asv[virtualenv]
python -m uv pip install --upgrade pip wheel setuptools wget cmake casadi numpy
python -m uv pip install asv[virtualenv]
- name: Install SuiteSparse and SUNDIALS
run: python scripts/install_KLU_Sundials.py
Expand All @@ -48,7 +51,7 @@ jobs:
LD_LIBRARY_PATH: $HOME/.local/lib

- name: Upload results as artifact
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: asv_periodic_results
path: results
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ jobs:
CMAKE_BUILD_PARALLEL_LEVEL=${{ steps.get_num_cores.outputs.count }}
CIBW_ARCHS: AMD64
CIBW_BEFORE_BUILD: python -m pip install setuptools wheel delvewheel # skip CasADi and CMake
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair -w {dest_dir} {wheel}
# Fix access violation because GHA runners have modified PATH that picks wrong
# msvcp140.dll, see https://github.com/adang1345/delvewheel/issues/54
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/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: wheels_windows
path: ./wheelhouse/*.whl
Expand Down Expand Up @@ -127,7 +129,7 @@ jobs:
python -m pytest -m cibw {project}/tests/unit
- name: Upload wheels for Linux
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: wheels_manylinux
path: ./wheelhouse/*.whl
Expand All @@ -149,9 +151,6 @@ jobs:
- 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: Set macOS-specific environment variables
run: echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV

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

Expand Down Expand Up @@ -243,13 +242,15 @@ jobs:
python scripts/install_KLU_Sundials.py
python -m cibuildwheel --output-dir wheelhouse
env:
# 10.13 for Intel (macos-12/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_REPAIR_WHEEL_COMMAND: |
if [[ $(uname -m) == "x86_64" ]]; then
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
elif [[ $(uname -m) == "arm64" ]]; then
# Use higher macOS target for now: https://github.com/casadi/casadi/issues/3698
# Use higher macOS target for now since casadi/libc++.1.0.dylib is still not fixed
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} --require-target-macos-version 11.1
for file in {dest_dir}/*.whl; do mv "$file" "${file//macosx_11_1/macosx_11_0}"; done
fi
Expand All @@ -260,7 +261,7 @@ jobs:
python -m pytest -m cibw {project}/tests/unit
- name: Upload wheels for macOS (amd64, arm64)
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: wheels_${{ matrix.os }}
path: ./wheelhouse/*.whl
Expand All @@ -280,7 +281,7 @@ jobs:
run: pipx run build --sdist

- name: Upload SDist
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: sdist
path: ./dist/*.tar.gz
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/release_reminder.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/run_benchmarks_over_history.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
${{ github.event.inputs.commit_start }}..${{ github.event.inputs.commit_end }}
- name: Upload results as artifact
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: asv_over_history_results
path: results
Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/run_periodic_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Set up uv
run: python -m pip install uv

- name: Install nox
run: python -m pip install nox
run: python -m uv pip install nox[uv]

- name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS
timeout-minutes: 10
Expand Down Expand Up @@ -114,8 +117,11 @@ jobs:
with:
python-version: 3.11

- name: Set up uv
run: python -m pip install uv

- name: Install nox
run: python -m pip install nox
run: python -m uv pip install nox[uv]

- name: Install docs dependencies and run doctests for GNU/Linux
run: python -m nox -s doctests
Expand All @@ -141,8 +147,11 @@ jobs:
with:
python-version: 3.12

- name: Set up uv
run: python -m pip install uv

- name: Install nox
run: python -m pip install nox
run: python -m uv pip install nox[uv]

- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
Expand All @@ -169,8 +178,11 @@ jobs:
with:
python-version: 3.12

- name: Set up uv
run: python -m pip install uv

- name: Install nox
run: python -m pip install nox
run: python -m uv pip install nox[uv]

- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: SARIF file
path: results.sarif
Expand All @@ -68,6 +68,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5
uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
with:
sarif_file: results.sarif
Loading

0 comments on commit b3aeaf1

Please sign in to comment.