From 16e06f598dc60d7469d617a05a2fd1a68d22e76b Mon Sep 17 00:00:00 2001 From: Santhosh <52504160+santacodes@users.noreply.github.com> Date: Sun, 1 Sep 2024 22:24:58 +0530 Subject: [PATCH] `uv` support in CI (#4353) * Using uv for testing and benchmark workflows * fix failing notebook tests --- .github/workflows/benchmark_on_push.yml | 7 +++++-- .github/workflows/periodic_benchmarks.yml | 7 +++++-- .github/workflows/run_periodic_tests.yml | 20 ++++++++++++++---- .github/workflows/test_on_push.yml | 25 ++++++++++++++++++----- noxfile.py | 4 ++-- 5 files changed, 48 insertions(+), 15 deletions(-) diff --git a/.github/workflows/benchmark_on_push.yml b/.github/workflows/benchmark_on_push.yml index b0da71461e..2883eb5f26 100644 --- a/.github/workflows/benchmark_on_push.yml +++ b/.github/workflows/benchmark_on_push.yml @@ -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 diff --git a/.github/workflows/periodic_benchmarks.yml b/.github/workflows/periodic_benchmarks.yml index faa008ff05..641627c0ba 100644 --- a/.github/workflows/periodic_benchmarks.yml +++ b/.github/workflows/periodic_benchmarks.yml @@ -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 diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index 2dd9ef8a89..9f10a9c6f7 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index adfb698a69..9224b7df36 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/noxfile.py b/noxfile.py index a34d6e81f4..6567ed167c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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"] @@ -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