Skip to content

Commit

Permalink
uv support in CI (pybamm-team#4353)
Browse files Browse the repository at this point in the history
* Using uv for testing and benchmark workflows

* fix failing notebook tests
  • Loading branch information
santacodes authored Sep 1, 2024
1 parent ad41dbe commit 16e06f5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 15 deletions.
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
7 changes: 5 additions & 2 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 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
25 changes: 20 additions & 5 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ jobs:
with:
python-version: 3.12

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

- name: Check style
run: |
python -m pip install pre-commit
python -m uv pip install pre-commit
pre-commit run -a
run_unit_integration_and_coverage_tests:
Expand Down Expand Up @@ -86,8 +89,11 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- 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: Cache pybamm-requires nox environment for GNU/Linux and macOS
uses: actions/cache@v4
Expand Down Expand Up @@ -158,8 +164,11 @@ jobs:
python-version: 3.11
cache: 'pip'

- 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 Down Expand Up @@ -198,8 +207,11 @@ jobs:
python-version: 3.12
cache: 'pip'

- 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: Cache pybamm-requires nox environment for GNU/Linux
uses: actions/cache@v4
Expand Down Expand Up @@ -251,8 +263,11 @@ jobs:
python-version: 3.12
cache: 'pip'

- 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: Cache pybamm-requires nox environment for GNU/Linux
uses: actions/cache@v4
Expand Down
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


# Options to modify nox behaviour
nox.options.default_venv_backend = "virtualenv"
nox.options.default_venv_backend = "uv|virtualenv"
nox.options.reuse_existing_virtualenvs = True
if sys.platform != "win32":
nox.options.sessions = ["pre-commit", "pybamm-requires", "unit"]
Expand Down Expand Up @@ -207,7 +207,7 @@ def run_examples(session):
"""Run the examples tests for Jupyter notebooks."""
set_environment_variables(PYBAMM_ENV, session=session)
session.install("setuptools", silent=False)
session.install("-e", ".[all,dev]", silent=False)
session.install("-e", ".[all,dev,jax]", silent=False)
notebooks_to_test = session.posargs if session.posargs else []
session.run(
"pytest", "--nbmake", *notebooks_to_test, "docs/source/examples/", external=True
Expand Down

0 comments on commit 16e06f5

Please sign in to comment.