Skip to content

Commit c01b950

Browse files
committed
Promote Cortado as PerTurbo v2 successor
1 parent 3e6b6e9 commit c01b950

69 files changed

Lines changed: 19095 additions & 21093 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.git
2+
.venv
3+
.pytest_cache
4+
.ruff_cache
5+
__pycache__
6+
.test_outputs
7+
dist
8+
build
9+
docs
10+
tests
11+
*.h5ad
12+
*.h5mu
13+
*.ipynb

.github/workflows/build.yaml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
name: Check Build
1+
name: Check build
22

33
on:
44
push:
55
branches: [main]
66
pull_request:
77
branches: [main]
88

9-
concurrency:
10-
group: ${{ github.workflow }}-${{ github.ref }}
11-
cancel-in-progress: true
12-
139
jobs:
1410
package:
1511
runs-on: ubuntu-latest
1612
steps:
17-
- uses: actions/checkout@v3
18-
- name: Set up Python 3.10
19-
uses: actions/setup-python@v4
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
2015
with:
21-
python-version: "3.10"
22-
cache: "pip"
23-
cache-dependency-path: "**/pyproject.toml"
24-
- name: Install build dependencies
25-
run: python -m pip install --upgrade pip wheel twine build
26-
- name: Build package
27-
run: python -m build
28-
- name: Check package
29-
run: twine check --strict dist/*.whl
16+
python-version: "3.11"
17+
- uses: astral-sh/setup-uv@v5
18+
- run: uv build
19+
- run: uv run --with twine twine check --strict dist/*
20+
- run: uv venv /tmp/perturbo-wheel
21+
- run: uv pip install --python /tmp/perturbo-wheel/bin/python dist/*.whl
22+
- run: /tmp/perturbo-wheel/bin/perturbo --help

.github/workflows/docker.yaml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@ name: Build & Push CUDA Image (GHCR)
22

33
on:
44
push:
5-
# branches: [ main ]
6-
tags: [ 'v*' ] # build on version tags, e.g. v1.2.3
7-
workflow_dispatch: {} # allow manual runs
5+
# Version tags are the intentional release boundary for container images.
6+
tags: ["v*"]
7+
workflow_dispatch: {}
88

99
permissions:
1010
contents: read
11-
packages: write # REQUIRED for ghcr.io
11+
packages: write
1212

1313
jobs:
1414
build:
1515
runs-on: ubuntu-latest
16-
1716
steps:
1817
- name: Checkout
1918
uses: actions/checkout@v4
2019

21-
- name: Set up QEMU (for cross-arch emulation)
20+
- name: Set up QEMU
2221
uses: docker/setup-qemu-action@v3
2322

2423
- name: Set up Docker Buildx
@@ -31,22 +30,21 @@ jobs:
3130
username: ${{ github.actor }}
3231
password: ${{ secrets.GITHUB_TOKEN }}
3332

34-
- name: Extract metadata (tags, labels)
33+
- name: Extract metadata
3534
id: meta
3635
uses: docker/metadata-action@v5
3736
with:
3837
images: ghcr.io/${{ github.repository }}
3938
tags: |
40-
type=ref,event=branch
4139
type=ref,event=tag
4240
type=sha
4341
44-
- name: Build & Push
42+
- name: Build and push JAX CUDA image
4543
uses: docker/build-push-action@v6
4644
with:
4745
context: .
48-
file: ./Dockerfile # change if your Dockerfile path differs
49-
platforms: linux/amd64 # most HPC nodes are amd64; add linux/arm64 if needed
46+
file: ./Dockerfile
47+
platforms: linux/amd64
5048
push: true
5149
tags: ${{ steps.meta.outputs.tags }}
5250
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/release.yaml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,19 @@ on:
44
release:
55
types: [published]
66

7-
# Use "trusted publishing", see https://docs.pypi.org/trusted-publishers/
87
jobs:
98
release:
10-
name: Upload release to PyPI
119
runs-on: ubuntu-latest
1210
environment:
1311
name: pypi
1412
url: https://pypi.org/p/perturbo
1513
permissions:
16-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
14+
id-token: write
1715
steps:
1816
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v5
1918
with:
20-
filter: blob:none
21-
fetch-depth: 0
22-
- uses: actions/setup-python@v4
23-
with:
24-
python-version: "3.x"
25-
cache: "pip"
26-
- run: pip install build
27-
- run: python -m build
28-
- name: Publish package distributions to PyPI
29-
uses: pypa/gh-action-pypi-publish@release/v1
19+
python-version: "3.11"
20+
- uses: astral-sh/setup-uv@v5
21+
- run: uv build
22+
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yaml

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,59 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8-
schedule:
9-
- cron: "0 5 1,15 * *"
108

119
concurrency:
1210
group: ${{ github.workflow }}-${{ github.ref }}
1311
cancel-in-progress: true
1412

1513
jobs:
1614
test:
17-
runs-on: ${{ matrix.os }}
18-
defaults:
19-
run:
20-
shell: bash -e {0} # -e to fail on error
21-
15+
runs-on: ubuntu-latest
2216
strategy:
2317
fail-fast: false
2418
matrix:
25-
python: ["3.10", "3.11", "3.12"]
26-
os: [ubuntu-latest]
27-
19+
python: ["3.11", "3.12"]
2820
env:
29-
OS: ${{ matrix.os }}
30-
PYTHON: ${{ matrix.python }}
31-
21+
JAX_PLATFORM_NAME: cpu
22+
MPLBACKEND: Agg
3223
steps:
33-
- uses: actions/checkout@v3
34-
- name: Set up Python ${{ matrix.python }}
35-
uses: actions/setup-python@v4
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-python@v5
3626
with:
3727
python-version: ${{ matrix.python }}
38-
cache: "pip"
39-
cache-dependency-path: "**/pyproject.toml"
28+
- uses: astral-sh/setup-uv@v5
29+
with:
30+
enable-cache: true
31+
- run: uv sync --locked --group test
32+
- run: uv run pytest
33+
34+
clean-import:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-python@v5
39+
with:
40+
python-version: "3.11"
41+
- uses: astral-sh/setup-uv@v5
42+
- run: uv venv /tmp/perturbo-base
43+
- run: uv pip install --python /tmp/perturbo-base/bin/python .
44+
- run: >-
45+
/tmp/perturbo-base/bin/python -c
46+
"import sys; import perturbo;
47+
assert all(name not in sys.modules for name in ('torch', 'pyro', 'scvi'))"
4048
41-
- name: Install test dependencies
42-
run: |
43-
python -m pip install --upgrade pip wheel
44-
- name: Install dependencies
45-
run: |
46-
pip install ".[dev,test]"
47-
- name: Test
48-
env:
49-
MPLBACKEND: agg
50-
PLATFORM: ${{ matrix.os }}
51-
DISPLAY: :42
52-
run: |
53-
coverage run -m pytest -v --color=yes
54-
- name: Report coverage
55-
run: |
56-
coverage report
57-
- name: Upload coverage
58-
uses: codecov/codecov-action@v3
49+
legacy:
50+
runs-on: ubuntu-latest
51+
env:
52+
JAX_PLATFORM_NAME: cpu
53+
MPLBACKEND: Agg
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: actions/setup-python@v5
57+
with:
58+
python-version: "3.11"
59+
- uses: astral-sh/setup-uv@v5
5960
with:
60-
token: ${{ secrets.CODECOV_TOKEN }}
61+
enable-cache: true
62+
- run: uv sync --locked --group test --extra legacy
63+
- run: uv run pytest tests/legacy

