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

Create Optional Dependencies #3044

Merged
merged 34 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0c14b09
Group Optional Dependencies
arjxn-py Jun 16, 2023
5fa1311
Add `noxfile` & modify workflow for it
arjxn-py Jun 16, 2023
4361846
style: pre-commit fixes
pre-commit-ci[bot] Jun 16, 2023
2b749f4
Make a tests group for CI
arjxn-py Jun 16, 2023
7123272
style: pre-commit fixes
pre-commit-ci[bot] Jun 16, 2023
1381d39
Add `pybtex` in docs
arjxn-py Jun 17, 2023
3d99eb8
Add anytree to doctests
arjxn-py Jun 17, 2023
994db56
Also Installing tests deps in doctests
arjxn-py Jun 18, 2023
c87e117
Merge branch 'develop' into make-deps-optional
arjxn-py Jun 19, 2023
72a889c
Remove importlib-metadata from deps
arjxn-py Jun 19, 2023
3634661
Create examples group for `examples`
arjxn-py Jun 20, 2023
ad1d9b1
Add `tqdm` as dependency
arjxn-py Jun 20, 2023
ca20dbc
Missed installing dev deps in `examples`
arjxn-py Jun 20, 2023
65a2650
Apply suggestions from code review
arjxn-py Jun 25, 2023
e2f8d5d
Remove doc deps from [all]
arjxn-py Jun 25, 2023
e7a6536
Added required deps section in docs
arjxn-py Jun 25, 2023
fee6b07
Added [plot] deps in docs
arjxn-py Jun 25, 2023
b81bb90
Add [docs] deps in docs
arjxn-py Jun 25, 2023
14bcf3a
Added `[example]` deps in docs
arjxn-py Jun 25, 2023
574c37c
Add `[dev]` deps in docs
arjxn-py Jun 25, 2023
828aa05
Add extra deps
arjxn-py Jun 25, 2023
52f4118
Remove extra deps from deps
arjxn-py Jun 26, 2023
afe2449
Remove required deps from `[all]` & conf. tests
arjxn-py Jun 26, 2023
1a6cbb7
Changelog & fix headings
arjxn-py Jun 26, 2023
b5030f9
Merge branch 'develop' into make-deps-optional
arjxn-py Jun 27, 2023
6a88625
Also Installing `dev` deps in doctests
arjxn-py Jun 28, 2023
a8101d3
Installing `[all]` in sessions & edit docs
arjxn-py Jun 28, 2023
c25cab9
Remove 3 deps from `[dev]` & update docs
arjxn-py Jun 29, 2023
50f20cc
Squash Previous 6 commits
arjxn-py Jul 4, 2023
876b822
Merge branch 'develop' into make-deps-optional
arjxn-py Jul 4, 2023
3b75abe
Opening notebooks in `main` with `Open with Colab`
arjxn-py Jul 4, 2023
6943229
Apply suggestions from code review
arjxn-py Jul 4, 2023
432b02b
Merge branch 'develop' into make-deps-optional
Saransh-cpp Jul 5, 2023
63524b4
Formatting and minor fixes
Saransh-cpp Jul 5, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)

## Breaking changes

