-
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
base: main
Are you sure you want to change the base?
Conversation
ff2f51e
to
08341c9
Compare
Ahh annoyingly this requires readthedocs to know how to install the dev version of icechunk, otherwise it won't be able to properly execute the docs. may take some figuring out to make that happen in readthedocs with poetry etc |
@@ -14,7 +15,11 @@ build: | |||
- poetry config virtualenvs.create false | |||
post_install: | |||
# Install deps and build using poetry | |||
- . "$READTHEDOCS_VIRTUALENV_PATH/bin/activate" && cd docs && poetry install | |||
- . "$READTHEDOCS_VIRTUALENV_PATH/bin/activate" && cd docs && poetry install && cd ../icechunk-python && maturin develop && cd ../docs |
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:
pip install git+https://github.com/earth-mover/icechunk.git@COMMIT#subdirectory=icechunk-python
This will require maturin in the env, which we seem to have.
With the current strategy we need an upstream change before this works. I put in a PR: pawamoy/markdown-exec#80 otherwise can't finish the version control page which has codeblocks that intentional raise execeptions. |
Can we skip this one for now and continue with the rest? |
26d4c49
to
ea18b8b
Compare
sure |
ea18b8b
to
4c6966a
Compare
docs/docs/icechunk-python/dask.md
Outdated
# Assuming you have a valid writable Session named icechunk_session | ||
dataset = xr.tutorial.open_dataset("rasm", chunks={"time": 1}).isel(time=slice(24)) | ||
with icechunk_session.allow_pickling(): |
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.
this should only be needed for the read down below.
for snapshot in repo.ancestry(branch="main"): | ||
print(snapshot) |
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.
for snapshot in repo.ancestry(branch="main"): | |
print(snapshot) | |
print(list(repo.ancestry(branch="main")) |
perhaps?
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.
|
||
```mermaid | ||
```python exec="on" result="mermaid" session="version" | ||
main_commits = [s.id[:6] for s in list(repo.ancestry(branch='main'))] |
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've wanted a method to do this for quite long!
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.
You mean creating the mermaid diagram from python? it would be amazing if it could just auto generate the tree for you in a notebook. Would just have to bundle mermaid.js
First let's start a distributed Client and create an IcechunkStore. | ||
|
||
```python | ||
# initialize a distributed Client | ||
from distributed import Client | ||
|
||
client = Client() | ||
|
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.
noteable change here is that the first example doesn't use a client, because it was not working without allow_pickling
so i only used the client after that was described
|
||
icechunk.xarray.to_icechunk(dataset, session) | ||
# `to_icechunk` takes care of "allow_pickling" for you | ||
icechunk.xarray.to_icechunk(dataset, icechunk_session, mode="w") |
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.
had to add the mode to avoid an error.
```python | ||
session = repo.readonly_session(snapshot_id="BSHY7B1AGAPWQC14Q18G") | ||
```python exec="on" session="version" source="material-block" result="code" | ||
session = repo.readonly_session(snapshot_id=list(repo.ancestry(branch="main"))[1].id) |
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.
Is there a nicer way to get the second to last commit? equivalent to HEAD~1
?
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.
next(next(repo.ancestry(branch="main")))
?
- toc: | ||
permalink: "#" |
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.
Also added permalinks that show up when you hover. unrelated to executable changes
@@ -59,9 +59,9 @@ def write_timestamp(*, itime: int, session: Session) -> None: | |||
|
|||
Now execute the writes. | |||
|
|||
```python exec="on" session="parallel" source="material-block" result="code" | |||
<!-- ```python exec="on" session="parallel" source="material-block" result="code" --> | |||
```python |
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.
this example runs fine for me locally, but ends up not writing anything to store when running on readthedocs.
By making docs executable we will be able to automatically pick up errors. Currently I'm doing this using
markdown-exec
because that was the only way to integrate into the existing markdown docs while also preserving the tabbing that exists in several pages. This has the downside of currently being a bit verbose in adding to the start of each executable codeblock. However I think this is fixable with some issues I've opened upstream (pawamoy/markdown-exec#77, pawamoy/markdown-exec#76 (comment)). There are two alternatives:mkdocs-jupyter
Woudl allow for writing documentation in jupyter notebooks. however, we would lose some of the pymdownx extensions (e.g. tabbing)
Have doc build fail on unexpected error:
markdown-exec currently warns on an unexpected error. We can make the docs fail by passing
--strict
tomkdocs build
(pawamoy/markdown-exec#75)Alternatively
mkdocs-jupyter
provides this already, or we can achieve the same with myst/jupyterbook