From c708c3cb4e5770199df0fc9a6579a3cdf9dea2b7 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sun, 2 Nov 2025 16:20:34 +0300 Subject: [PATCH 01/15] Revamp CI - drop python-3.8 - use `uv` - split lint and test --- .github/workflows/code-style.yaml | 35 ++++++++++++++++ .github/workflows/quality-checks.yaml | 15 ++++--- Makefile | 44 +++++++++++--------- pyproject.toml | 60 ++++++++++++++++++++++++++- 4 files changed, 126 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/code-style.yaml diff --git a/.github/workflows/code-style.yaml b/.github/workflows/code-style.yaml new file mode 100644 index 00000000..44d485e7 --- /dev/null +++ b/.github/workflows/code-style.yaml @@ -0,0 +1,35 @@ +name: QualityChecks + +on: + push: + pull_request: + branches: + - main + +jobs: + check-and-test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + + name: Python-3.11 + steps: + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + version: "0.9.6" + #---------------------------------------------- + # install + #---------------------------------------------- + - name: Install dependencies + run: UV_PYTHON=python3.11 make sync + #---------------------------------------------- + # lint + #---------------------------------------------- + - name: Run lint + run: make lint diff --git a/.github/workflows/quality-checks.yaml b/.github/workflows/quality-checks.yaml index f1cbb02e..3c9eef64 100644 --- a/.github/workflows/quality-checks.yaml +++ b/.github/workflows/quality-checks.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11"] fail-fast: false name: Python-${{ matrix.python-version }} @@ -20,18 +20,21 @@ jobs: # check-out repo and set-up python #---------------------------------------------- - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + version: "0.9.6" + with: python-version: ${{ matrix.python-version }} #---------------------------------------------- # install #---------------------------------------------- - name: Install dependencies - run: GK_REQUIREMENTS=test_requirements-${{ matrix.python-version }}.txt make install + run: UV_PYTHON=python${{ matrix.python-version }} make sync #---------------------------------------------- - # Lint and test + # test #---------------------------------------------- - - name: Run lint - run: make lint - name: Run tests run: make test diff --git a/Makefile b/Makefile index 9181219c..5d2ee2e3 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ SUCCESS='\033[0;32m' SHELL=/bin/bash -PYVERSION:=$(shell python -c "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)") -GK_REQUIREMENTS?=test_requirements-$(PYVERSION).txt +UV ?= uv +VENV_DIR ?= .venv help: ## Shows this help message # $(MAKEFILE_LIST) is set by make itself; the following parses the `target: ## help line` format and adds color highlighting @@ -14,25 +14,29 @@ docs: (cd docs ; make clean; make doctest; make html) @echo "${SUCCESS}============== Docs are available at docs/_build/html/index.html ============== ${SUCCESS}" +venv: ## Create a virtualenv (UV_PYTHON=python3.10 to force) + @$(UV) venv --seed --python "$${UV_PYTHON:-system}" $(VENV_DIR) + @echo $(SUCCESS) "Virtualenv ready in $(VENV_DIR)" -install: ## Install repo for developement (Only for Linux) - @echo "=== pip install package with dev requirements (using $(GK_REQUIREMENTS)) ==============" - pip install --upgrade pip - pip install --upgrade --upgrade-strategy eager --no-cache-dir -r $(GK_REQUIREMENTS) | cat - pip install -e . +sync: venv ## Resolve + install project and dev deps for development + @$(UV) sync --dev + @echo $(SUCCESS) "Environment synced from pyproject.toml" -format: ## Formats code with `autoflake`, `black` and `isort` - autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place geometric_kernels tests --exclude=__init__.py - black geometric_kernels tests - isort geometric_kernels tests - -lint: - flake8 geometric_kernels tests - black geometric_kernels tests --check --diff - isort geometric_kernels tests --check-only --diff - mypy --namespace-packages geometric_kernels +install: sync ## Backward-compat -test: ## Run the tests, start with the failing ones and break on first fail. - pytest -v -x --ff -rN -Wignore -s --tb=short --durations=0 --cov --cov-report=xml tests - pytest --nbmake --nbmake-kernel=python3 --durations=0 --nbmake-timeout=1000 --ignore=notebooks/frontends/GPJax.ipynb notebooks/ +format: ## Formats code with `autoflake`, `black` and `isort` + @$(UV) sync --no-dev + @$(UV)x autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place geometric_kernels tests --exclude=__init__.py + @$(UV)x black@24.3.0 geometric_kernels tests + @$(UV)x isort@5.13.2 geometric_kernels tests + +lint: sync + @$(UV)x flake8@7.0.0 geometric_kernels tests + @$(UV)x black@24.3.0 geometric_kernels tests --check --diff + @$(UV)x isort@5.13.2 geometric_kernels tests --check-only --diff + @$(UV) run mypy --namespace-packages geometric_kernels + +test: sync ## Run the tests, start with the failing ones and break on first fail. + @$(UV) run pytest -v -x --ff -rN -Wignore -s --tb=short --durations=0 --cov --cov-report=xml tests + @$(UV) run pytest --nbmake --nbmake-kernel=python3 --durations=0 --nbmake-timeout=1000 --ignore=notebooks/frontends/GPJax.ipynb notebooks/ diff --git a/pyproject.toml b/pyproject.toml index 67176dcc..e76f82a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,9 +21,9 @@ classifiers = [ keywords=[ "geometric-kernels", ] -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = [ - "backends>=1.7", + "backends", # >=1.7", "einops", "geomstats", "numpy>=1.16", @@ -59,3 +59,59 @@ allow_redefinition = true [tool.black] line-length = 88 target-version = ['py38', 'py39', 'py310', 'py311'] + + +[tool.uv] +default-groups = [] + +[dependency-groups] +dev = [ + # --- shared from test_requirements.txt --- + "ipykernel", + "backends>=1.5.4", + "plotly", + "kaleido", + "black==24.3.0", + "flake8==7.0.0", + "isort==5.13.2", + "autoflake", + "pytest", + "pytest-cov", + "nbmake", + "mypy", + "scikit-learn", + "geoopt", + + # scipy + 'scipy==1.10.1; python_version == "3.8"', + 'scipy==1.12.0; python_version >= "3.9" and python_version < "3.12"', + + # typing-extensions only required on newer pins in 3.10/3.11 files + 'typing_extensions>=4.6; python_version >= "3.10" and python_version < "3.12"', + + # Torch + "torch==2.1.2", + # gpytorch + 'gpytorch; python_version < "3.10"', + 'gpytorch==1.11; python_version >= "3.10" and python_version < "3.12"', + "botorch>=0.9", + + # TensorFlow / GPflow / TFP split + 'tensorflow==2.13.0; python_version=="3.8"', + 'tensorflow==2.13.1; python_version=="3.9"', + 'tensorflow==2.15; python_version>="3.10" and python_version<"3.12"', + 'tensorflow-probability==0.20.1; python_version < "3.10"', + 'tensorflow-probability==0.23; python_version >= "3.10" and python_version < "3.12"', + 'gpflow==2.9.0; python_version < "3.10"', + 'gpflow==2.9; python_version >= "3.10" and python_version < "3.12"', + + # JAX family + 'jax==0.4.13; python_version < "3.10"', + 'jaxlib==0.4.13; python_version < "3.10"', + 'jax==0.4.23; python_version >= "3.10" and python_version < "3.12"', + 'jaxlib==0.4.23; python_version >= "3.10" and python_version < "3.12"', + 'jaxtyping==0.2.25; python_version == "3.9"', + 'jaxtyping; python_version != "3.9"', + 'optax==0.1.7; python_version == "3.8"', + 'optax; python_version >= "3.9"', +] \ No newline at end of file From 16e1376fd78415b5dd8f81a54ac940b632e5171f Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sun, 2 Nov 2025 16:24:08 +0300 Subject: [PATCH 02/15] Fix --- .github/workflows/code-style.yaml | 2 +- .github/workflows/quality-checks.yaml | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/code-style.yaml b/.github/workflows/code-style.yaml index 44d485e7..67a13883 100644 --- a/.github/workflows/code-style.yaml +++ b/.github/workflows/code-style.yaml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false - name: Python-3.11 + name: Code style steps: #---------------------------------------------- # check-out repo and set-up python diff --git a/.github/workflows/quality-checks.yaml b/.github/workflows/quality-checks.yaml index 3c9eef64..518aeb53 100644 --- a/.github/workflows/quality-checks.yaml +++ b/.github/workflows/quality-checks.yaml @@ -25,9 +25,6 @@ jobs: uses: astral-sh/setup-uv@v6 with: version: "0.9.6" - - with: - python-version: ${{ matrix.python-version }} #---------------------------------------------- # install #---------------------------------------------- From 0b36f0a632b5ca8d735a2067bd3439fe905d2cf2 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sun, 2 Nov 2025 16:26:47 +0300 Subject: [PATCH 03/15] Fixes --- .github/workflows/code-style.yaml | 4 ++-- .github/workflows/quality-checks.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-style.yaml b/.github/workflows/code-style.yaml index 67a13883..2ef049e4 100644 --- a/.github/workflows/code-style.yaml +++ b/.github/workflows/code-style.yaml @@ -1,4 +1,4 @@ -name: QualityChecks +name: CodeStyle on: push: @@ -32,4 +32,4 @@ jobs: # lint #---------------------------------------------- - name: Run lint - run: make lint + run: UV_PYTHON=python3.11 make lint diff --git a/.github/workflows/quality-checks.yaml b/.github/workflows/quality-checks.yaml index 518aeb53..b82577bf 100644 --- a/.github/workflows/quality-checks.yaml +++ b/.github/workflows/quality-checks.yaml @@ -34,4 +34,4 @@ jobs: # test #---------------------------------------------- - name: Run tests - run: make test + run: UV_PYTHON=python${{ matrix.python-version }} make test From cd1055b06c1a106597426a9fbc1e8ddfa237e2c3 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sun, 2 Nov 2025 16:35:09 +0300 Subject: [PATCH 04/15] Add clarifying echos in Makefile --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5d2ee2e3..f1408c2d 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,11 @@ docs: venv: ## Create a virtualenv (UV_PYTHON=python3.10 to force) @$(UV) venv --seed --python "$${UV_PYTHON:-system}" $(VENV_DIR) - @echo $(SUCCESS) "Virtualenv ready in $(VENV_DIR)" + @echo "$(SUCCESS) Virtualenv ready in $(VENV_DIR) $(SUCCESS)" sync: venv ## Resolve + install project and dev deps for development @$(UV) sync --dev - @echo $(SUCCESS) "Environment synced from pyproject.toml" + @echo "$(SUCCESS) Environment synced from pyproject.toml $(SUCCESS)" install: sync ## Backward-compat @@ -30,13 +30,16 @@ format: ## Formats code with `autoflake`, `black` and `isort` @$(UV)x autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place geometric_kernels tests --exclude=__init__.py @$(UV)x black@24.3.0 geometric_kernels tests @$(UV)x isort@5.13.2 geometric_kernels tests + @echo "$(SUCCESS) Format done $(SUCCESS)" lint: sync @$(UV)x flake8@7.0.0 geometric_kernels tests @$(UV)x black@24.3.0 geometric_kernels tests --check --diff @$(UV)x isort@5.13.2 geometric_kernels tests --check-only --diff @$(UV) run mypy --namespace-packages geometric_kernels + @echo "$(SUCCESS) Lint done $(SUCCESS)" test: sync ## Run the tests, start with the failing ones and break on first fail. @$(UV) run pytest -v -x --ff -rN -Wignore -s --tb=short --durations=0 --cov --cov-report=xml tests @$(UV) run pytest --nbmake --nbmake-kernel=python3 --durations=0 --nbmake-timeout=1000 --ignore=notebooks/frontends/GPJax.ipynb notebooks/ + @echo "$(SUCCESS) Tests done $(SUCCESS)" From a42af24f9c888f17a8a453660ae4fb41b7a9fc96 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sun, 2 Nov 2025 16:39:06 +0300 Subject: [PATCH 05/15] Loosen dev versions --- pyproject.toml | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e76f82a1..52e2365d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,19 +81,16 @@ dev = [ "mypy", "scikit-learn", "geoopt", - - # scipy - 'scipy==1.10.1; python_version == "3.8"', - 'scipy==1.12.0; python_version >= "3.9" and python_version < "3.12"', + 'scipy', # typing-extensions only required on newer pins in 3.10/3.11 files 'typing_extensions>=4.6; python_version >= "3.10" and python_version < "3.12"', # Torch - "torch==2.1.2", + "torch", + # gpytorch - 'gpytorch; python_version < "3.10"', - 'gpytorch==1.11; python_version >= "3.10" and python_version < "3.12"', + 'gpytorch', "botorch>=0.9", # TensorFlow / GPflow / TFP split @@ -106,12 +103,9 @@ dev = [ 'gpflow==2.9; python_version >= "3.10" and python_version < "3.12"', # JAX family - 'jax==0.4.13; python_version < "3.10"', - 'jaxlib==0.4.13; python_version < "3.10"', - 'jax==0.4.23; python_version >= "3.10" and python_version < "3.12"', - 'jaxlib==0.4.23; python_version >= "3.10" and python_version < "3.12"', + 'jax', + 'jaxlib', 'jaxtyping==0.2.25; python_version == "3.9"', 'jaxtyping; python_version != "3.9"', - 'optax==0.1.7; python_version == "3.8"', - 'optax; python_version >= "3.9"', + 'optax', ] \ No newline at end of file From 3b8b916b451760d819b4fbd8ee580c42ce6b2b07 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sun, 2 Nov 2025 16:42:28 +0300 Subject: [PATCH 06/15] Update `trapz` extra --- geometric_kernels/lab_extras/jax/extras.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometric_kernels/lab_extras/jax/extras.py b/geometric_kernels/lab_extras/jax/extras.py index 5743ef3e..974fae99 100644 --- a/geometric_kernels/lab_extras/jax/extras.py +++ b/geometric_kernels/lab_extras/jax/extras.py @@ -30,7 +30,7 @@ def trapz(y: B.JAXNumeric, x: _Numeric, dx: _Numeric = 1.0, axis: int = -1): # """ Integrate along the given axis using the trapezoidal rule. """ - return jnp.trapz(y, x, dx, axis) + return jnp.trapezoid(y, x, dx, axis) @dispatch From d90877212f342c4b330bdac78fab79e49cbd3760 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sun, 2 Nov 2025 17:05:02 +0300 Subject: [PATCH 07/15] Fix `create_random_state` in tests/helper.py In the sparse case, this fails because rank-2 array is expected --- tests/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/helper.py b/tests/helper.py index f0f67af5..96681d5a 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -139,7 +139,7 @@ def np_to_backend(value: B.NPNumeric, backend: str): def create_random_state(backend: str, seed: int = 0): - dtype = B.dtype(np_to_backend(np.array([1.0]), backend)) + dtype = B.dtype(np_to_backend(np.array([[1.0]]), backend)) return B.create_random_state(dtype, seed=seed) From 4cdd93dac587f2c944b0c6a0f46c566e5c7776e3 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sun, 2 Nov 2025 20:24:55 +0300 Subject: [PATCH 08/15] Update README and remove old test-requirents files --- Makefile | 29 +++++++++++++++-------------- README.md | 32 ++++++++++++++++++++++++++------ test_requirements-3.10.txt | 26 -------------------------- test_requirements-3.11.txt | 26 -------------------------- test_requirements-3.8.txt | 25 ------------------------- test_requirements-3.9.txt | 25 ------------------------- test_requirements.txt | 21 --------------------- 7 files changed, 41 insertions(+), 143 deletions(-) delete mode 100644 test_requirements-3.10.txt delete mode 100644 test_requirements-3.11.txt delete mode 100644 test_requirements-3.8.txt delete mode 100644 test_requirements-3.9.txt delete mode 100644 test_requirements.txt diff --git a/Makefile b/Makefile index f1408c2d..6cf95c84 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,10 @@ SUCCESS='\033[0;32m' SHELL=/bin/bash -UV ?= uv -VENV_DIR ?= .venv +UV ?= uv +UV_RUN ?= uv run +VENV_DIR ?= .venv +UV_PYTHON ?= python3.11 help: ## Shows this help message # $(MAKEFILE_LIST) is set by make itself; the following parses the `target: ## help line` format and adds color highlighting @@ -26,20 +28,19 @@ install: sync ## Backward-compat format: ## Formats code with `autoflake`, `black` and `isort` - @$(UV) sync --no-dev - @$(UV)x autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place geometric_kernels tests --exclude=__init__.py - @$(UV)x black@24.3.0 geometric_kernels tests - @$(UV)x isort@5.13.2 geometric_kernels tests + @$(UV_RUN) autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place geometric_kernels tests --exclude=__init__.py + @$(UV_RUN) black geometric_kernels tests + @$(UV_RUN) isort geometric_kernels tests @echo "$(SUCCESS) Format done $(SUCCESS)" -lint: sync - @$(UV)x flake8@7.0.0 geometric_kernels tests - @$(UV)x black@24.3.0 geometric_kernels tests --check --diff - @$(UV)x isort@5.13.2 geometric_kernels tests --check-only --diff - @$(UV) run mypy --namespace-packages geometric_kernels +lint: + @$(UV_RUN) flake8 geometric_kernels tests + @$(UV_RUN) black geometric_kernels tests --check --diff + @$(UV_RUN) isort geometric_kernels tests --check-only --diff + @$(UV_RUN) mypy --namespace-packages geometric_kernels @echo "$(SUCCESS) Lint done $(SUCCESS)" -test: sync ## Run the tests, start with the failing ones and break on first fail. - @$(UV) run pytest -v -x --ff -rN -Wignore -s --tb=short --durations=0 --cov --cov-report=xml tests - @$(UV) run pytest --nbmake --nbmake-kernel=python3 --durations=0 --nbmake-timeout=1000 --ignore=notebooks/frontends/GPJax.ipynb notebooks/ +test: ## Run the tests, start with the failing ones and break on first fail. + @$(UV_RUN) pytest -v -x --ff -rN -Wignore -s --tb=short --durations=0 --cov --cov-report=xml tests + @$(UV_RUN) pytest --nbmake --nbmake-kernel=python3 --durations=0 --nbmake-timeout=1000 --ignore=notebooks/frontends/GPJax.ipynb notebooks/ @echo "$(SUCCESS) Tests done $(SUCCESS)" diff --git a/README.md b/README.md index 1bf16b4e..e6e693ae 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,12 @@ This enables kernel methods — in particular Gaussian process models &mdash 0. [Optionally] create and activate a new virtual environment. - You can use Conda + You can use [uv](https://github.com/astral-sh/uv) + ```bash + uv venv + ``` + + or conda ```bash conda create -n [env_name] python=3.[version] @@ -33,6 +38,8 @@ This enables kernel methods — in particular Gaussian process models &mdash pip install geometric_kernels ``` + **NOTE**: If you use `uv`, swap `pip` with `uv pip` everywhere. If you initialized a project with `uv init`, use `uv add` instead. + If you want to install specific GitHub branch called `[branch]`, run ```bash @@ -142,23 +149,36 @@ The documentation for GeometricKernels is available on a [separate website](http ## For development and running the tests -Run these commands from the root directory of the repository. +If you want to contribute to the library, thank you! Follow these instructions to set up the environment and run the tests and the code formatting. + +Initialize the virtual environment. + +```bash +make venv [UV_PYTHON=python3.11 VENV_DIR=.venv] +``` + +You can change the python version and the venv directory. The above are the defaults. -Install all backends and the dev requirements (Pytest, black, etc.) +**NOTE**: We use [uv](https://github.com/astral-sh/uv) for development. It is not strictly necessary, and if you don't want to use it, you can still run `make lint` and `make test` if you set `UV_RUN=` to be empty. You will need to set up the environment yourself. + +Install all backends and the dev requirements (Pytest, black, etc.). This will install all the backends. ```bash -make install +make install [UV_PYTHON=python3.11] ``` +**NOTE**: If not using `uv`, you can still install the dev requirements via `pip install -e .[dev]`. + Run style checks + ```bash -make lint +make lint [UV_PYTHON=python3.11] ``` Run the tests ```bash -make test +make test [UV_PYTHON=python3.11] ``` **Example:** If you want to learn how to implement your own space or kernel component, checkout the [CustomSpacesAndKernels.ipynb](https://github.com/geometric-kernels/GeometricKernels/blob/main/notebooks/CustomSpacesAndKernels.ipynb) notebook. diff --git a/test_requirements-3.10.txt b/test_requirements-3.10.txt deleted file mode 100644 index 4dc5c20e..00000000 --- a/test_requirements-3.10.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Version-independent requirements -################################## --r test_requirements.txt - -# Version-dependent requirements -################################ - -# Base -typing_extensions>=4.6 -scipy==1.12.0 - -# Torch -torch==2.1.2 -gpytorch==1.11 -botorch>=0.9 - -# TensorFlow -gpflow==2.9 -tensorflow==2.15 -tensorflow-probability==0.23 - -# JAX -jax==0.4.23 -jaxlib==0.4.23 -jaxtyping -optax diff --git a/test_requirements-3.11.txt b/test_requirements-3.11.txt deleted file mode 100644 index 4dc5c20e..00000000 --- a/test_requirements-3.11.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Version-independent requirements -################################## --r test_requirements.txt - -# Version-dependent requirements -################################ - -# Base -typing_extensions>=4.6 -scipy==1.12.0 - -# Torch -torch==2.1.2 -gpytorch==1.11 -botorch>=0.9 - -# TensorFlow -gpflow==2.9 -tensorflow==2.15 -tensorflow-probability==0.23 - -# JAX -jax==0.4.23 -jaxlib==0.4.23 -jaxtyping -optax diff --git a/test_requirements-3.8.txt b/test_requirements-3.8.txt deleted file mode 100644 index 5291e002..00000000 --- a/test_requirements-3.8.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Version-independent requirements -################################## --r test_requirements.txt - -# Version-dependent requirements -################################ - -# Base -scipy==1.10.1 - -# Torch -torch==2.1.2 -gpytorch -botorch - -# TensorFlow -gpflow==2.9.0 -tensorflow==2.13.0 -tensorflow-probability==0.20.1 - -# JAX -jax==0.4.13 -jaxlib==0.4.13 -jaxtyping -optax==0.1.7 diff --git a/test_requirements-3.9.txt b/test_requirements-3.9.txt deleted file mode 100644 index 20364d88..00000000 --- a/test_requirements-3.9.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Version-independent requirements -################################## --r test_requirements.txt - -# Version-dependent requirements -################################ - -# Base -scipy==1.12.0 - -# Torch -torch==2.1.2 -gpytorch -botorch - -# TensorFlow -gpflow==2.9.0 -tensorflow==2.13.1 -tensorflow-probability==0.20.1 - -# JAX -jax==0.4.13 -jaxlib==0.4.13 -jaxtyping==0.2.25 -optax diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index bae906e7..00000000 --- a/test_requirements.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Base -ipykernel -backends>=1.5.4 - -# Plotting -plotly -kaleido - -# Tests and style checks -black==24.3.0 -flake8==7.0.0 -isort==5.13.2 -autoflake -pytest -pytest-cov -nbmake -mypy - -# For running some tests -scikit-learn -geoopt From e4b0980c76f7e3a905ed30868aaa213c19a29ba3 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sun, 2 Nov 2025 20:30:11 +0300 Subject: [PATCH 09/15] Update the docs --- docs/index.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index 4069ae4b..6c3b769e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -16,6 +16,31 @@ This is a **Python 3** library. Before doing anything, you might want to create and activate a new virtual environment: +.. raw:: html + +
+
+
+