.readthedocs.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# https://docs.readthedocs.io/en/stable/config-file/v2.html
22
version: 2
33
build:
4-
os: ubuntu-20.04
4+
os: ubuntu-22.04
55
tools:
6-
python: "3.10"
6+
python: "3.11"
77
sphinx:
88
configuration: docs/conf.py
99
# disable this for more lenient docs builds
@@ -13,4 +13,4 @@ python:
1313
- method: pip
1414
path: .
1515
extra_requirements:
16-
- doc
16+
- docs

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,13 @@ and this project adheres to [Semantic Versioning][].
1212

1313
### Added
1414

15-
- Basic tool, preprocessing and plotting functions
15+
- PerTurbo 2.0 replaces the default implementation with NumPyro/JAX.
16+
- The former PyTorch/Pyro/scvi implementation is isolated under the deprecated
17+
`perturbo.legacy` optional extra.
18+
- Cortado-format MuData registrations and fit bundles are read compatibly and
19+
migrated to the PerTurbo v2 format when saved.
20+
21+
### Changed
22+
23+
- Python 3.11 is now the minimum supported version.
24+
- The command-line entry point is `perturbo`.

Dockerfile

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
# syntax=docker/dockerfile:1
2-
FROM pytorch/pytorch:2.6.0-cuda12.4-cudnn9-runtime
1+
# JAX's CUDA 12 extra carries the CUDA/cuDNN user-space libraries as Python
2+
# wheels. The host's NVIDIA driver is supplied at runtime by the NVIDIA
3+
# Container Toolkit, so a PyTorch or system-CUDA base image is unnecessary.
4+
FROM python:3.11-slim
5+
36
WORKDIR /app
4-
ENV DEBIAN_FRONTEND=noninteractive
5-
RUN apt-get update && apt-get install -y --no-install-recommends git curl ca-certificates && rm -rf /var/lib/apt/lists/*
6-
RUN pip install --upgrade pip
77

8-
# The workflow will place PerTurbo/ alongside this Dockerfile
9-
COPY . /app/PerTurbo
10-
# (optional) avoid copying .git via .dockerignore
11-
RUN pip install /app/PerTurbo
8+
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
9+
PIP_NO_CACHE_DIR=1 \
10+
PYTHONUNBUFFERED=1 \
11+
XLA_PYTHON_CLIENT_PREALLOCATE=false
12+
13+
RUN apt-get update \
14+
&& apt-get install -y --no-install-recommends ca-certificates \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
RUN python -m pip install --upgrade pip \
18+
&& python -m pip install uv==0.6.3
19+
20+
COPY pyproject.toml uv.lock README.md LICENSE ./
21+
COPY src ./src
22+
23+
RUN uv sync --locked --no-dev --extra cuda
24+
25+
ENV PATH="/app/.venv/bin:$PATH"
1226

13-
CMD ["python3"]
27+
ENTRYPOINT ["perturbo"]
28+
CMD ["--help"]

0 commit comments

Comments
 (0)