diff --git a/.all-contributorsrc b/.all-contributorsrc index bec2dd43f5..ab735fcd78 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,6 @@ { "files": [ "all_contributors.md", - "README.md" ], "imageSize": 100, "commit": false, @@ -517,10 +516,10 @@ ] }, { - "login": "abillscmu", + "login": "aabills", "name": "Alec Bills", "avatar_url": "https://avatars.githubusercontent.com/u/48105066?v=4", - "profile": "https://github.com/abillscmu", + "profile": "https://github.com/aabills", "contributions": [ "code" ] diff --git a/.github/workflows/lychee_url_checker.yml b/.github/workflows/lychee_url_checker.yml index fc3549a5bd..98dd7a266d 100644 --- a/.github/workflows/lychee_url_checker.yml +++ b/.github/workflows/lychee_url_checker.yml @@ -17,7 +17,7 @@ jobs: # cache Lychee results to avoid hitting rate limits - name: Restore lychee cache - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: .lycheecache key: cache-lychee-${{ github.sha }} diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 545c45ab15..a55510f42f 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -52,7 +52,7 @@ jobs: run: git clone --depth 1 --branch v2.12.0 https://github.com/pybind/pybind11.git -c advice.detachedHead=false - name: Cache packages installed through vcpkg on Windows - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 env: cache-name: vckpg_binary_cache with: @@ -77,7 +77,7 @@ jobs: CMAKE_GENERATOR_PLATFORM=x64 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_BEFORE_BUILD: python -m pip install setuptools delvewheel # skip CasADi and CMake # 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} @@ -243,7 +243,7 @@ jobs: # 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 cmake casadi setuptools delocate CIBW_REPAIR_WHEEL_COMMAND: | if [[ $(uname -m) == "x86_64" ]]; then delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} @@ -314,13 +314,13 @@ jobs: - name: Publish to PyPI if: github.event.inputs.target == 'pypi' || github.event_name == 'release' - uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2 + uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3 with: packages-dir: artifacts/ - name: Publish to TestPyPI if: github.event.inputs.target == 'testpypi' - uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2 + uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3 with: packages-dir: artifacts/ repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index b1e08b63eb..5e2b4a4017 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -85,7 +85,7 @@ jobs: - name: Upload coverage report if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' - uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 + uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 1c9c51f9bd..03822b3bd6 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -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@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6 with: sarif_file: results.sarif diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 8a77262a7e..1e759b0f2a 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -3,6 +3,7 @@ name: PyBaMM on: workflow_dispatch: pull_request: + paths-ignore: [".all-contributorsrc", "all_contributors.md"] env: PYBAMM_DISABLE_TELEMETRY: "true" @@ -96,7 +97,7 @@ jobs: run: python -m uv pip install nox[uv] - name: Cache pybamm-requires nox environment for GNU/Linux and macOS - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 if: matrix.os != 'windows-latest' with: path: | @@ -123,7 +124,7 @@ jobs: - name: Upload coverage report if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' - uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 + uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -212,7 +213,7 @@ jobs: run: python -m uv pip install nox[uv] - name: Cache pybamm-requires nox environment for GNU/Linux - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: | # Repository files @@ -267,7 +268,7 @@ jobs: run: python -m uv pip install nox[uv] - name: Cache pybamm-requires nox environment for GNU/Linux - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: | # Repository files diff --git a/.github/workflows/validation_benchmarks.yml b/.github/workflows/validation_benchmarks.yml index 1f50a70591..5b5d5fad21 100644 --- a/.github/workflows/validation_benchmarks.yml +++ b/.github/workflows/validation_benchmarks.yml @@ -13,13 +13,14 @@ jobs: name: Dispatch to `pybamm-validation` runs-on: ubuntu-latest steps: - - uses: mvasigh/dispatch-action@7d246d27377b345bd9c58646c51641bec9c7435c # 1.1.6 + - uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0 with: token: ${{ secrets.BENCHMARKS_ACCESS_TOKEN }} - repo: pybamm-validation - owner: pybamm-team - event_type: ${{ github.event_name }} - message: | + repository: pybamm-team/pybamm-validation + event-type: ${{ github.event_name }} + client-payload: |- { - "commit_hash": "$GITHUB_SHA" + "message": { + "commit_hash": "$GITHUB_SHA" + } } diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 20f24faeb6..4c3ef44e6e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.8.1" + rev: "v0.8.2" hooks: - id: ruff args: [--fix, --show-fixes] diff --git a/CHANGELOG.md b/CHANGELOG.md index 508c5f3058..920a292683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ## Breaking changes +- The conda distribution (`pybamm`) now installs all optional dependencies available on conda-forge. Use the new `pybamm-base` conda +package to install PyBaMM with only the required dependencies. ([conda-forge/pybamm-feedstock#70](https://github.com/conda-forge/pybamm-feedstock/pull/70)) - Separated extrapolation options for `pybamm.BoundaryValue` and `pybamm.BoundaryGradient`, and updated the default to be "linear" for the value and "quadratic" for the gradient. ([#4614](https://github.com/pybamm-team/PyBaMM/pull/4614)) - 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)) diff --git a/README.md b/README.md index 20fe7804a4..31ea45cebe 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,6 @@ [![code style](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/pybamm-team/PyBaMM/badge)](https://scorecard.dev/viewer/?uri=github.com/pybamm-team/PyBaMM) - -[![All Contributors](https://img.shields.io/badge/all_contributors-94-orange.svg)](#-contributors) - - # PyBaMM diff --git a/all_contributors.md b/all_contributors.md index b4a6751da1..61434b6750 100644 --- a/all_contributors.md +++ b/all_contributors.md @@ -1,3 +1,8 @@ + + +[![All Contributors](https://img.shields.io/badge/all_contributors-94-orange.svg)](#-contributors) + + Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): diff --git a/docs/source/user_guide/installation/gnu-linux-mac.rst b/docs/source/user_guide/installation/gnu-linux-mac.rst index 97171b53b7..877462b5ac 100644 --- a/docs/source/user_guide/installation/gnu-linux-mac.rst +++ b/docs/source/user_guide/installation/gnu-linux-mac.rst @@ -50,7 +50,8 @@ To create a virtual environment ``env`` within your current directory type: virtualenv env -You can then “activate” the environment using: +or use any of your preferred environment management tools. You can then “activate” +the environment using: .. code:: bash @@ -64,27 +65,28 @@ the environment and go back to your original system, just type: deactivate -PyBaMM can be installed via pip. On macOS, it is necessary to install the `SUNDIALS `__ +PyBaMM can be installed via ``pip`` or ``conda``. library beforehand. -.. tab:: GNU/Linux - - In a terminal, run the following command: +.. tab:: pip .. code:: bash pip install pybamm -.. tab:: macOS +.. tab:: conda + + .. note:: - In a terminal, run the following command: + At the moment, PyBaMM's conda-forge distribution does not include ``IDAKLUSolver``. .. code:: bash - pip install pybamm + conda install -c conda-forge pybamm-base -PyBaMM’s required dependencies (such as ``numpy``, ``casadi``, etc) will be -installed automatically when you install PyBaMM using ``pip``. +PyBaMM’s `required dependencies `_ +(such as ``numpy``, ``casadi``, etc) will be installed automatically when you +install ``pybamm`` using ``pip`` or ``pybamm-base`` using ``conda``. For an introduction to virtual environments, see (https://realpython.com/python-virtual-environments-a-primer/). @@ -101,6 +103,8 @@ Users can install ``jax`` and ``jaxlib`` to use the Jax solver. The ``pip install "pybamm[jax]"`` command automatically downloads and installs ``pybamm`` and the compatible versions of ``jax`` and ``jaxlib`` on your system. +PyBaMM's full `conda-forge distribution `_ (``pybamm``) includes ``jax`` and ``jaxlib`` by default. + .. _optional-iree-mlir-support: Optional - IREE / MLIR support diff --git a/docs/source/user_guide/installation/index.rst b/docs/source/user_guide/installation/index.rst index 9225f1ee98..9fb81c8532 100644 --- a/docs/source/user_guide/installation/index.rst +++ b/docs/source/user_guide/installation/index.rst @@ -4,42 +4,33 @@ Installation PyBaMM is available on GNU/Linux, MacOS and Windows. It can be installed using ``pip`` or ``conda``, or from source. -.. tab:: GNU/Linux and Windows +.. tab:: pip - .. tab:: pip + PyBaMM can be installed via pip from `PyPI `__. - PyBaMM can be installed via pip from `PyPI `__. + .. code:: bash - .. code:: bash + pip install pybamm - pip install pybamm +.. tab:: conda - .. tab:: conda + PyBaMM is available as a ``conda`` package through the conda-forge channel. - PyBaMM is part of the `Anaconda `_ distribution and is available as a conda package through the conda-forge channel. + The ``pybamm`` package on conda-forge installs PyBaMM with all the `required and optional dependencies `_ available on conda-forge. - .. code:: bash + .. note:: - conda install -c conda-forge pybamm + At the moment, PyBaMM's conda-forge distribution does not include ``IDAKLUSolver``. -.. tab:: macOS + .. code:: bash - .. tab:: pip + conda install -c conda-forge pybamm - PyBaMM can be installed via pip from `PyPI `__. + The ``pybamm-base`` package installs PyBaMM only with its `required dependencies `_. - .. code:: bash + .. code:: bash - pip install pybamm - - - .. tab:: conda - - PyBaMM is part of the `Anaconda `_ distribution and is available as a conda package through the conda-forge channel. - - .. code:: bash - - conda install -c conda-forge pybamm + conda install -c conda-forge pybamm-base Optional solvers diff --git a/docs/source/user_guide/installation/install-from-docker.rst b/docs/source/user_guide/installation/install-from-docker.rst index aeffdd25a1..11771765c7 100644 --- a/docs/source/user_guide/installation/install-from-docker.rst +++ b/docs/source/user_guide/installation/install-from-docker.rst @@ -13,7 +13,7 @@ Ensure Docker installation by running: .. code:: bash - docker --version + docker --version Pulling the Docker image ------------------------ diff --git a/docs/source/user_guide/installation/windows.rst b/docs/source/user_guide/installation/windows.rst index 44dc79a7d3..5e7405abb4 100644 --- a/docs/source/user_guide/installation/windows.rst +++ b/docs/source/user_guide/installation/windows.rst @@ -40,7 +40,8 @@ type: python -m virtualenv env -You can then “activate” the environment using: +or use any of your preferred environment management tools. You can then “activate” +the environment using: .. code:: @@ -56,12 +57,25 @@ the environment and go back to your original system, just type: PyBaMM can be installed via pip: -.. code:: bash +.. tab:: pip + + .. code:: bash + + pip install pybamm + +.. tab:: conda - pip install pybamm + .. note:: -PyBaMM’s dependencies (such as ``numpy``, ``scipy``, etc) will be -installed automatically when you install PyBaMM using ``pip``. + At the moment, PyBaMM's conda-forge distribution does not include ``IDAKLUSolver``. + + .. code:: bash + + conda install -c conda-forge pybamm-base + +PyBaMM’s `required dependencies `_ +(such as ``numpy``, ``casadi``, etc) will be installed automatically when you +install ``pybamm`` using ``pip`` or ``pybamm-base`` using ``conda``. For an introduction to virtual environments, see (https://realpython.com/python-virtual-environments-a-primer/). @@ -77,6 +91,8 @@ Users can install ``jax`` and ``jaxlib`` to use the Jax solver. The ``pip install "pybamm[jax]"`` command automatically downloads and installs ``pybamm`` and the compatible versions of ``jax`` and ``jaxlib`` on your system. +PyBaMM's full `conda-forge distribution `_ (``pybamm``) includes ``jax`` and ``jaxlib`` by default. + Uninstall PyBaMM ---------------- diff --git a/pyproject.toml b/pyproject.toml index 7eb35293e3..923f72438d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ [build-system] requires = [ - "setuptools>=64", - "wheel", + "setuptools>=70.1.1", # On Windows, use the CasADi vcpkg registry and CMake bundled from MSVC "casadi>=3.6.7; platform_system!='Windows'", # Note: the version of CasADi as a build-time dependency should be matched @@ -271,11 +270,6 @@ log_date_format = "%Y-%m-%d %H:%M:%S" source = ["src/pybamm"] concurrency = ["multiprocessing"] -[tool.repo-review] -ignore = [ - "PP003" # list wheel as a build-dep -] - [tool.mypy] ignore_missing_imports = true allow_redefinition = true diff --git a/scripts/Dockerfile b/scripts/Dockerfile index e6fac122ff..a742a51caf 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -28,7 +28,7 @@ RUN uv venv $VIRTUAL_ENV RUN #!/bin/bash && source /home/pybamm/venv/bin/activate; ENV PATH="$VIRTUAL_ENV/bin:$PATH" -RUN uv pip install --upgrade setuptools wheel wget cmake +RUN uv pip install --upgrade setuptools wget cmake RUN python scripts/install_KLU_Sundials.py && \ rm -rf pybind11 && \ diff --git a/setup.py b/setup.py index 8a49bfd715..35f9487aca 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,11 @@ from multiprocessing import cpu_count from pathlib import Path from platform import system -import wheel.bdist_wheel as orig from setuptools import setup, Extension from setuptools.command.install import install from setuptools.command.build_ext import build_ext +from setuptools.command.bdist_wheel import bdist_wheel default_lib_dir = ( @@ -230,29 +230,29 @@ def run(self): # ---------- Custom class for building wheels ------------------------------------------ -class bdist_wheel(orig.bdist_wheel): +class PyBaMMWheel(bdist_wheel): """A custom install command to add 2 build options""" user_options = [ - *orig.bdist_wheel.user_options, + *bdist_wheel.user_options, ("suitesparse-root=", None, "suitesparse source location"), ("sundials-root=", None, "sundials source location"), ] def initialize_options(self): - orig.bdist_wheel.initialize_options(self) + bdist_wheel.initialize_options(self) self.suitesparse_root = None self.sundials_root = None def finalize_options(self): - orig.bdist_wheel.finalize_options(self) + bdist_wheel.finalize_options(self) if not self.suitesparse_root: self.suitesparse_root = default_lib_dir if not self.sundials_root: self.sundials_root = default_lib_dir def run(self): - orig.bdist_wheel.run(self) + bdist_wheel.run(self) def compile_KLU(): @@ -342,7 +342,7 @@ def compile_KLU(): ext_modules=ext_modules, cmdclass={ "build_ext": CMakeBuild, - "bdist_wheel": bdist_wheel, + "bdist_wheel": PyBaMMWheel, "install": CustomInstall, }, ) diff --git a/src/pybamm/experiment/experiment.py b/src/pybamm/experiment/experiment.py index fb20a0180e..ce44457cb2 100644 --- a/src/pybamm/experiment/experiment.py +++ b/src/pybamm/experiment/experiment.py @@ -3,6 +3,7 @@ from .step.base_step import ( _convert_time_to_seconds, _convert_temperature_to_kelvin, + BaseStep, ) @@ -39,7 +40,7 @@ class Experiment: def __init__( self, - operating_conditions: list[str | tuple[str]], + operating_conditions: list[str | tuple[str] | BaseStep], period: str | None = None, temperature: float | None = None, termination: list[str] | None = None, diff --git a/src/pybamm/solvers/idaklu_solver.py b/src/pybamm/solvers/idaklu_solver.py index 484c1ed9b4..730572d082 100644 --- a/src/pybamm/solvers/idaklu_solver.py +++ b/src/pybamm/solvers/idaklu_solver.py @@ -55,9 +55,9 @@ class IDAKLUSolver(pybamm.BaseSolver): Parameters ---------- rtol : float, optional - The relative tolerance for the solver (default is 1e-6). + The relative tolerance for the solver (default is 1e-4). atol : float, optional - The absolute tolerance for the solver (default is 1e-4). + The absolute tolerance for the solver (default is 1e-6). root_method : str or pybamm algebraic solver class, optional The method to use to find initial conditions (for DAE solvers). If a solver class, must be an algebraic solver class.