+ +

+
+
+ +.. code-block:: bash + + uv venv --python python[version] [venv_dir] + +where [env_dir] is the directory of the environment and [version] is the version of Python you want to use, we currently support 3.9, 3.10, 3.11. + +.. raw:: html + +
+
+
+ .. raw:: html
@@ -74,6 +99,9 @@ To install GeometricKernels, run pip install geometric_kernels +.. note:: + If you use `uv`, swap `pip` with `uv pip` everywhere. Additionally, if you ran `uv init`, use `uv add` instal, to add the requirement in your `pyproject.toml` and install it. + .. note:: If you want to install specific GitHub branch called `[branch]`, run From 68e3e53f3149b29477ce50a55087bde555ea1871 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sat, 8 Nov 2025 00:40:16 +0300 Subject: [PATCH 10/15] Fix colours in the Makefile and autorun uv sync before test/lint --- Makefile | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 6cf95c84..d1f0c83c 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,13 @@ .PHONY: help docs install format lint test -SUCCESS='\033[0;32m' +SUCCESS = \033[0;32m +RESET = \033[0m SHELL=/bin/bash UV ?= uv UV_RUN ?= uv run VENV_DIR ?= .venv -UV_PYTHON ?= python3.11 +UV_PYTHON ?= 3.11 help: ## Shows this help message # $(MAKEFILE_LIST) is set by make itself; the following parses the `target: ## help line` format and adds color highlighting @@ -14,33 +15,33 @@ help: ## Shows this help message docs: (cd docs ; make clean; make doctest; make html) - @echo "${SUCCESS}============== Docs are available at docs/_build/html/index.html ============== ${SUCCESS}" + @echo -e "$(SUCCESS)============== Docs are available at docs/_build/html/index.html ==============$(RESET)" -venv: ## Create a virtualenv (UV_PYTHON=python3.10 to force) - @$(UV) venv --seed --python "$${UV_PYTHON:-system}" $(VENV_DIR) - @echo "$(SUCCESS) Virtualenv ready in $(VENV_DIR) $(SUCCESS)" +venv: ## Create a virtualenv (UV_PYTHON=3.10 to force) + @$(UV) venv --seed $(if $(strip $(UV_PYTHON)),--python $(UV_PYTHON),) $(VENV_DIR) + @echo -e "$(SUCCESS)Virtualenv ready in $(VENV_DIR)$(RESET)" -sync: venv ## Resolve + install project and dev deps for development +sync: ## Resolve + install project and dev deps for development @$(UV) sync --dev - @echo "$(SUCCESS) Environment synced from pyproject.toml $(SUCCESS)" + @echo -e "$(SUCCESS)Environment synced from pyproject.toml$(RESET)" install: sync ## Backward-compat -format: ## Formats code with `autoflake`, `black` and `isort` +format: sync ## Formats code with `autoflake`, `black` and `isort` @$(UV_RUN) autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place geometric_kernels tests --exclude=__init__.py @$(UV_RUN) black geometric_kernels tests @$(UV_RUN) isort geometric_kernels tests - @echo "$(SUCCESS) Format done $(SUCCESS)" + @echo -e "$(SUCCESS)Format done$(RESET)" -lint: +lint: sync @$(UV_RUN) flake8 geometric_kernels tests @$(UV_RUN) black geometric_kernels tests --check --diff @$(UV_RUN) isort geometric_kernels tests --check-only --diff @$(UV_RUN) mypy --namespace-packages geometric_kernels - @echo "$(SUCCESS) Lint done $(SUCCESS)" + @echo -e "$(SUCCESS)Lint done$(RESET)" -test: ## Run the tests, start with the failing ones and break on first fail. +test: sync ## Run the tests, start with the failing ones and break on first fail. @$(UV_RUN) pytest -v -x --ff -rN -Wignore -s --tb=short --durations=0 --cov --cov-report=xml tests @$(UV_RUN) pytest --nbmake --nbmake-kernel=python3 --durations=0 --nbmake-timeout=1000 --ignore=notebooks/frontends/GPJax.ipynb notebooks/ - @echo "$(SUCCESS) Tests done $(SUCCESS)" + @echo -e "$(SUCCESS)Tests done$(RESET)" From 1787dfae9881001f0c370616541ae3e84a347b6d Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sat, 8 Nov 2025 00:40:54 +0300 Subject: [PATCH 11/15] Clarify README instructions for dev setup --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e6e693ae..7c75d1dc 100644 --- a/README.md +++ b/README.md @@ -154,31 +154,36 @@ If you want to contribute to the library, thank you! Follow these instructions t Initialize the virtual environment. ```bash -make venv [UV_PYTHON=python3.11 VENV_DIR=.venv] +make venv + ``` -You can change the python version and the venv directory. The above are the defaults. +You can change the python version and the venv directory like this: + +```bash +make venv UV_PYTHON=3.11 VENV_DIR=.venv +``` **NOTE**: We use [uv](https://github.com/astral-sh/uv) for development. It is not strictly necessary, and if you don't want to use it, you can still run `make lint` and `make test` if you set `UV_RUN=` to be empty. You will need to set up the environment yourself. Install all backends and the dev requirements (Pytest, black, etc.). This will install all the backends. ```bash -make install [UV_PYTHON=python3.11] +make install ``` **NOTE**: If not using `uv`, you can still install the dev requirements via `pip install -e .[dev]`. -Run style checks +Run the style checks ```bash -make lint [UV_PYTHON=python3.11] +make lint ``` Run the tests ```bash -make test [UV_PYTHON=python3.11] +make test ``` **Example:** If you want to learn how to implement your own space or kernel component, checkout the [CustomSpacesAndKernels.ipynb](https://github.com/geometric-kernels/GeometricKernels/blob/main/notebooks/CustomSpacesAndKernels.ipynb) notebook. From d3409b7eac9d427f5084106851f567e11f0ea1e0 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sat, 8 Nov 2025 00:51:11 +0300 Subject: [PATCH 12/15] Update Makefile for docs to use `uv` --- docs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index d4bb2cbb..3fb41af6 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,7 +4,7 @@ # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build +SPHINXBUILD ?= uv run sphinx-build SOURCEDIR = . BUILDDIR = _build From 8430d0b6f2e765335459fb71d4d89b2326646cd0 Mon Sep 17 00:00:00 2001 From: stoprightthere Date: Sat, 8 Nov 2025 14:10:45 +0300 Subject: [PATCH 13/15] Update docs workflow --- .github/workflows/docs.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 1cdbeecb..0f518aad 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -10,19 +10,21 @@ jobs: runs-on: ubuntu-latest steps: #---------------------------------------------- - # check-out repo and set-up python + # check out repo and set up uv #---------------------------------------------- - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: astral-sh/setup-uv@v6 with: - python-version: "3.10" + version: "0.9.6" #---------------------------------------------- # install #---------------------------------------------- + - name: Set up venv + run: UV_PYTHON=3.11 make venv - name: Install dependencies run: | make install - pip install -r docs/requirements.txt + uv pip install -r docs/requirements.txt - name: Build documentation run: | make docs From 5a33095367e0d05c71a883e1991e272b29a36f1e Mon Sep 17 00:00:00 2001 From: Viacheslav Borovitskiy Date: Sun, 9 Nov 2025 10:01:25 +0000 Subject: [PATCH 14/15] Revise docs/README.md Signed-off-by: Viacheslav Borovitskiy --- docs/README.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index 2a11d0a4..6041ba61 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,12 +1,27 @@ -# Compiling documentation +# Compiling Documentation -First, execute doctests by running the following command in this dirrectory +## Installing Depdenencies + +If you are using `uv`, first install docs building depedenencies **while in the `docs/` dirrectory**. +```bash +uv add -r requirements.txt ``` -make doctest +If you are using `pip`, you can run +```bash +pip install -r requirements.txt ``` -If all tests are passed, run +## Running Doctests + +Execute doctests by running the following command **while in the `docs/` dirrectory**. +```bash +make doctest ``` + +## Compiling Documentation + +If all tests are passed, run the following command **while in the `docs/` dirrectory**. +```bash make html ``` From 2f121d145b9591841121ce49998ac15fa0aa8369 Mon Sep 17 00:00:00 2001 From: Viacheslav Borovitskiy Date: Sun, 9 Nov 2025 10:14:54 +0000 Subject: [PATCH 15/15] Update README with Jupyter/uv integration instructions Signed-off-by: Viacheslav Borovitskiy --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7c75d1dc..4113dbbb 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,8 @@ Run the tests make test ``` +If you want to run Jupyter with your `uv` development environment, check out [this page](https://docs.astral.sh/uv/guides/integration/jupyter/). + **Example:** If you want to learn how to implement your own space or kernel component, checkout the [CustomSpacesAndKernels.ipynb](https://github.com/geometric-kernels/GeometricKernels/blob/main/notebooks/CustomSpacesAndKernels.ipynb) notebook. ## If you have a question