From e3a8c37f97ffec1943fe22cdc65352473d9302f7 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 10:44:35 +0200 Subject: [PATCH 01/11] Use `uv` as Nox backend --- .github/workflows/nox.yml | 2 ++ noxfile.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/nox.yml b/.github/workflows/nox.yml index 499b48c4e..f48f592d9 100644 --- a/.github/workflows/nox.yml +++ b/.github/workflows/nox.yml @@ -20,6 +20,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Register Python problem matcher run: echo "::add-matcher::.github/workflows/matchers/pytest.json" - name: Install dependencies diff --git a/noxfile.py b/noxfile.py index 55544435c..c08e010ba 100644 --- a/noxfile.py +++ b/noxfile.py @@ -2,6 +2,8 @@ import nox +nox.options.default_venv_backend = "uv" + @nox.session(python=["3.9", "3.10", "3.11", "3.12"]) @nox.parametrize("all_deps", [True, False]) From b2facbf2c2ad3fe8f4c7d1519be63b089c2b8bc8 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 10:54:12 +0200 Subject: [PATCH 02/11] Use `uv` with Nox --- .github/workflows/nox.yml | 6 ++---- README.md | 4 ++-- noxfile.py | 6 +++--- pyproject.toml | 9 ++++++++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/nox.yml b/.github/workflows/nox.yml index f48f592d9..b2cc51c7c 100644 --- a/.github/workflows/nox.yml +++ b/.github/workflows/nox.yml @@ -24,9 +24,7 @@ jobs: uses: astral-sh/setup-uv@v6 - name: Register Python problem matcher run: echo "::add-matcher::.github/workflows/matchers/pytest.json" - - name: Install dependencies - run: pip install nox pytest-github-actions-annotate-failures - name: Test with nox using minimal dependencies - run: nox -e "pytest-${{ matrix.python-version }}(all_deps=False)" + run: uv run --group nox nox -e "pytest-${{ matrix.python-version }}(all_deps=False)" - name: Test with nox with all dependencies - run: nox -e "pytest-${{ matrix.python-version }}(all_deps=True)" + run: uv run --group nox nox -e "pytest-${{ matrix.python-version }}(all_deps=True)" diff --git a/README.md b/README.md index c7b2fcad6..dcfd4ff8f 100644 --- a/README.md +++ b/README.md @@ -160,12 +160,12 @@ jupyter labextension install @pyviz/jupyterlab_pyviz ## :wrench: Development -Clone the repository and run `pip install -e ".[notebook,testing,other]"` to add a link to the cloned repo into your Python path: +Clone the repository and run `pip install -e ".[notebook,test,other]"` to add a link to the cloned repo into your Python path: ```bash git clone git@github.com:python-adaptive/adaptive.git cd adaptive -pip install -e ".[notebook,testing,other]" +pip install -e ".[notebook,test,other]" ``` We recommend using a Conda environment or a virtualenv for package management during Adaptive development. diff --git a/noxfile.py b/noxfile.py index c08e010ba..c7cd966f7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -9,7 +9,7 @@ @nox.parametrize("all_deps", [True, False]) def pytest(session: nox.Session, all_deps: bool) -> None: """Run pytest with optional dependencies.""" - session.install(".[testing,other]" if all_deps else ".[testing]") + session.install(".[test,other]" if all_deps else ".[test]") session.run("coverage", "erase") session.run("pytest") @@ -17,7 +17,7 @@ def pytest(session: nox.Session, all_deps: bool) -> None: @nox.session(python="3.11") def pytest_typeguard(session: nox.Session) -> None: """Run pytest with typeguard.""" - session.install(".[testing,other]") + session.install(".[test,other]") session.run("coverage", "erase") session.run("pytest", "--typeguard-packages=adaptive") @@ -26,7 +26,7 @@ def pytest_typeguard(session: nox.Session) -> None: def coverage(session: nox.Session) -> None: """Generate coverage report.""" session.install("coverage") - session.install(".[testing,other]") + session.install(".[test,other]") session.run("pytest") session.run("coverage", "report") diff --git a/pyproject.toml b/pyproject.toml index 8dbe2c89a..52cff0a8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ notebook = [ "matplotlib", "plotly", ] -testing = [ +test = [ "flaky", "pytest", "pytest-cov", @@ -56,6 +56,7 @@ testing = [ "pre_commit", "typeguard", ] +dev = ["adaptive[test,nox,notebook,other]"] [project.urls] homepage = "https://adaptive.readthedocs.io/" @@ -66,6 +67,12 @@ repository = "https://github.com/python-adaptive/adaptive" content-type = "text/markdown" file = "README.md" +[dependency-groups] +nox = [ + "nox", + "pytest-github-actions-annotate-failures", +] + [tool.setuptools.packages.find] include = ["adaptive.*", "adaptive"] From 8d0638b8045e88242088678dcf6378123adb92ef Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 10:59:28 +0200 Subject: [PATCH 03/11] simplify setup --- .github/workflows/nox.yml | 4 ++-- noxfile.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/nox.yml b/.github/workflows/nox.yml index b2cc51c7c..0e25e3b5d 100644 --- a/.github/workflows/nox.yml +++ b/.github/workflows/nox.yml @@ -25,6 +25,6 @@ jobs: - name: Register Python problem matcher run: echo "::add-matcher::.github/workflows/matchers/pytest.json" - name: Test with nox using minimal dependencies - run: uv run --group nox nox -e "pytest-${{ matrix.python-version }}(all_deps=False)" + run: uv run --group nox nox -e "pytest_min_deps-${{ matrix.python-version }}" - name: Test with nox with all dependencies - run: uv run --group nox nox -e "pytest-${{ matrix.python-version }}(all_deps=True)" + run: uv run --group nox nox -e "pytest_all_deps-${{ matrix.python-version }}" diff --git a/noxfile.py b/noxfile.py index c7cd966f7..741a57f21 100644 --- a/noxfile.py +++ b/noxfile.py @@ -4,12 +4,21 @@ nox.options.default_venv_backend = "uv" +python = ["3.9", "3.10", "3.11", "3.12"] -@nox.session(python=["3.9", "3.10", "3.11", "3.12"]) -@nox.parametrize("all_deps", [True, False]) -def pytest(session: nox.Session, all_deps: bool) -> None: - """Run pytest with optional dependencies.""" - session.install(".[test,other]" if all_deps else ".[test]") + +@nox.session(python=python) +def pytest_min_deps(session: nox.Session) -> None: + """Run pytest with no optional dependencies.""" + session.install(".[test]") + session.run("coverage", "erase") + session.run("pytest") + + +@nox.session(python=python) +def pytest_all_deps(session: nox.Session) -> None: + """Run pytest with "other" optional dependencies.""" + session.install(".[test,other]") session.run("coverage", "erase") session.run("pytest") From 7003ff0784aacca09728ae01e272b5d76c14dbbb Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 11:01:20 +0200 Subject: [PATCH 04/11] Remove .github/workflows/matchers/pytest.json --- .github/workflows/matchers/pytest.json | 18 ------------------ .github/workflows/nox.yml | 2 -- 2 files changed, 20 deletions(-) delete mode 100644 .github/workflows/matchers/pytest.json diff --git a/.github/workflows/matchers/pytest.json b/.github/workflows/matchers/pytest.json deleted file mode 100644 index 3e5d8d5b8..000000000 --- a/.github/workflows/matchers/pytest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "problemMatcher": [ - { - "owner": "python", - "pattern": [ - { - "regexp": "^\\s*File\\s\\\"(.*)\\\",\\sline\\s(\\d+),\\sin\\s(.*)$", - "file": 1, - "line": 2 - }, - { - "regexp": "^\\s*raise\\s(.*)\\(\\'(.*)\\'\\)$", - "message": 2 - } - ] - } - ] -} diff --git a/.github/workflows/nox.yml b/.github/workflows/nox.yml index 0e25e3b5d..3a52e846d 100644 --- a/.github/workflows/nox.yml +++ b/.github/workflows/nox.yml @@ -22,8 +22,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install uv uses: astral-sh/setup-uv@v6 - - name: Register Python problem matcher - run: echo "::add-matcher::.github/workflows/matchers/pytest.json" - name: Test with nox using minimal dependencies run: uv run --group nox nox -e "pytest_min_deps-${{ matrix.python-version }}" - name: Test with nox with all dependencies From b629394a695a66d9ee1c0c1d5c78f28da3f1637e Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 11:02:45 +0200 Subject: [PATCH 05/11] add coverage as dep --- noxfile.py | 1 - pyproject.toml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 741a57f21..89ed01733 100644 --- a/noxfile.py +++ b/noxfile.py @@ -34,7 +34,6 @@ def pytest_typeguard(session: nox.Session) -> None: @nox.session(python="3.11") def coverage(session: nox.Session) -> None: """Generate coverage report.""" - session.install("coverage") session.install(".[test,other]") session.run("pytest") diff --git a/pyproject.toml b/pyproject.toml index 52cff0a8b..cdccac22a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,7 @@ test = [ "pytest-timeout", "pre_commit", "typeguard", + "coverage", ] dev = ["adaptive[test,nox,notebook,other]"] From 89b4dc82ae350f28b2f4bade382e646eda5216ce Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 11:05:12 +0200 Subject: [PATCH 06/11] uv for coverage job --- .github/workflows/coverage.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ab393048a..3adce595a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,9 +12,9 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.11 - - name: Install dependencies - run: pip install nox + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Test with nox - run: nox -e coverage + run: uv run --group nox nox -e coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 From 159b04a5c77a12bfbd2475cfbbbbd29d6d4b6683 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 11:05:38 +0200 Subject: [PATCH 07/11] default to 3.13 --- .github/workflows/coverage.yml | 2 +- noxfile.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3adce595a..4c177878f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -11,7 +11,7 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: 3.13 - name: Install uv uses: astral-sh/setup-uv@v6 - name: Test with nox diff --git a/noxfile.py b/noxfile.py index 89ed01733..b4e04d97f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -23,7 +23,7 @@ def pytest_all_deps(session: nox.Session) -> None: session.run("pytest") -@nox.session(python="3.11") +@nox.session(python="3.13") def pytest_typeguard(session: nox.Session) -> None: """Run pytest with typeguard.""" session.install(".[test,other]") @@ -31,7 +31,7 @@ def pytest_typeguard(session: nox.Session) -> None: session.run("pytest", "--typeguard-packages=adaptive") -@nox.session(python="3.11") +@nox.session(python="3.13") def coverage(session: nox.Session) -> None: """Generate coverage report.""" session.install(".[test,other]") From 1903f0596d2ba3ff196c6a933c32d47a9ca83f59 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 11:05:51 +0200 Subject: [PATCH 08/11] . --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index b4e04d97f..a5e8ecef7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -4,7 +4,7 @@ nox.options.default_venv_backend = "uv" -python = ["3.9", "3.10", "3.11", "3.12"] +python = ["3.9", "3.10", "3.11", "3.12", "3.13"] @nox.session(python=python) From 81c83f406cb97d35c1ff6b6ea8942c6ce33b6cad Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 11:06:26 +0200 Subject: [PATCH 09/11] typeguard --- .github/workflows/typeguard.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/typeguard.yml b/.github/workflows/typeguard.yml index a95ac4f2f..3689442b3 100644 --- a/.github/workflows/typeguard.yml +++ b/.github/workflows/typeguard.yml @@ -12,8 +12,8 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: "3.11" - - name: Install dependencies - run: pip install nox + python-version: "3.13" + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Test with nox - run: nox -e pytest_typeguard + run: uv run --group nox nox -e pytest_typeguard From 4a35173e0416496737d7257f0ed8c9c1dde07345 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 11:12:42 +0200 Subject: [PATCH 10/11] run pytest with xdist if n_cpus > 2 --- noxfile.py | 12 ++++++++---- pyproject.toml | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/noxfile.py b/noxfile.py index a5e8ecef7..6a6114bb3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,10 +1,14 @@ """Nox configuration file.""" +import os + import nox nox.options.default_venv_backend = "uv" python = ["3.9", "3.10", "3.11", "3.12", "3.13"] +num_cpus = os.cpu_count() or 1 +xdist = ("-n", "auto") if num_cpus > 2 else () @nox.session(python=python) @@ -12,7 +16,7 @@ def pytest_min_deps(session: nox.Session) -> None: """Run pytest with no optional dependencies.""" session.install(".[test]") session.run("coverage", "erase") - session.run("pytest") + session.run("pytest", *xdist) @nox.session(python=python) @@ -20,7 +24,7 @@ def pytest_all_deps(session: nox.Session) -> None: """Run pytest with "other" optional dependencies.""" session.install(".[test,other]") session.run("coverage", "erase") - session.run("pytest") + session.run("pytest", *xdist) @nox.session(python="3.13") @@ -28,14 +32,14 @@ def pytest_typeguard(session: nox.Session) -> None: """Run pytest with typeguard.""" session.install(".[test,other]") session.run("coverage", "erase") - session.run("pytest", "--typeguard-packages=adaptive") + session.run("pytest", "--typeguard-packages=adaptive", *xdist) @nox.session(python="3.13") def coverage(session: nox.Session) -> None: """Generate coverage report.""" session.install(".[test,other]") - session.run("pytest") + session.run("pytest", *xdist) session.run("coverage", "report") session.run("coverage", "xml") diff --git a/pyproject.toml b/pyproject.toml index cdccac22a..5e59cad3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,7 @@ test = [ "pytest-cov", "pytest-randomly", "pytest-timeout", + "pytest-xdist", "pre_commit", "typeguard", "coverage", From bb4cde519c6a551fb899ea98776bc37f95d6fbcc Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 May 2025 11:16:01 +0200 Subject: [PATCH 11/11] test 3.13 --- .github/workflows/nox.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nox.yml b/.github/workflows/nox.yml index 3a52e846d..f021d3b2c 100644 --- a/.github/workflows/nox.yml +++ b/.github/workflows/nox.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: platform: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4