Skip to content

Commit 391706e

Browse files
committed
merge main
2 parents c2a2aaf + 3c6ae7d commit 391706e

Some content is hidden

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

55 files changed

+4063
-1320
lines changed

.github/workflows/docs.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,34 @@ jobs:
2424
uses: actions/checkout@v4
2525
with:
2626
fetch-depth: 0
27+
2728
- name: Setup Pages
2829
id: pages
2930
uses: actions/configure-pages@v3
31+
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v7
34+
35+
- name: Set up Python
36+
run: uv python install 3.11
37+
3038
- name: Install dependencies
3139
run: |
32-
python -m pip install --upgrade pip
33-
pip install ".[doc]"
40+
uv sync --group doc
41+
# temporary fix for sphinx-polyversion
42+
uv pip install --force-reinstall git+https://github.com/ziw-liu/sphinx-polyversion.git@iohub-staging
3443
- name: Set environment
3544
run: |
3645
REPO_OWNER="${GITHUB_REPOSITORY%%/*}"
3746
REPO_NAME="${GITHUB_REPOSITORY#*/}"
3847
echo "GITHUB_PAGES_URL=https://$REPO_OWNER.github.io/$REPO_NAME" >> $GITHUB_ENV
48+
3949
- name: Build the docs
4050
run: |
4151
echo $GITHUB_PAGES_URL
42-
make build -C docs
52+
uv run make build -C docs
4353
touch docs/build/.nojekyll
54+
4455
- name: Upload build artifacts
4556
uses: actions/upload-pages-artifact@v3
4657
with:

.github/workflows/pr.yml

Lines changed: 19 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,24 @@
11
# This workflow will install Python dependencies, run tests and lint with a single version of Python
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: lint, style, and tests
4+
name: PR checks
55

66
on:
77
pull_request:
88
branches:
99
- "*"
1010

1111
jobs:
12-
style:
13-
name: Style Check
14-
runs-on: ubuntu-latest
15-
16-
strategy:
17-
matrix:
18-
python-version: ["3.11"]
19-
20-
steps:
21-
- uses: actions/checkout@v4
22-
- name: Set up Python
23-
uses: actions/setup-python@v4
24-
with:
25-
python-version: ${{ matrix.python-version }}
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install black
30-
- name: Check code styling with Black
31-
run: |
32-
black --diff -S -t py310 iohub
33-
black --check -S -t py310 iohub
34-
3512
lint:
36-
name: Lint Check
37-
runs-on: ubuntu-latest
38-
39-
strategy:
40-
matrix:
41-
python-version: ["3.11"]
42-
43-
steps:
44-
- uses: actions/checkout@v4
45-
- name: Set up Python
46-
uses: actions/setup-python@v4
47-
with:
48-
python-version: ${{ matrix.python-version }}
49-
- name: Install dependencies
50-
run: |
51-
python -m pip install --upgrade pip
52-
pip install flake8
53-
- name: Check code with Flake8
54-
# E203 conflicts with black
55-
run: |
56-
flake8 iohub --extend-ignore=E203
57-
58-
isort:
59-
name: isort Check
13+
name: Lint
6014
runs-on: ubuntu-latest
61-
62-
strategy:
63-
matrix:
64-
python-version: ["3.11"]
65-
6615
steps:
6716
- uses: actions/checkout@v4
68-
- name: Set up Python
69-
uses: actions/setup-python@v4
17+
- uses: j178/prek-action@v1
7018
with:
71-
python-version: ${{ matrix.python-version }}
72-
- name: Install dependencies
73-
run: |
74-
python -m pip install --upgrade pip
75-
pip install isort
76-
- name: Check code with isort
77-
run: |
78-
isort --check iohub
19+
extra-args: ''
7920

8021
tests:
81-
needs: [style, lint, isort]
8222
runs-on: ubuntu-latest
8323
strategy:
8424
matrix:
@@ -87,40 +27,38 @@ jobs:
8727
steps:
8828
- uses: actions/checkout@v4
8929

90-
- uses: actions/setup-python@v4
91-
with:
92-
python-version: ${{ matrix.python-version }}
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v7
32+
33+
- name: Set up Python ${{ matrix.python-version }}
34+
run: uv python install ${{ matrix.python-version }}
9335

9436
- name: Install dependencies
95-
run: |
96-
python -m pip install --upgrade pip
97-
pip install ".[dev,acquire-zarr]"
37+
run: uv sync --group test
9838

9939
- name: Test with pytest
10040
env:
10141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102-
run: |
103-
pytest -v --cov=./ --cov-report=xml
42+
run: uv run pytest -v --cov=./ --cov-report=xml
10443

10544
# this checks that docs build and examples run
10645
# but does not deploy to GH Pages
10746
docs:
108-
needs: [style, lint, isort]
10947
runs-on: ubuntu-latest
11048
steps:
11149
- uses: actions/checkout@v4
11250

