Skip to content

Commit c393e41

Browse files
authored
Merge branch 'main' into coalesce-shard-reads
2 parents 6437fb6 + b30ae18 commit c393e41

File tree

9 files changed

+79
-15
lines changed

9 files changed

+79
-15
lines changed

.github/workflows/check_changelogs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
12+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1313

1414
- name: Install uv
1515
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0

.github/workflows/codspeed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Run benchmarks
1818
runs-on: codspeed-macro
1919
steps:
20-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@v6
2121
with:
2222
fetch-depth: 0 # grab all branches and tags
2323
- name: Set up Python

.github/workflows/lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main, 3.1.x]
6+
pull_request:
7+
branches: [main, 3.1.x]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
lint:
16+
name: Lint
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v6
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v5
22+
- name: Install prek
23+
run: uv tool install prek
24+
- name: Run prek
25+
run: prek run --all-files

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
ci:
22
autoupdate_commit_msg: "chore: update pre-commit hooks"
33
autoupdate_schedule: "monthly"
4-
autofix_commit_msg: "style: pre-commit fixes"
54
autofix_prs: false
5+
skip: [] # pre-commit.ci only checks for updates, prek runs hooks locally
6+
67
default_stages: [pre-commit, pre-push]
78

89
default_language_version:

changes/3658.misc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Switch from `pre-commit` to [`prek`](https://github.com/j178/prek) for pre-commit checks.

docs/contributing.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,50 @@ All tests are automatically run via GitHub Actions for every pull request and mu
109109

110110
> **Note:** Previous versions of Zarr-Python made extensive use of doctests. These tests were not maintained during the 3.0 refactor but may be brought back in the future. See issue #2614 for more details.
111111
112-
### Code standards - using pre-commit
112+
### Code standards - using prek
113113

114114
All code must conform to the PEP8 standard. Regarding line length, lines up to 100 characters are allowed, although please try to keep under 90 wherever possible.
115115

116-
`Zarr` uses a set of `pre-commit` hooks and the `pre-commit` bot to format, type-check, and prettify the codebase. `pre-commit` can be installed locally by running:
116+
`Zarr` uses a set of git hooks managed by [`prek`](https://github.com/j178/prek), a fast, Rust-based pre-commit hook manager that is fully compatible with `.pre-commit-config.yaml` files. `prek` can be installed locally by running:
117117

118118
```bash
119-
python -m pip install pre-commit
119+
uv tool install prek
120+
```
121+
122+
or:
123+
124+
```bash
125+
pip install prek
120126
```
121127

122128
The hooks can be installed locally by running:
123129

124130
```bash
125-
pre-commit install
131+
prek install
132+
```
133+
134+
This would run the checks every time a commit is created locally. The checks will by default only run on the files modified by a commit, but the checks can be triggered for all the files by running:
135+
136+
```bash
137+
prek run --all-files
138+
```
139+
140+
You can also run hooks only for files in a specific directory:
141+
142+
```bash
143+
prek run --directory src/zarr
144+
```
145+
146+
Or run hooks for files changed in the last commit:
147+
148+
```bash
149+
prek run --last-commit
126150
```
127151

128-
This would run the checks every time a commit is created locally. These checks will also run on every commit pushed to an open PR, resulting in some automatic styling fixes by the `pre-commit` bot. The checks will by default only run on the files modified by a commit, but the checks can be triggered for all the files by running:
152+
To list all available hooks:
129153

130154
```bash
131-
pre-commit run --all-files
155+
prek list
132156
```
133157

134158
If you would like to skip the failing checks and push the code for further discussion, use the `--no-verify` option with `git commit`.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ maintainers = [
3030
{ name = "Deepak Cherian" }
3131
]
3232
requires-python = ">=3.11"
33-
# If you add a new dependency here, please also add it to .pre-commit-config.yml
33+
# If you add a new dependency here, please also add it to .pre-commit-config.yaml
3434
dependencies = [
3535
'packaging>=22.0',
3636
'numpy>=2.0',
@@ -428,6 +428,7 @@ markers = [
428428
ignore = [
429429
"PC111", # fix Python code in documentation - enable later
430430
"PC180", # for JavaScript - not interested
431+
"PC902", # pre-commit.ci custom autofix message - not using autofix
431432
]
432433

433434
[tool.numpydoc_validation]

tests/benchmarks/test_indexing.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,27 @@
2222
(slice(None), slice(0, 3, 2), slice(0, 10)),
2323
)
2424

25+
shards = (
26+
None,
27+
(50,) * 3,
28+
)
29+
2530

26-
@pytest.mark.parametrize("store", ["memory"], indirect=["store"])
31+
@pytest.mark.parametrize("store", ["memory", "memory_get_latency"], indirect=["store"])
2732
@pytest.mark.parametrize("indexer", indexers, ids=str)
33+
@pytest.mark.parametrize("shards", shards, ids=str)
2834
def test_slice_indexing(
29-
store: Store, indexer: tuple[int | slice], benchmark: BenchmarkFixture
35+
store: Store,
36+
indexer: tuple[int | slice],
37+
shards: tuple[int, ...] | None,
38+
benchmark: BenchmarkFixture,
3039
) -> None:
3140
data = create_array(
3241
store=store,
3342
shape=(105,) * 3,
3443
dtype="uint8",
3544
chunks=(10,) * 3,
36-
shards=None,
45+
shards=shards,
3746
compressors=None,
3847
filters=None,
3948
fill_value=0,

tests/conftest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from zarr.core.metadata.v3 import ArrayV3Metadata
4141
from zarr.core.sync import sync
4242
from zarr.storage import FsspecStore, LocalStore, MemoryStore, StorePath, ZipStore
43+
from zarr.testing.store import LatencyStore
4344

4445
if TYPE_CHECKING:
4546
from collections.abc import Generator
@@ -58,8 +59,8 @@
5859

5960

6061
async def parse_store(
61-
store: Literal["local", "memory", "fsspec", "zip"], path: str
62-
) -> LocalStore | MemoryStore | FsspecStore | ZipStore:
62+
store: Literal["local", "memory", "fsspec", "zip", "memory_get_latency"], path: str
63+
) -> LocalStore | MemoryStore | FsspecStore | ZipStore | LatencyStore:
6364
if store == "local":
6465
return await LocalStore.open(path)
6566
if store == "memory":
@@ -68,6 +69,8 @@ async def parse_store(
6869
return await FsspecStore.open(url=path)
6970
if store == "zip":
7071
return await ZipStore.open(path + "/zarr.zip", mode="w")
72+
if store == "memory_get_latency":
73+
return LatencyStore(MemoryStore(), get_latency=0.0001, set_latency=0)
7174
raise AssertionError
7275

7376

0 commit comments

Comments
 (0)