Skip to content

Commit 87d2041

Browse files
maxrjonesd-v-b
andauthored
Add experimental section to the API docs (#3642)
Co-authored-by: Davis Bennett <[email protected]>
1 parent 884a8c9 commit 87d2041

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

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/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)