113-
- uses: actions/setup-python@v4
114-
with:
115-
python-version: "3.11"
51+
- name: Install uv
52+
uses: astral-sh/setup-uv@v7
53+
54+
- name: Set up Python
55+
run: uv python install 3.11
11656

11757
- name: Install dependencies
11858
run: |
119-
python -m pip install --upgrade pip
120-
pip install ".[doc]"
59+
uv sync --group doc
12160
# temporary fix for sphinx-polyversion
122-
pip install --force-reinstall git+https://github.com/ziw-liu/sphinx-polyversion.git@iohub-staging
61+
uv pip install --force-reinstall git+https://github.com/ziw-liu/sphinx-polyversion.git@iohub-staging
12362
12463
- name: Test docs build
125-
run: |
126-
sphinx-polyversion docs/poly.py -vvv --local
64+
run: uv run sphinx-polyversion docs/poly.py -vvv --local

.github/workflows/test.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20-
- uses: actions/setup-python@v4
21-
with:
22-
python-version: ${{ matrix.python-version }}
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v7
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
run: uv python install ${{ matrix.python-version }}
2325

2426
- name: Install dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
pip install ".[dev,acquire-zarr]"
27+
run: uv sync --group test
2828

2929
- name: Test with pytest
3030
env:
3131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
run: |
33-
pytest -v --cov=./iohub --cov-report=xml
32+
run: uv run pytest -v --cov=./iohub --cov-report=xml

.pre-commit-config.yaml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,19 @@
11
repos:
22
# basic pre-commit
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
4+
rev: v6.0.0
55
hooks:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- id: check-added-large-files
9+
args: ['--maxkb=1000']
910
- id: check-yaml
1011
- id: check-toml
1112
- id: detect-private-key
12-
# sorting imports
13-
- repo: https://github.com/pycqa/isort
14-
rev: 5.12.0
13+
# linting and formatting
14+
- repo: https://github.com/astral-sh/ruff-pre-commit
15+
rev: v0.14.14
1516
hooks:
16-
- id: isort
17-
# syntax linting and formatting
18-
- repo: https://github.com/myint/autoflake
19-
rev: v2.1.1
20-
hooks:
21-
- id: autoflake
22-
args: [--in-place, --remove-all-unused-imports,
23-
--ignore-init-module-imports]
24-
- repo: https://github.com/PyCQA/flake8
25-
rev: 6.0.0
26-
hooks:
27-
- id: flake8
28-
args: [--ignore, "E203,W503", --min-python-version, '3.11']
29-
additional_dependencies: [flake8-typing-imports==1.16.0]
30-
- repo: https://github.com/psf/black
31-
rev: 23.3.0
32-
hooks:
33-
- id: black
17+
- id: ruff-check
18+
args: [--fix]
19+
- id: ruff-format

CONTRIBUTING.md

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,15 @@ or describe the bug fixed or feature implemented in the PR.
6969

7070
### Setting up development environment
7171

