-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start of executable docs #777
Open
ianhi
wants to merge
21
commits into
main
Choose a base branch
from
ian/docs/exec-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+590
−62
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8982b41
doc: initial executeable docs
ianhi eadf070
doc: add permalink anchors
ianhi 2147bf2
doc: executable quickstart
ianhi c94ac6a
remove old docs stuff
ianhi 3066a2c
doc: strict docs build
ianhi 08341c9
doc: add markdown-exec dependency
ianhi f02ee47
doc: readthedocs build rust
ianhi f7a7706
doc: rtd build
ianhi 9513808
doc: rtd build
ianhi d3bb916
doc: rtd build
ianhi 650318e
doc: rtd build
ianhi ada7460
doc: rtd build
ianhi ea09396
doc: rtd build
ianhi 754b466
doc: rtd build
ianhi 3432708
doc: rtd build
ianhi 4385b7b
docs: end of file
ianhi 506ce49
docs: back to snapshot_id
ianhi 27e3e89
docs: add parallel to executed docs
ianhi 1d94464
docs: add xarray to doc req
ianhi 7a9592b
doc: build add pooch
ianhi 26d4c49
doc: build add scipy
ianhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,3 +76,5 @@ ENV/ | |
|
||
# MkDocs documentation | ||
site*/ | ||
|
||
icechunk-local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,16 @@ To get started, let's create a new Icechunk repository. | |
We recommend creating your repo on a cloud storage platform to get the most out of Icechunk's cloud-native design. | ||
However, you can also create a repo on your local filesystem. | ||
|
||
```python exec="on" | ||
# remove local path if it already exists to prevent errors | ||
# this is hidden in the rendered docs | ||
from shutil import rmtree | ||
try: | ||
rmtree("./icechunk-local"); | ||
except FileNotFoundError: | ||
pass | ||
``` | ||
|
||
=== "S3 Storage" | ||
|
||
```python | ||
|
@@ -57,7 +67,7 @@ However, you can also create a repo on your local filesystem. | |
|
||
=== "Local Storage" | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="above" | ||
import icechunk | ||
storage = icechunk.local_filesystem_storage("./icechunk-local") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about storage = icechunk.local_filesystem_storage(tempfile.mkdtemp())) so we don't have to clear the local folder above? |
||
repo = icechunk.Repository.create(storage) | ||
|
@@ -68,13 +78,13 @@ However, you can also create a repo on your local filesystem. | |
Once the repository is created, we can use `Session`s to read and write data. Since there is no data in the repository yet, | ||
let's create a writable session on the default `main` branch. | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="material-block" | ||
session = repo.writable_session("main") | ||
``` | ||
|
||
Now that we have a session, we can access the `IcechunkStore` from it to interact with the underlying data using `zarr`: | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="material-block" | ||
store = session.store # A zarr store | ||
``` | ||
|
||
|
@@ -83,22 +93,23 @@ store = session.store # A zarr store | |
We can now use our Icechunk `store` with Zarr. | ||
Let's first create a group and an array within it. | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="material-block" | ||
import zarr | ||
group = zarr.group(store) | ||
array = group.create("my_array", shape=10, dtype='int32', chunks=(5,)) | ||
``` | ||
|
||
Now let's write some data | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="material-block" | ||
array[:] = 1 | ||
``` | ||
|
||
Now let's commit our update using the session | ||
|
||
```python | ||
session.commit("first commit") | ||
```python exec="on" session="quickstart" source="material-block" | ||
snapshot_id_1 = session.commit("first commit") | ||
print(snapshot_id_1) | ||
``` | ||
|
||
🎉 Congratulations! You just made your first Icechunk snapshot. | ||
|
@@ -111,7 +122,7 @@ session.commit("first commit") | |
|
||
At this point, we have already committed using our session, so we need to get a new session and store to make more changes. | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="material-block" | ||
session_2 = repo.writable_session("main") | ||
store_2 = session_2.store | ||
group = zarr.open_group(store_2) | ||
|
@@ -120,38 +131,33 @@ array = group["my_array"] | |
|
||
Let's now put some new data into our array, overwriting the first five elements. | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="material-block" | ||
array[:5] = 2 | ||
``` | ||
|
||
...and commit the changes | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="material-block" | ||
snapshot_id_2 = session_2.commit("overwrite some values") | ||
``` | ||
|
||
## Explore version history | ||
|
||
We can see the full version history of our repo: | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="material-block" | ||
hist = repo.ancestry(snapshot_id=snapshot_id_2) | ||
for ancestor in hist: | ||
print(ancestor.id, ancestor.message, ancestor.written_at) | ||
|
||
# Output: | ||
# AHC3TSP5ERXKTM4FCB5G overwrite some values 2024-10-14 14:07:27.328429+00:00 | ||
# Q492CAPV7SF3T1BC0AA0 first commit 2024-10-14 14:07:26.152193+00:00 | ||
# T7SMDT9C5DZ8MP83DNM0 Repository initialized 2024-10-14 14:07:22.338529+00:00 | ||
``` | ||
|
||
...and we can go back in time to the earlier version. | ||
|
||
```python | ||
```python exec="on" session="quickstart" source="material-block" | ||
# latest version | ||
assert array[0] == 2 | ||
# check out earlier snapshot | ||
earlier_session = repo.readonly_session(snapshot_id=hist[1].id) | ||
earlier_session = repo.readonly_session(snapshot_id=snapshot_id_1) | ||
store = earlier_session.store | ||
|
||
# get the array | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n", | ||
"# Quickstart\n", | ||
"\n", | ||
"Icechunk is designed to be mostly in the background.\n", | ||
"As a Python user, you'll mostly be interacting with Zarr.\n", | ||
"If you're not familiar with Zarr, you may want to start with the [Zarr Tutorial](https://zarr.readthedocs.io/en/latest/tutorial.html)\n", | ||
"\n", | ||
"## Installation\n", | ||
"\n", | ||
"Icechunk can be installed using pip or conda:\n", | ||
"\n", | ||
"=== \"pip\"\n", | ||
"\n", | ||
" ```bash\n", | ||
" python -m pip install icechunk\n", | ||
" ```\n", | ||
"\n", | ||
"=== \"conda\"\n", | ||
"\n", | ||
" ```bash\n", | ||
" conda install -c conda-forge icechunk\n", | ||
" ```\n", | ||
"\n", | ||
"!!! note\n", | ||
"\n", | ||
" Icechunk is currently designed to support the [Zarr V3 Specification](https://zarr-specs.readthedocs.io/en/latest/v3/core/v3.0.html).\n", | ||
" Using it today requires installing Zarr Python 3.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can directly install from github with pip too if we know the commit ID. example:
This will require maturin in the env, which we seem to have.