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 13 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
31 changes: 10 additions & 21 deletions .github/workflows/run_periodic_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,46 +86,35 @@ jobs:

- name: Install standard python dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install "tox<4"

python -m pip install --upgrade pip wheel setuptools nox

- name: Install SuiteSparse and Sundials
if: matrix.os == 'ubuntu-latest'
run: tox -e pybamm-requires
run: nox -s pybamm-requires

- name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10
if: matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11
run: python -m tox -e unit
run: nox -s unit

- name: Run unit tests for GNU/Linux with Python 3.11 and generate coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11
run: python -m tox -e coverage
run: nox -s coverage

- name: Upload coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11
uses: codecov/codecov-action@v2.1.0

- name: Run integration tests for GNU/Linux
if: matrix.os == 'ubuntu-latest'
run: python -m tox -e integration
- name: Run integration tests
run: nox -s integration

- name: Run unit tests for Windows and MacOS
if: matrix.os != 'ubuntu-latest'
run: python -m tox -e mac-windows-unit

- name: Run integration tests for Windows and MacOS
if: matrix.os != 'ubuntu-latest'
run: python -m tox -e mac-windows-integration
run: nox -s unit

- name: Install docs dependencies and run doctests
if: matrix.os == 'ubuntu-latest'
run: tox -e doctests
run: nox -s doctests

- name: Install dev dependencies and run example tests
if: matrix.os == 'ubuntu-latest'
run: tox -e examples

- name: Install scikits.odes and test pybamm_install_odes
if: matrix.os == 'ubuntu-latest'
run: |
tox -e odes
run: nox -s examples
16 changes: 8 additions & 8 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,36 @@ jobs:
- name: Install standard Python dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install "tox<4"
python -m pip install "nox"

- name: Install SuiteSparse and Sundials
if: matrix.os == 'ubuntu-latest'
run: tox -e pybamm-requires
run: nox -s pybamm-requires

- name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10
if: matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11
run: python -m tox -e unit
run: nox -s unit

- name: Run unit tests for GNU/Linux with Python 3.11 and generate coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11
run: python -m tox -e coverage
run: nox -s coverage

- name: Upload coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11
uses: codecov/codecov-action@v2.1.0

- name: Run integration tests for GNU/Linux with Python 3.11
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11
run: python -m tox -e integration
run: nox -s integration

- name: Run unit tests for Windows and MacOS with all Python versions
if: matrix.os != 'ubuntu-latest'
run: python -m tox -e mac-windows-unit
run: nox -s unit

- name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11
run: tox -e doctests
run: nox -s doctests

- name: Install dev dependencies and run example tests for GNU/Linux with Python 3.11
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11
run: tox -e examples
run: nox -s examples
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
123 changes: 123 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import nox
import os
import sys


@nox.session(name="pybamm-requires")
def run_pybamm_requires(session):
homedir = os.getenv("HOME")
session.env["SUNDIALS_INST"] = session.env.get("SUNDIALS_INST", f"{homedir}/.local")
session.env[
"LD_LIBRARY_PATH"
] = f"{homedir}/.local/lib:{session.env.get('LD_LIBRARY_PATH')}"
if sys.platform != "win32" or sys.platform != "darwin":
session.install("wget", "cmake")
session.run("python", "scripts/install_KLU_Sundials.py")
session.run(
"git",
"clone",
"https://github.com/pybind/pybind11.git",
"pybind11/",
external=True,
)


@nox.session(name="coverage")
def run_coverage(session):
homedir = os.getenv("HOME")
session.env["SUNDIALS_INST"] = session.env.get("SUNDIALS_INST", f"{homedir}/.local")
session.env[
"LD_LIBRARY_PATH"
] = f"{homedir}/.local/lib:{session.env.get('LD_LIBRARY_PATH')}"
session.install("coverage")
session.install("-e", ".[dev]")
if sys.platform != "win32" or sys.platform != "darwin":
session.install("scikits.odes")
session.run("pybamm_install_jax")
session.run("coverage", "run", "--rcfile=.coveragerc", "run-tests.py", "--nosub")
session.run("coverage", "combine")
session.run("coverage", "xml")


@nox.session(name="integration", reuse_venv=True)
def run_integration(session):
homedir = os.getenv("HOME")
session.env["SUNDIALS_INST"] = session.env.get("SUNDIALS_INST", f"{homedir}/.local")
session.env[
"LD_LIBRARY_PATH"
] = f"{homedir}/.local/lib:{session.env.get('LD_LIBRARY_PATH')}"
session.install("-e", ".[dev]")
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", ".[dev]")
session.install("-e", ".[docs]")
session.run("python", "run-tests.py", "--doctest")


@nox.session(name="unit", reuse_venv=True)
def run_unit(session):
homedir = os.getenv("HOME")
session.env["SUNDIALS_INST"] = session.env.get("SUNDIALS_INST", f"{homedir}/.local")
session.env[
"LD_LIBRARY_PATH"
] = f"{homedir}/.local/lib:{session.env.get('LD_LIBRARY_PATH')}"
session.install("-e", ".[dev]")
if sys.platform == "linux":
session.run("pybamm_install_jax")
session.install("scikits.odes")
session.run("python", "run-tests.py", "--unit")


@nox.session(name="examples", reuse_venv=True)
def run_examples(session):
session.install("-e", ".[dev]")
session.install("-e", ".[examples]")
arjxn-py marked this conversation as resolved.
Show resolved Hide resolved
session.run("python", "run-tests.py", "--examples")


@nox.session(name="dev", reuse_venv=True)
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("cmake")
session.run(
"echo",
"export",
f"LD_LIBRARY_PATH={LD_LIBRARY_PATH}",
">>",
f"{envbindir}/activate",
)


@nox.session(name="tests", reuse_venv=True)
def run_tests(session):
session.install("-e", ".[dev]")
if sys.platform == "linux":
session.run("pybamm_install_jax")
session.run("python", "run-tests.py", "--all")


@nox.session(name="docs", reuse_venv=True)
def build_docs(session):
envbindir = session.bin
session.install("-e", ".[dev]")
session.install(
"sphinx>=1.5",
"pydata-sphinx-theme",
"sphinx-autobuild",
"sphinx_design",
"sphinx-copybutton",
"myst-parser",
"sphinx-inline-tabs",
)
session.chdir("docs/")
session.run(
"sphinx-autobuild", "--open-browser", "-qT", ".", f"{envbindir}/../tmp/html"
)
76 changes: 62 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 @@ -231,11 +218,72 @@ def compile_KLU():
"myst-parser",
"sphinx-inline-tabs",
], # For doc generation
"dev": [
"examples": [
"pre-commit", # For code style checking
"black", # For code style auto-formatting
arjxn-py marked this conversation as resolved.
Show resolved Hide resolved
"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": [
"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",
"matplotlib>=2.0",
arjxn-py marked this conversation as resolved.
Show resolved Hide resolved
],
"all": [
"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",
"matplotlib>=2.0",
"sphinx>=1.5",
"pydata-sphinx-theme",
"sphinx_design",
"sphinx-copybutton",
"myst-parser",
"sphinx-inline-tabs",
arjxn-py marked this conversation as resolved.
Show resolved Hide resolved
"pre-commit",
"black",
arjxn-py marked this conversation as resolved.
Show resolved Hide resolved
"jupyter",
],
},
entry_points={
"console_scripts": [
Expand Down