72-
For local development, first install [Git](https://git-scm.com/)
73-
and Python with an environment management tool
74-
(e.g. [miniforge](https://github.com/conda-forge/miniforge), a minimal community distribution of Conda).
72+
This project uses [uv](https://docs.astral.sh/uv/) for dependency management.
7573

76-
If you use Conda, set up an environment with:
74+
#### Install uv
7775

78-
```sh
79-
conda create -n iohub-dev python=3.11
80-
conda activate iohub-dev
81-
```
76+
See [uv installation docs](https://docs.astral.sh/uv/getting-started/installation/).
77+
78+
#### Clone the repository
8279

83-
If you have push permission to the repository,
84-
clone the repository (the code blocks below are shell commands):
80+
If you have push permission to the repository:
8581

8682
```sh
8783
cd # to the directory you want to work in
@@ -91,40 +87,61 @@ git clone https://github.com/czbiohub-sf/iohub.git
9187
Otherwise, you can follow [these instructions](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
9288
to [fork](https://github.com/czbiohub-sf/iohub/fork) the repository.
9389

94-
Then install the package in editable mode with the development dependencies.
95-
Remove acquire-zarr if you do not have glibc version 2.35 or later,
96-
for example on the Bruno cluster (Rocky Linux 8).
90+
#### Install dependencies
91+
92+
First, create a virtual environment with a supported Python version (3.11-3.13):
93+
94+
```sh
95+
cd iohub/
96+
uv venv -p 3.13 # or 3.11, 3.12
97+
```
98+
99+
This makes a virtual environment in the `.venv` where the dependencies for `iohub` will be installed.
100+
101+
Then sync dependencies:
97102

98103
```sh
99-
cd iohub/ # or the renamed project root directory
100-
pip install -e ".[dev,acquire-zarr]"
104+
uv sync
101105
```
102106

107+
> **Note**: `uv sync` installs the [`dev` group by default](https://docs.astral.sh/uv/concepts/projects/sync/#syncing-development-dependencies), which includes all development dependencies. iohub currently supports Python 3.11-3.13—if `uv sync` fails to resolve dependencies, ensure you've created a venv with a supported version as shown above. See [dependency groups](https://docs.astral.sh/uv/concepts/projects/dependencies/#dependency-groups) for more details.
108+
109+
#### Dependency groups
110+
111+
The project uses [dependency groups](https://docs.astral.sh/uv/concepts/projects/dependencies/#dependency-groups) for development tools and [optional dependencies](https://docs.astral.sh/uv/concepts/projects/dependencies/#optional-dependencies) for user-facing extras.
112+
113+
| Group | Purpose |
114+
|-------|---------|
115+
| `test` | Testing tools (pytest, hypothesis, etc.) |
116+
| `acquire-zarr` | Acquire-zarr reader (requires glibc 2.35+) |
117+
| `doc` | Documentation (sphinx, etc.) |
118+
| `pre-commit` | Pre-commit hooks |
119+
| `dev` | Includes test, acquire-zarr, doc, pre-commit (installed by default via `uv sync`) |
120+
121+
> **Note**: On older glibc systems (e.g., Rocky Linux 8), `acquire-zarr` won't work. Use `uv sync --no-group acquire-zarr` instead.
122+
103123
Then make the changes and [track them with Git](https://docs.github.com/en/get-started/using-git/about-git#example-contribute-to-an-existing-repository).
104124

105125
### Developing documentation
106126

107127
#### Prerequisites
108128

109-
Install a forked version of `sphinx-polyversion` due to an incompatibility with `setuptools_scm`.
129+
Install the [forked version of `sphinx-polyversion`](https://github.com/ziw-liu/sphinx-polyversion/tree/iohub-staging) (temporary fix for compatibility):
110130

111131
```shell
112-
pip install --force-reinstall git+https://github.com/ziw-liu/sphinx-polyversion.git@iohub-staging
132+
uv pip install --force-reinstall git+https://github.com/ziw-liu/sphinx-polyversion.git@iohub-staging
113133
```
114134

115135
#### Building the HTML version locally
116136

117-
Inside `/docs` folder
137+
Inside the `docs/` folder:
118138

119139
```shell
120-
pip install "/PATH/TO/iohub[doc]"
121140
make clean
122-
sphinx-polyversion poly.py -vvv --local
141+
uv run sphinx-polyversion poly.py -vvv --local
123142
```
124143

125-
Generated HTML documentation can be found in
126-
the ``build/html`` directory. Open ``build/html/index.html`` to view the home
127-
page for the documentation.
144+
Generated HTML documentation can be found in the `build/` directory.
128145

129146
#### Writing examples
130147

@@ -138,8 +155,7 @@ and output (stdout, matplotlib plot) are rendered in HTML.
138155
They can also be executed as plain Python scripts
139156
or interactive code blocks in some IDEs (VS Code, PyCharm, Spyder etc.).
140157

141-
See the syntax documentation
142-
[here](https://sphinx-gallery.github.io/stable/syntax.html).
158+
See the [syntax documentation](https://sphinx-gallery.github.io/stable/syntax.html).
143159

144160
### Testing
145161

@@ -148,7 +164,7 @@ Local test runs and coverage check can be invoked by:
148164

149165
```sh
150166
# in the project root directory
151-
pytest --cov=iohub tests/
167+
uv run pytest --cov=iohub tests/
152168
```
153169

154170
`iohub` uses [Hypothesis](https://hypothesis.readthedocs.io/en/latest/index.html)
@@ -158,12 +174,21 @@ for how this can reveal more bugs.
158174

159175
### Code style
160176

161-
We use [pre-commit](https://pre-commit.com/) to sort imports with [isort](https://github.com/PyCQA/isort), format code with [black](https://black.readthedocs.io/en/stable/), and lint with [flake8](https://github.com/PyCQA/flake8) automatically prior to each commit. To minimize test errors when submitting pull requests, please install pre-commit in your environment as follows:
177+
We use [prek](https://github.com/j178/prek) (a faster [pre-commit](https://pre-commit.com/) runner) to automatically format and lint code prior to each commit. To minimize test errors when submitting pull requests, install the hooks:
178+
179+
```bash
180+
uvx prek install
181+
```
182+
183+
> `uvx` runs tools in isolated, cached environments, no binaries added to your PATH and no dependencies installed in your project venv.
184+
185+
To run manually:
162186

163187
```bash
164-
pre-commit install
188+
uvx prek run # run on staged files only
189+
uvx prek run --all-files # run on all files
165190
```
166191

167-
When these packages are executed within the project root directory, they should automatically use the [project settings](./pyproject.toml).
192+
When these tools are executed within the project root directory, they should automatically use the [project settings](./pyproject.toml).
168193

169194
[NumPy style docstrings](https://numpydoc.readthedocs.io/en/latest/format.html) are used for API documentation.

0 commit comments

Comments
 (0)