Skip to content

Commit bac8726

Browse files
authored
Merge branch 'main' into chore/benchmarks
2 parents 09f86ef + 7166a8d commit bac8726

16 files changed

Lines changed: 118 additions & 38 deletions

File tree

.github/workflows/check_changelogs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
1313

1414
- name: Install uv
15-
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4
15+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
1616

1717
- name: Check changelog entries
1818
run: uv run --no-sync python ci/check_changelog_entries.py

.github/workflows/hypothesis.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
5353
- name: Restore cached hypothesis directory
5454
id: restore-hypothesis-cache
55-
uses: actions/cache/restore@v4
55+
uses: actions/cache/restore@v5
5656
with:
5757
path: .hypothesis/
5858
key: cache-hypothesis-${{ runner.os }}-${{ github.run_id }}
@@ -70,7 +70,7 @@ jobs:
7070
- name: Save cached hypothesis directory
7171
id: save-hypothesis-cache
7272
if: always() && steps.status.outcome != 'skipped'
73-
uses: actions/cache/save@v4
73+
uses: actions/cache/save@v5
7474
with:
7575
path: .hypothesis/
7676
key: cache-hypothesis-${{ runner.os }}-${{ github.run_id }}

.github/workflows/nightly_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: hatch build
3232

3333
- name: Upload nightly wheels
34-
uses: scientific-python/upload-nightly-action@b36e8c0c10dbcfd2e05bf95f17ef8c14fd708dbf
34+
uses: scientific-python/upload-nightly-action@5748273c71e2d8d3a61f3a11a16421c8954f9ecf
3535
with:
3636
artifacts_path: dist
3737
anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }}

.github/workflows/releases.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
pip install hatch
2828
- name: Build wheel and sdist
2929
run: hatch build
30-
- uses: actions/upload-artifact@v5
30+
- uses: actions/upload-artifact@v6
3131
with:
3232
name: releases
3333
path: dist
@@ -36,7 +36,7 @@ jobs:
3636
needs: [build_artifacts]
3737
runs-on: ubuntu-latest
3838
steps:
39-
- uses: actions/download-artifact@v6
39+
- uses: actions/download-artifact@v7
4040
with:
4141
name: releases
4242
path: dist
@@ -51,7 +51,7 @@ jobs:
5151
runs-on: ubuntu-latest
5252
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
5353
steps:
54-
- uses: actions/download-artifact@v6
54+
- uses: actions/download-artifact@v7
5555
with:
5656
name: releases
5757
path: dist

.pre-commit-config.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ ci:
44
autofix_commit_msg: "style: pre-commit fixes"
55
autofix_prs: false
66
default_stages: [pre-commit, pre-push]
7+
8+
default_language_version:
9+
python: python3.11
10+
711
repos:
812
- repo: https://github.com/astral-sh/ruff-pre-commit
9-
rev: v0.14.3
13+
rev: v0.14.10
1014
hooks:
1115
- id: ruff-check
1216
args: ["--fix", "--show-fixes"]
@@ -23,7 +27,7 @@ repos:
2327
exclude: mkdocs.yml
2428
- id: trailing-whitespace
2529
- repo: https://github.com/pre-commit/mirrors-mypy
26-
rev: v1.18.2
30+
rev: v1.19.1
2731
hooks:
2832
- id: mypy
2933
files: src|tests
@@ -42,7 +46,7 @@ repos:
4246
- hypothesis
4347
- s3fs
4448
- repo: https://github.com/scientific-python/cookie
45-
rev: 2025.10.20
49+
rev: 2025.11.21
4650
hooks:
4751
- id: sp-repo-review
4852
- repo: https://github.com/pre-commit/pygrep-hooks
@@ -51,7 +55,7 @@ repos:
5155
- id: rst-directive-colons
5256
- id: rst-inline-touching-normal
5357
- repo: https://github.com/numpy/numpydoc
54-
rev: v1.9.0
58+
rev: v1.10.0
5559
hooks:
5660
- id: numpydoc-validation
5761
- repo: https://github.com/twisted/towncrier

changes/3648.misc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix deprecation of setting a shape on an array directly in ``numpy`` 2.5+.

docs/api/zarr/experimental.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: experimental
3+
---
4+
5+
Experimental functionality is not stable and may change or be removed at any point.
6+
7+
## Classes
8+
9+
::: zarr.experimental.cache_store

