From a2bfbae67855012f3f4c45e999d9fe2ac92bfa99 Mon Sep 17 00:00:00 2001 From: Dan F-M Date: Sun, 11 May 2025 05:57:07 -0400 Subject: [PATCH] Use uv for CI. --- .github/workflows/news.yml | 23 ------ .github/workflows/tests.yml | 72 ++++++++++--------- .gitignore | 1 + CONTRIBUTING.md | 3 +- docs/install.md | 3 +- noxfile.py | 34 --------- pyproject.toml | 7 +- .../test_solvers/test_quasisep/test_solver.py | 2 +- 8 files changed, 48 insertions(+), 97 deletions(-) delete mode 100644 .github/workflows/news.yml delete mode 100644 noxfile.py diff --git a/.github/workflows/news.yml b/.github/workflows/news.yml deleted file mode 100644 index e986d6be..00000000 --- a/.github/workflows/news.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: News - -on: - pull_request: - -jobs: - news: - if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'pre-commit-ci[bot]' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install -U pip - python -m pip install towncrier - - name: Check for news - run: python -m towncrier check --compare-with origin/main diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d2bfbe57..9b6cd71a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,39 +13,53 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11"] - nox-session: ["test"] - x64: ["1"] + python-version: ["3.10"] + x64: ["0"] include: - - python-version: "3.10" - nox-session: "test" - x64: "0" - - python-version: "3.10" - nox-session: "comparison" + - python-version: "3.13" x64: "1" - - python-version: "3.10" - nox-session: "doctest" - x64: "1" - steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup Python - uses: actions/setup-python@v5 + - name: Set up uv + uses: astral-sh/setup-uv@v6 + - name: Run tests + run: | + uv run --extra test --python ${{ matrix.python-version }} pytest -n auto tests + env: + JAX_ENABLE_X64: ${{ matrix.x64 }} + + comparison: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies + fetch-depth: 0 + - name: Set up uv + uses: astral-sh/setup-uv@v6 + - name: Run tests run: | - python -m pip install -U pip - python -m pip install nox + uv run --extra test --extra comparison --python 3.12 pytest -n auto tests + env: + JAX_ENABLE_X64: "1" + + doctest: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up uv + uses: astral-sh/setup-uv@v6 - name: Run tests run: | - python -m nox --non-interactive --error-on-missing-interpreter \ - --session ${{ matrix.nox-session }} --python ${{ matrix.python-version }} + uv run --extra test --extra doctest --python 3.12 pytest --doctest-modules -v src/tinygp env: - JAX_ENABLE_X64: ${{ matrix.x64 }} + JAX_ENABLE_X64: "1" build: runs-on: ubuntu-latest @@ -53,18 +67,12 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install -U pip - python -m pip install -U build twine + - name: Set up uv + uses: astral-sh/setup-uv@v6 - name: Build the distribution - run: python -m build . + run: uv build - name: Check the distribution - run: python -m twine check --strict dist/* + run: uv run --with twine python -m twine check --strict dist/* - uses: actions/upload-artifact@v4 with: path: dist/* @@ -75,7 +83,7 @@ jobs: url: https://pypi.org/p/tinygp permissions: id-token: write - needs: [tests, build] + needs: [tests, comparison, doctest, build] runs-on: ubuntu-latest if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') steps: diff --git a/.gitignore b/.gitignore index 534364a9..9a207ab2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ docs/api/summary __pycache__ *.egg-info +uv.lock diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9163ac74..b97c86a2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,8 +34,7 @@ Tracker](https://github.com/dfm/tinygp/issues). ## How to test the project ```bash -python -m pip install nox -python -m nox -s test -p 3.10 +uv run --extra test pytest ``` ## How to submit changes diff --git a/docs/install.md b/docs/install.md index 50465cc0..7eb8b252 100644 --- a/docs/install.md +++ b/docs/install.md @@ -34,6 +34,5 @@ If you installed from source, you can run the unit tests. From the root of the source directory, run: ```bash -python -m pip install nox -python -m nox -s test -p 3.10 +uv run --extra test pytest ``` diff --git a/noxfile.py b/noxfile.py deleted file mode 100644 index 888519ad..00000000 --- a/noxfile.py +++ /dev/null @@ -1,34 +0,0 @@ -import platform -from pathlib import Path - -import nox - -PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12"] - - -@nox.session(python=PYTHON_VERSIONS) -def test(session: nox.Session) -> None: - session.install(".[test]") - session.run("pytest", *session.posargs) - - -@nox.session(python=PYTHON_VERSIONS) -def comparison(session: nox.Session) -> None: - session.install(".[test,comparison]") - session.run("pytest", *session.posargs, env={"JAX_ENABLE_X64": "1"}) - - -@nox.session(python=PYTHON_VERSIONS) -def doctest(session: nox.Session) -> None: - if platform.system() == "Windows": - module = Path(session.virtualenv.location) / "Lib" / "site-packages" / "tinygp" - else: - module = ( - Path(session.virtualenv.location) - / "lib" - / f"python{session.python}" - / "site-packages" - / "tinygp" - ) - session.install(".[test]", "numpyro") - session.run("pytest", "--doctest-modules", "-v", str(module), *session.posargs) diff --git a/pyproject.toml b/pyproject.toml index 8a449383..f612ca1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "tinygp" description = "The tiniest of Gaussian Process libraries" authors = [{ name = "Dan Foreman-Mackey", email = "foreman.mackey@gmail.com" }] readme = "README.md" -requires-python = ">=3.9" +requires-python = ">=3.10" license = { text = "MIT" } classifiers = [ "Development Status :: 4 - Beta", @@ -15,11 +15,12 @@ classifiers = [ "Programming Language :: Python :: 3", ] dynamic = ["version"] -dependencies = ["jax", "jaxlib", "equinox"] +dependencies = ["jax", "equinox"] [project.optional-dependencies] -test = ["pytest"] +test = ["pytest", "pytest-xdist"] comparison = ["george", "celerite"] +doctest = ["numpyro"] docs = [ "sphinx-book-theme", "myst-nb", diff --git a/tests/test_solvers/test_quasisep/test_solver.py b/tests/test_solvers/test_quasisep/test_solver.py index ebdf8e0c..5fcb64f1 100644 --- a/tests/test_solvers/test_quasisep/test_solver.py +++ b/tests/test_solvers/test_quasisep/test_solver.py @@ -130,6 +130,6 @@ def test_unsorted(data): def impl(X, y): return GaussianProcess(kernel, X, diag=0.1).log_probability(y) - with pytest.raises(jax.lib.xla_extension.XlaRuntimeError) as exc_info: + with pytest.raises(jax.errors.JaxRuntimeError) as exc_info: impl(x_, y_).block_until_ready() assert exc_info.match(r"Input coordinates must be sorted")