Skip to content

Commit 5823ef7

Browse files
mpiannuccirabernat
andauthored
[docs] Add async usage doc (#1139)
* Add async docs first pass * Apply suggestion from @rabernat Co-authored-by: Ryan Abernathey <ryan.abernathey@gmail.com> * Apply suggestion from @rabernat Co-authored-by: Ryan Abernathey <ryan.abernathey@gmail.com> * Update exec code * Apply suggestion from @rabernat Co-authored-by: Ryan Abernathey <ryan.abernathey@gmail.com> --------- Co-authored-by: Ryan Abernathey <ryan.abernathey@gmail.com>
1 parent 3f0ffba commit 5823ef7

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

docs/docs/async.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Async Usage
2+
3+
Icechunk includes an optional asynchronous interface for orchestrating repos and sessions. However, the Icechunk core is fully asynchronous and delivers full parallelism and performance whether you choose to use the synchronous or asynchronous interface. Most users, particularly those doing interactive data science and analytics, should use the synchronous interface.
4+
5+
## When to use async
6+
7+
The async interface allows for icechunk operations to run concurrently, without blocking the current thread while waiting for IO operations. The most common reason to use async is that you are developing a backend service in which work may be happening across multiple Icechunk repositories simultaneously.
8+
9+
## Using the async interface
10+
11+
You can call both sync and async methods on a `Repository`, `Session`, or `Store` as needed. (Of course, to use the async methods, you must be within a async function.) Methods that support async are named with an `_async` postfix:
12+
13+
```python exec="on" session="async_usage" source="material-block"
14+
import icechunk
15+
16+
async def get_branches(storage: icechunk.Storage) -> set[str]:
17+
repo = await icechunk.Repository.open_async(storage)
18+
return await repo.list_branches_async()
19+
```

docs/docs/howto.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,11 @@ expired = repo.expire_snapshots(older_than=expiry_time)
271271
```python
272272
results = repo.garbage_collect(expiry_time)
273273
```
274+
275+
### Usage in async contexts
276+
277+
Most methods in Icechunk have an async counterpart, named with an `_async` postfix. For more info, see [Async Usage](./async.md).
278+
279+
```python
280+
results = await repo.garbage_collect_async(expiry_time)
281+
```

docs/mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ plugins:
157157
# These redirects work with use_directory_urls: true (default)
158158
'icechunk-python/quickstart/index.md': 'quickstart.md'
159159
'icechunk-python/reference/index.md': 'reference.md'
160+
'icechunk-python/async/index.md': 'async.md'
160161
'icechunk-python/configuration/index.md': 'configuration.md'
161162
'icechunk-python/storage/index.md': 'storage.md'
162163
'icechunk-python/version-control/index.md': 'version-control.md'
@@ -214,6 +215,7 @@ nav:
214215
- Xarray: xarray.md
215216
- Tuning Performance: performance.md
216217
- Virtual Datasets: virtual.md
218+
- Async Usage: async.md
217219
- Icechunk for Git Users: icechunk-for-git-users.md
218220
- Creating Icechunk Datasets:
219221
- Global Raster Data cube: ingestion/glad-ingest.ipynb

0 commit comments

Comments
 (0)