From ed1efe030d3e22afb4960128cbb740ff83583123 Mon Sep 17 00:00:00 2001 From: "Michael J. Williams" Date: Tue, 27 Oct 2026 09:47:25 +0100 Subject: [PATCH 1/2] CI: improve lint, distribution, and compatibility checks --- .github/workflows/lint.yml | 17 +++++---- .github/workflows/publish.yml | 40 ++++++++++---------- .github/workflows/tests.yml | 69 ++++++++++++++++++++++++++--------- CONTRIBUTING.md | 6 ++- 4 files changed, 86 insertions(+), 46 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7862bd3..099dc65 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,6 +5,10 @@ on: branches: [ main, release* ] pull_request: branches: [ main, release* ] + workflow_dispatch: + +permissions: + contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -15,6 +19,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 + - uses: astral-sh/ruff-action@v4.0.0 + with: + version: "0.14.x" + args: 'check .' - uses: astral-sh/ruff-action@v4.0.0 with: version: "0.14.x" @@ -27,16 +35,9 @@ jobs: with: python-version: "3.11" cache: "pip" - - name: Checkout sequince-dev/sequince - uses: actions/checkout@v7 - with: - repository: sequince-dev/sequince - ssh-key: ${{ secrets.SEQUINCE_DEPLOY_KEY }} - path: sequince - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install ./sequince - python -m pip install . "mypy>=1.10" + python -m pip install . "sequince==0.1.0b1" "mypy>=1.10" - name: Type check run: mypy diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c349644..f3528fe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,30 +3,30 @@ on: release: types: [published] +permissions: + contents: read + jobs: build: - name: Build distribution runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: "3.x" - - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: python3 -m build - - name: Store the distribution packages - uses: actions/upload-artifact@v7 - with: - name: python-package-distributions - path: dist/ + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - uses: actions/setup-python@v6 + with: + python-version: "3.11" + - name: Install build and metadata validation tools + run: python -m pip install build twine + - name: Build source distribution and wheel + run: python -m build + - name: Validate distribution metadata + run: python -m twine check --strict dist/* + - uses: actions/upload-artifact@v7 + with: + name: python-package-distributions + path: dist/ + if-no-files-found: error pypi-publish: name: Upload release to PyPI diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 133d277..b26a8c8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,44 +5,79 @@ on: branches: [ main, release* ] pull_request: branches: [ main, release* ] + workflow_dispatch: + +permissions: + contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - uses: actions/setup-python@v6 + with: + python-version: "3.11" + - name: Install build and metadata validation tools + run: python -m pip install build twine + - name: Build source distribution and wheel + run: python -m build + - name: Validate distribution metadata + run: python -m twine check --strict dist/* + - uses: actions/upload-artifact@v7 + with: + name: python-package-distributions + path: dist/ + if-no-files-found: error + tests: - name: Python ${{ matrix.python-version }} (${{ matrix.os }}) + name: Python ${{ matrix.python-version }} (Sequince ${{ matrix.sequince }}) + needs: build strategy: fail-fast: false matrix: - os: [Ubuntu] python-version: ["3.11", "3.12", "3.13"] - runs-on: ${{ matrix.os }}-latest + sequince: ["0.1.0b1"] + include: + - python-version: "3.13" + sequince: main + runs-on: ubuntu-latest + env: + JAX_PLATFORMS: cpu steps: - - name: Checkout repository and submodules + - name: Checkout tests and dependency groups uses: actions/checkout@v7 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - - name: Checkout sequince-dev/sequince - uses: actions/checkout@v7 + - name: Download distributions + uses: actions/download-artifact@v8 with: - repository: sequince-dev/sequince - ssh-key: ${{ secrets.SEQUINCE_DEPLOY_KEY }} - path: sequince + name: python-package-distributions + path: dist/ - name: Install dependencies + env: + SEQUINCE_VERSION: ${{ matrix.sequince }} run: | python -m pip install --upgrade pip - # Install pytorch CPU version for testing - pip install torch --index-url https://download.pytorch.org/whl/cpu - # Install backends for orng - # Can't use cupy since it requires CUDA toolkit to be installed - pip install ./sequince - pip install -e . --group test + python -m pip install torch --index-url https://download.pytorch.org/whl/cpu + if [ "$SEQUINCE_VERSION" = main ]; then + python -m pip install "sequince @ git+https://github.com/sequince-dev/sequince.git@main" + else + python -m pip install "sequince==$SEQUINCE_VERSION" + fi + python -m pip install dist/*.whl --group test + python -m pip check + - name: Verify backend imports + run: python -c "import sklearn, torch, zuko, jax, flowjax, equinox" - name: Test with pytest - run: | - python -m pytest tests/ + run: python -m pytest tests/ -ra diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c8715f0..fc0aae3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -76,7 +76,11 @@ and tool configuration are defined in `pyproject.toml`. When developing against a local Sequince checkout, install it first, for example with `python -m pip install -e ../sequince`, before installing sequince-density. -CI also installs Sequince from a checkout before running the tests. +CI tests the built wheel against Sequince 0.1.0b1 on Python 3.11–3.13, with +an additional Python 3.13 compatibility run against Sequince's `main` branch. +All density backends are installed and checked for import errors before pytest +runs. Both test and release workflows build a source distribution and wheel, +then validate their metadata with `twine check --strict`. Use Pixi for the documentation environment, as described below. Generated lock files and local environments should stay out of pull requests. From d5f1aef7eadde1203d67fd9b35012ed0edff8f71 Mon Sep 17 00:00:00 2001 From: "Michael J. Williams" Date: Tue, 27 Oct 2026 09:52:34 +0100 Subject: [PATCH 2/2] BUG(typing): allow flow backends to define array namespaces --- src/sequince_density/flows/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sequince_density/flows/base.py b/src/sequince_density/flows/base.py index 31a9fc8..bdc4e2d 100644 --- a/src/sequince_density/flows/base.py +++ b/src/sequince_density/flows/base.py @@ -3,6 +3,7 @@ from __future__ import annotations import inspect +from types import ModuleType from typing import Any from sequince.transforms import IdentityTransform, ParticleTransform @@ -15,7 +16,7 @@ class Flow: while remaining compatible with ``sequince.transforms.FlowTransform``. """ - xp = None + xp: ModuleType | None = None def __init__( self,