Skip to content

Commit 4a43fe8

Browse files
authored
docs: fix stale API references post-redesign merge (#1050)
- SKILL.md: update examples to wrapper API (create_notebook, cell.run, cell.stream, notebook.presence, CellHandle properties) - python-bindings.md: rewrite advanced section to use wrapper API, demote native types to internal subsection - gremlin README: NativeClient → Client (async) - python README: remove deleted demos section
1 parent 612d578 commit 4a43fe8

File tree

4 files changed

+58
-34
lines changed

4 files changed

+58
-34
lines changed

.claude/skills/python-bindings/SKILL.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import runtimed
4242

4343
async def main():
4444
client = runtimed.Client()
45-
async with await client.create() as notebook:
45+
async with await client.create_notebook() as notebook:
4646
cell = await notebook.cells.create("print('hello')")
4747
result = await cell.run()
4848
print(result.stdout) # "hello\n"
@@ -51,15 +51,27 @@ async def main():
5151
print(cell.source) # "print('hello')"
5252
print(cell.cell_type) # "code"
5353

54+
# Streaming execution (async iterator)
55+
cell2 = await notebook.cells.create("for i in range(3): print(i)")
56+
async for event in await cell2.stream():
57+
print(event)
58+
59+
# Presence (cursor/selection sync)
60+
await notebook.presence.set_cursor(cell.id, line=0, column=5)
61+
5462
asyncio.run(main())
5563
```
5664

57-
For the native session API (streaming, presence, metadata), use `NativeAsyncClient`:
65+
Other `Client` entry points:
5866

5967
```python
60-
native_client = runtimed.NativeAsyncClient()
61-
session = await native_client.create_notebook()
62-
result = await session.run("print('hello')")
68+
notebook = await client.open_notebook("/path/to/notebook.ipynb")
69+
notebook = await client.join_notebook(notebook_id)
70+
71+
# List active notebooks
72+
infos = await client.list_active_notebooks() # list[NotebookInfo]
73+
for info in infos:
74+
print(info.runtime_type, info.status, info.has_runtime)
6375
```
6476

6577
## Output.data Typing
@@ -82,23 +94,31 @@ When an output contains a binary image MIME type, the daemon synthesizes a `text
8294
The `Notebook.cells` collection provides sync reads and async writes:
8395

8496
```python
85-
# Sync reads from local CRDT
97+
# Sync reads from local CRDT via CellHandle properties
8698
cell = notebook.cells.get_by_index(0)
8799
print(cell.source, cell.cell_type, cell.outputs)
100+
print(cell.tags, cell.source_hidden, cell.outputs_hidden)
88101

89102
# Search
90103
matches = notebook.cells.find("import")
91104

92-
# Runtime state
93-
print(notebook.runtime.kernel.status) # sync read
94-
```
105+
# Iterate all cells
106+
for cell in notebook.cells:
107+
print(cell.id, cell.source[:40])
95108

96-
For the native session API, per-cell accessors are also available:
109+
# Async mutations on CellHandle
110+
await cell.set_source("new code")
111+
await cell.splice(0, 0, "# inserted at top\n")
112+
await cell.set_tags(["parameters"])
113+
await cell.set_source_hidden(True)
114+
await cell.clear_outputs()
115+
await cell.delete()
97116

98-
```python
99-
source = session.get_cell_source(cell_id) # just the source string
100-
cell_type = session.get_cell_type(cell_id) # "code" | "markdown" | "raw"
101-
cell_ids = session.get_cell_ids() # position-sorted IDs
117+
# Runtime state (sync read)
118+
print(notebook.runtime)
119+
120+
# Connected peers
121+
print(notebook.peers) # list of (peer_id, peer_label)
102122
```
103123

104124
## Socket Path Configuration
@@ -152,7 +172,7 @@ Three packages are workspace members:
152172

153173
### Wrong daemon
154174

155-
If `notebook.run()` returns `Output(stream, stderr: "Failed to parse output: <hash>")`, the bindings are connecting to the wrong daemon. The blob store is per-daemon. Set `RUNTIMED_SOCKET_PATH` to the correct daemon socket.
175+
If `cell.run()` returns `Output(stream, stderr: "Failed to parse output: <hash>")`, the bindings are connecting to the wrong daemon. The blob store is per-daemon. Set `RUNTIMED_SOCKET_PATH` to the correct daemon socket.
156176

157177
### Empty outputs from cell.outputs
158178

docs/python-bindings.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,30 +260,41 @@ async def multi_client_demo():
260260
print(result.stdout) # "42\n" — shared kernel state
261261
```
262262

263-
## Advanced: Native Session API
263+
## Streaming Execution & Presence
264264

265-
For power users who need direct access to the low-level session methods (streaming execution, presence, cell metadata, dependencies), use `NativeAsyncClient` and `AsyncSession`:
265+
The wrapper API covers streaming execution, presence, and all other
266+
session-level features — no need to drop down to native types:
266267

267268
```python
268-
native_client = runtimed.NativeAsyncClient()
269-
session = await native_client.create_notebook()
269+
client = runtimed.Client()
270+
nb = await client.create_notebook()
271+
await nb.start()
270272

271-
# Full session API available
272-
cell_id = await session.create_cell("print('hello')")
273-
result = await session.execute_cell(cell_id)
273+
cell = await nb.cells.create("print('hello')")
274274

275275
# Streaming execution
276-
async for event in await session.stream_execute(cell_id):
276+
async for event in await cell.stream():
277277
if event.event_type == "output":
278278
print(event.output.text)
279279

280280
# Presence
281-
await session.set_cursor(cell_id, line=0, column=5)
282-
peers = await session.get_peers()
281+
await nb.presence.set_cursor(cell.id, line=0, column=5)
282+
peers = nb.peers # sync read — list of (peer_id, label) tuples
283283

284-
await session.close()
284+
await nb.close()
285285
```
286286

287+
### Internal: Native Session API
288+
289+
> **Note:** `NativeAsyncClient` and `AsyncSession` are internal types not
290+
> included in the public `__all__`. The wrapper API above covers their
291+
> functionality. If you genuinely need the raw session (e.g. for methods
292+
> not yet wrapped), import them explicitly:
293+
>
294+
> ```python
295+
> from runtimed.runtimed import NativeAsyncClient, AsyncSession
296+
> ```
297+
287298
## Error Handling
288299
289300
All errors raise `RuntimedError`:

python/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ For Zed MCP config:
5858
}
5959
```
6060

61-
## Running Demos
62-
63-
```bash
64-
# From the repo root
65-
RUNTIMED_SOCKET_PATH=... uv run python python/runtimed/demos/presence_cursor.py <notebook_id>
66-
```
67-
6861
## Rebuilding After Rust Changes
6962

7063
If you change code in `crates/runtimed-py/` or `crates/runtimed/`:

python/gremlin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ uv run python -m gremlin <notebook_id>
4444

4545
```bash
4646
# List active notebooks via the daemon
47-
uv run python -c "import runtimed; print(runtimed.NativeClient().list_active_notebooks())"
47+
uv run python -c "import asyncio, runtimed; client = runtimed.Client(); print(asyncio.run(client.list_active_notebooks()))"
4848
```
4949

5050
## Requirements

0 commit comments

Comments
 (0)