docs/contributing.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,40 @@ Hatch can also be used to serve continuously updating version of the documentati
173173
hatch --env docs run serve
174174
```
175175

176+
#### Adding executable code blocks in the documentation
177+
178+
Zarr uses [Markdown Exec](https://pawamoy.github.io/markdown-exec/usage/) to execute code blocks in Markdown files. Add `exec="on"` to a code block header for it to be executed when the docs are built. For example:
179+
180+
````md
181+
```python exec="on"
182+
print("Hello world")
183+
```
184+
````
185+
186+
Below are other useful options that can be added to the code block. See [Markdown Exec's documentation](https://pawamoy.github.io/markdown-exec/usage/#options-summary) for a full list:
187+
188+
- `source="above"` makes sure the code within the code block is also rendered in the documentation (rather than just the output).
189+
- `session="<name-of-docs-page>"` executes code blocks in a named session reusing previously defined variables.
190+
- `result="ansi"` or `result="html"` to render the output. If the code does not produce output, you should leave off the `result` option to prevent an empty cell from rendering in the docs.
191+
192+
For example:
193+
194+
````md
195+
```python exec="true" session="contributing" source="above" result="ansi"
196+
print("Hello world")
197+
```
198+
````
199+
200+
renders as:
201+
202+
```python exec="true" session="contributing" source="above" result="ansi"
203+
print("Hello world")
204+
```
205+
206+
#### Building documentation without executing code blocks
207+
208+
Sometimes, you may want the documentation to build quicker. You can disable code block execution by commenting out the [markdown-exec](https://github.com/zarr-developers/zarr-python/blob/884a8c91afcc3efe28b3da952be3b85125c453cb/mkdocs.yml#L132 plugin in the mkdocs configuration file). This will make code blocks and cross references render incorrectly (i.e., expect build warnings), but also reduces build time by ~3x. Be sure to undo the commenting out before opening your pull request.
209+
176210
### Changelog
177211

178212
zarr-python uses [towncrier](https://towncrier.readthedocs.io/en/stable/tutorial.html) to manage release notes. Most pull requests should include at least one news fragment describing the changes. To add a release note, you'll need the GitHub issue or pull request number and the type of your change (`feature`, `bugfix`, `doc`, `removal`, `misc`). With that, run `towncrier create` with your development environment, which will prompt you for the issue number, change type, and the news text:

docs/user-guide/experimental.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This section contains documentation for experimental Zarr Python features. The f
44

55
## `CacheStore`
66

7-
Zarr Python 3.1.4 adds `zarr.experimental.cache_store.CacheStore` provides a dual-store caching implementation
7+
Zarr Python 3.1.4 adds [`zarr.experimental.cache_store.CacheStore`][] provides a dual-store caching implementation
88
that can be wrapped around any Zarr store to improve performance for repeated data access.
99
This is particularly useful when working with remote stores (e.g., S3, HTTP) where network
1010
latency can significantly impact data access speed.
@@ -24,7 +24,7 @@ Because the `CacheStore` uses an ordinary Zarr `Store` object as the caching lay
2424
Creating a CacheStore requires both a source store and a cache store. The cache store
2525
can be any Store implementation, providing flexibility in cache persistence:
2626

27-
```python exec="true" session="experimental" source="above" result="ansi"
27+
```python exec="true" session="experimental" source="above"
2828
import zarr
2929
from zarr.storage import LocalStore
3030
import numpy as np
@@ -73,6 +73,7 @@ elapsed_nocache = time.time() - start
7373

7474
# Cache provides speedup for repeated access
7575
speedup = elapsed_nocache / elapsed_cache
76+
print(f"Speedup is {speedup}")
7677
```
7778

7879
Cache effectiveness is particularly pronounced with repeated access to the same data chunks.
@@ -84,7 +85,7 @@ The CacheStore can be configured with several parameters:
8485

8586
**max_size**: Controls the maximum size of cached data in bytes
8687

87-
```python exec="true" session="experimental" source="above" result="ansi"
88+
```python exec="true" session="experimental" source="above"
8889
# 256MB cache with size limit
8990
cache = CacheStore(
9091
store=source_store,
@@ -102,7 +103,7 @@ cache = CacheStore(
102103

103104
**max_age_seconds**: Controls time-based cache expiration
104105

105-
```python exec="true" session="experimental" source="above" result="ansi"
106+
```python exec="true" session="experimental" source="above"
106107
# Cache expires after 1 hour
107108
cache = CacheStore(
108109
store=source_store,
@@ -162,7 +163,7 @@ The `cache_info()` method returns a dictionary with detailed information about t
162163

163164
The CacheStore provides methods for manual cache management:
164165

165-
```python exec="true" session="experimental" source="above" result="ansi"
166+
```python exec="true" session="experimental" source="above"
166167
# Clear all cached data and tracking information
167168
import asyncio
168169
asyncio.run(cached_store.clear_cache())
@@ -192,7 +193,7 @@ and use any store type for the cache backend:
192193

193194
### Local Store with Memory Cache
194195

195-
```python exec="true" session="experimental-memory-cache" source="above" result="ansi"
196+
```python exec="true" session="experimental-memory-cache" source="above"
196197
from zarr.storage import LocalStore, MemoryStore
197198
from zarr.experimental.cache_store import CacheStore
198199
from tempfile import mkdtemp
@@ -209,7 +210,7 @@ cached_store = CacheStore(
209210

210211
### Memory Store with Persistent Cache
211212

212-
```python exec="true" session="experimental-local-cache" source="above" result="ansi"
213+
```python exec="true" session="experimental-local-cache" source="above"
213214
from tempfile import mkdtemp
214215
from zarr.storage import MemoryStore, LocalStore
215216
from zarr.experimental.cache_store import CacheStore
@@ -255,10 +256,12 @@ zarr_array[:] = np.random.random((100, 100))
255256
start = time.time()
256257
data = zarr_array[20:30, 20:30] # First access (cache miss)
257258
first_access = time.time() - start
259+
print(f"First access took {first_access}")
258260

259261
start = time.time()
260262
data = zarr_array[20:30, 20:30] # Second access (cache hit)
261263
second_access = time.time() - start
264+
print(f"Second access took {second_access}")
262265

263266
# Check cache statistics
264267
info = cached_store.cache_info()

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ nav:
4646
- api/zarr/metadata.md
4747
- api/zarr/registry.md
4848
- api/zarr/storage.md
49+
- api/zarr/experimental.md
4950
- ABC:
5051
- api/zarr/abc/index.md
5152
- api/zarr/abc/buffer.md

0 commit comments

Comments
 (0)