- PyBaMM now has optional dependencies that can be installed with the pattern `pip install pybamm[option]` e.g. `pybamm[plot]` ([#3044](https://github.com/pybamm-team/PyBaMM/pull/3044))

## Bug fixes

- Parameters in `Prada2013` have been updated to better match those given in the paper, which is a 2.3 Ah cell, instead of the mix-and-match with the 1.1 Ah cell from Lain2019.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Scheduled](https://github.com/pybamm-team/PyBaMM/actions/workflows/run_periodic_tests.yml/badge.svg?branch=develop)](https://github.com/pybamm-team/PyBaMM/actions/workflows/run_periodic_tests.yml)
[![readthedocs](https://readthedocs.org/projects/pybamm/badge/?version=latest)](https://pybamm.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/pybamm-team/PyBaMM/branch/main/graph/badge.svg)](https://codecov.io/gh/pybamm-team/PyBaMM)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/develop/)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/main/)
[![DOI](https://zenodo.org/badge/DOI/10.5334/jors.309.svg)](https://doi.org/10.5334/jors.309)
[![release](https://img.shields.io/github/v/release/pybamm-team/PyBaMM?color=yellow)](https://github.com/pybamm-team/PyBaMM/releases)
[![black code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jupyter # For example notebooks
pybtex
sympy >= 1.8
xarray
tqdm
# Note: Matplotlib is loaded for debug plots but to ensure pybamm runs
# on systems without an attached display it should never be imported
# outside of plot() methods.
Expand Down
146 changes: 145 additions & 1 deletion docs/source/user_guide/installation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,152 @@ Following GNU/Linux and macOS solvers are optionally available:
* `scikits.odes <https://scikits-odes.readthedocs.io/en/latest/>`_ -based solver, see `Optional - scikits.odes solver <https://pybamm.readthedocs.io/en/latest/source/user_guide/installation/GNU-linux.html#optional-scikits-odes-solver>`_.
* `jax <https://jax.readthedocs.io/en/latest/notebooks/quickstart.html>`_ -based solver, see `Optional - JaxSolver <https://pybamm.readthedocs.io/en/latest/source/user_guide/installation/GNU-linux.html#optional-jaxsolver>`_.

Dependencies
------------
.. _install.required_dependencies:

Required dependencies
~~~~~~~~~~~~~~~~~~~~~

PyBaMM requires the following dependencies.

================================================================ ==========================
Package Minimum supported version
================================================================ ==========================
`NumPy <https://numpy.org>`__ 1.16.0
`SciPy <https://docs.scipy.org/doc/scipy/>`__ 2.8.2
`pandas <https://pandas.pydata.org/docs/>`__ 0.24.0
`CasADi <https://web.casadi.org/docs/>`__ 3.6.0
`Xarray <https://docs.xarray.dev/en/stable/>`__ 2023.04.0
================================================================ ==========================

.. _install.optional_dependencies:

Optional Dependencies
~~~~~~~~~~~~~~~~~~~~~

PyBaMM has a number of optional dependencies for different functionalities.
arjxn-py marked this conversation as resolved.
Show resolved Hide resolved
If the optional dependency is not installed, PyBaMM will raise an ImportError when the method requiring that dependency is called.

If using pip, optional PyBaMM dependencies can be installed or managed in a file (e.g. requirements.txt or setup.py)
as optional extras (e.g.,``pybamm[dev,plot]``). All optional dependencies can be installed with ``pybamm[all]``,
and specific sets of dependencies are listed in the sections below.

.. _install.plot_dependencies:

Plot dependencies
^^^^^^^^^^^^^^^^^

Installable with ``pip install "pybamm[plot]"``

=========================================================== ================== ================== ==================================================================
Dependency Minimum Version pip extra Notes
=========================================================== ================== ================== ==================================================================
`imageio <https://imageio.readthedocs.io/en/stable/>`__ 2.9.0 plot For generating simulation GIFs.
`matplotlib <https://matplotlib.org/stable/>`__ 2.0.0 plot To plot various battery models, and analyzing battery performance.
=========================================================== ================== ================== ==================================================================

.. _install.docs_dependencies:

Docs dependencies
^^^^^^^^^^^^^^^^^

Installable with ``pip install "pybamm[docs]"``

================================================================================================= ================== ================== =======================================================================
Dependency Minimum Version pip extra Notes
================================================================================================= ================== ================== =======================================================================
`sphinx <https://www.sphinx-doc.org/en/master/>`__ 1.5.0 docs Sphinx makes it easy to create intelligent and beautiful documentation.
`pydata-sphinx-theme <https://pydata-sphinx-theme.readthedocs.io/en/stable/>`__ \- docs A clean, Bootstrap-based Sphinx theme.
`sphinx_design <https://sphinx-design.readthedocs.io/en/latest/>`__ \- docs A sphinx extension for designing.
`sphinx-copybutton <https://sphinx-copybutton.readthedocs.io/en/latest/>`__ \- docs To copy codeblocks.
`myst-parser <https://myst-parser.readthedocs.io/en/latest/>`__ \- docs For technical & scientific documentation.
`sphinx-inline-tabs <https://sphinx-inline-tabs.readthedocs.io/en/latest/>`__ \- docs Add inline tabbed content to your Sphinx documentation.
`sphinxcontrib-bibtex <https://sphinxcontrib-bibtex.readthedocs.io/en/latest/>`__ \- docs For BibTeX citations.
`sphinx-autobuild <https://sphinx-extensions.readthedocs.io/en/latest/sphinx-autobuild.html>`__ \- docs For re-building docs once triggered.
================================================================================================= ================== ================== =======================================================================

.. _install.examples_dependencies:

Examples dependencies
^^^^^^^^^^^^^^^^^^^^^

Installable with ``pip install "pybamm[examples]"``

================================================================================ ================== ================== ================================
Dependency Minimum Version pip extra Notes
================================================================================ ================== ================== ================================
`jupyter <https://docs.jupyter.org/en/latest/>`__ \- examples For example notebooks rendering.
================================================================================ ================== ================== ================================

.. _install.dev_dependencies:

Dev dependencies
^^^^^^^^^^^^^^^^^

Installable with ``pip install "pybamm[dev]"``

================================================================================ ================== ================== =============================================================
Dependency Minimum Version pip extra Notes
================================================================================ ================== ================== =============================================================
`pre-commit <https://pre-commit.com/index.html>`__ \- dev For managing and maintaining multi-language pre-commit hooks.
`black <https://black.readthedocs.io/en/stable/>`__ \- dev For code formatting.
================================================================================ ================== ================== =============================================================

.. _install.cite_dependencies:

Cite dependencies
^^^^^^^^^^^^^^^^^

Installable with ``pip install "pybamm[cite]"``

=========================================================== ================== ================== =========================================
Dependency Minimum Version pip extra Notes
=========================================================== ================== ================== =========================================
`pybtex <https://docs.pybtex.org/>`__ 0.24.0 cite BibTeX-compatible bibliography processor.
=========================================================== ================== ================== =========================================

.. _install.latexify_dependencies:

Latexify dependencies
^^^^^^^^^^^^^^^^^^^^^

Installable with ``pip install "pybamm[latexify]"``

=========================================================== ================== ================== =========================
Dependency Minimum Version pip extra Notes
=========================================================== ================== ================== =========================
`sympy <https://docs.sympy.org/latest/index.html>`__ 1.8.0 latexify For symbolic mathematics.
=========================================================== ================== ================== =========================

.. _install.bpx_dependencies:

bpx dependencies
^^^^^^^^^^^^^^^^^

Installable with ``pip install "pybamm[bpx]"``

=========================================================== ================== ================== ==========================
Dependency Minimum Version pip extra Notes
=========================================================== ================== ================== ==========================
`bpx <https://pypi.org/project/bpx/>`__ \- bpx Battery Parameter eXchange
=========================================================== ================== ================== ==========================

.. _install.tqdm_dependencies:

tqdm dependencies
^^^^^^^^^^^^^^^^^

Installable with ``pip install "pybamm[tqdm]"``

=========================================================== ================== ================== ==================
Dependency Minimum Version pip extra Notes
=========================================================== ================== ================== ==================
`tqdm <https://tqdm.github.io/>`__ \- tqdm For logging loops.
=========================================================== ================== ================== ==================

Full installation guide
-----------------------
-----------------------

Installing a specific version? Installing from source? Check the advanced installation pages below

Expand Down
16 changes: 8 additions & 8 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run_coverage(session):
"LD_LIBRARY_PATH"
] = f"{homedir}/.local/lib:{session.env.get('LD_LIBRARY_PATH')}"
session.install("coverage")
session.install("-e", ".")
session.install("-e", ".[all]")
if sys.platform != "win32":
session.install("scikits.odes")
session.run("pybamm_install_jax")
Expand All @@ -49,15 +49,15 @@ def run_integration(session):
session.env[
"LD_LIBRARY_PATH"
] = f"{homedir}/.local/lib:{session.env.get('LD_LIBRARY_PATH')}"
session.install("-e", ".[dev]")
session.install("-e", ".[all]")
if sys.platform == "linux":
session.install("scikits.odes")
session.run("python", "run-tests.py", "--integration")


@nox.session(name="doctests", reuse_venv=True)
def run_doctests(session):
session.install("-e", ".[docs]")
session.install("-e", ".[all,docs]")
arjxn-py marked this conversation as resolved.
Show resolved Hide resolved
session.run("python", "run-tests.py", "--doctest")


Expand All @@ -68,7 +68,7 @@ def run_unit(session):
session.env[
"LD_LIBRARY_PATH"
] = f"{homedir}/.local/lib:{session.env.get('LD_LIBRARY_PATH')}"
session.install("-e", ".")
session.install("-e", ".[all]")
if sys.platform == "linux":
session.run("pybamm_install_jax")
session.install("scikits.odes")
Expand All @@ -77,7 +77,7 @@ def run_unit(session):

@nox.session(name="examples", reuse_venv=True)
def run_examples(session):
session.install("-e", ".[dev]")
session.install("-e", ".[all]")
session.run("python", "run-tests.py", "--examples")


Expand All @@ -86,7 +86,7 @@ def set_dev(session):
homedir = os.getenv("HOME")
LD_LIBRARY_PATH = f"{homedir}/.local/lib:{session.env.get('LD_LIBRARY_PATH')}"
envbindir = session.bin
session.install("-e", ".[dev]")
session.install("-e", ".[all]")
session.install("cmake")
session.run(
"echo",
Expand All @@ -104,7 +104,7 @@ def run_tests(session):
session.env[
"LD_LIBRARY_PATH"
] = f"{homedir}/.local/lib:{session.env.get('LD_LIBRARY_PATH')}"
session.install("-e", ".[dev]")
session.install("-e", ".[all]")
if sys.platform == "linux" or sys.platform == "darwin":
session.run("pybamm_install_jax")
session.install("scikits.odes")
Expand All @@ -114,7 +114,7 @@ def run_tests(session):
@nox.session(name="docs", reuse_venv=True)
def build_docs(session):
envbindir = session.bin
session.install("-e", ".[docs]")
session.install("-e", ".[all,docs]")
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved
with session.chdir("docs/"):
session.run(
"sphinx-autobuild",
Expand Down
49 changes: 35 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,8 @@ def compile_KLU():
"numpy>=1.16",
"scipy>=1.3",
"pandas>=0.24",
"anytree>=2.4.3",
"autograd>=1.2",
"scikit-fem>=0.2.0",
"casadi>=3.6.0",
"imageio>=2.9.0",
"pybtex>=0.24.0",
"sympy>=1.8",
"xarray",
"bpx",
"tqdm",
# Note: Matplotlib is loaded for debug plots, but to ensure pybamm runs
# on systems without an attached display, it should never be imported
# outside of plot() methods.
# Should not be imported
"matplotlib>=2.0",
],
extras_require={
"docs": [
Expand All @@ -240,10 +227,44 @@ def compile_KLU():
"sphinx-gallery",
"sphinx-hoverxref",
], # For doc generation
"examples": [
"jupyter", # For example notebooks
],
"plot": [
"imageio>=2.9.0",
# Note: Matplotlib is loaded for debug plots, but to ensure pybamm runs
# on systems without an attached display, it should never be imported
# outside of plot() methods.
# Should not be imported
"matplotlib>=2.0",
],
"cite": [
"pybtex>=0.24.0",
],
"latexify": [
"sympy>=1.8",
],
"bpx": [
"bpx",
],
"tqdm": [
"tqdm",
],
"dev": [
"pre-commit", # For code style checking
"black", # For code style auto-formatting
"jupyter", # For example notebooks
],
"all": [
"anytree>=2.4.3",
"autograd>=1.2",
"scikit-fem>=0.2.0",
"imageio>=2.9.0",
"pybtex>=0.24.0",
"sympy>=1.8",
"bpx",
"tqdm",
"matplotlib>=2.0",
"jupyter",
],
},
entry_points={
Expand Down