Skip to content

Commit 5b6d3e0

Browse files
authored
docs: improve Getting Started — fix root README example, expand python-async README, document dora run vs dora start (#1576)
## What this fixes ### Root `README.md` - The "Run" section described a YOLO/webcam example but pointed to `examples/python-dataflow/dataflow.yml`, which is actually the `sender → transformer → receiver` pipeline — not a YOLO pipeline and no webcam required. - Corrected the shown YAML to match the actual file. - Removed the misleading `> Make sure to have a webcam` note. - Added a `dora run` vs `dora start` comparison table (sourced from code comments in `binaries/cli/src/command/run.rs` and `start/mod.rs`). ### `examples/python-async/README.md` - Was 4 lines with no explanation of what the example demonstrates or what "async" means in this context. - Rewrote to include: node descriptions, ASCII dataflow diagram, sync vs async API comparison table, and expected output. ## Why Both files were entry points for new users. The root README mismatch (YOLO description + non-YOLO URL) would cause confusion on first run. The `python-async` README gave no signal to readers about when or why to use the async API. ## Testing - Verified YAML structure against `examples/python-dataflow/dataflow.yml` directly. - Verified `dora run` vs `dora start` distinction against source in `binaries/cli/src/command/run.rs` (lines 1–6) and `start/mod.rs` (lines 1–3). - Verified `python-async` node behaviour by reading `send_data.py` and `receive_data.py`.
2 parents bd9667d + fd8d78b commit 5b6d3e0

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

examples/python-async/README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,58 @@
11
# Python Async Example
22

3-
To get started:
3+
This example shows how to use Python's `asyncio` with dora nodes. Instead of the
4+
blocking synchronous API (`for event in node:` or `node.next()`), nodes can use
5+
`await node.recv_async()` to receive events without blocking the thread — allowing
6+
other coroutines to run concurrently.
7+
8+
Use the async API when your node needs to integrate with async frameworks (e.g.
9+
`asyncio`, web servers, async I/O libraries).
10+
11+
## Overview
12+
13+
The [`dataflow.yaml`](./dataflow.yaml) defines two nodes:
14+
15+
- **send_data** — triggered every 10ms by a built-in dora timer, sends the current
16+
timestamp (nanoseconds, `uint64`) as output `data`. Stops after 100 sends.
17+
- **receive_data_with_sleep** — receives each timestamp using `await node.recv_async()`
18+
inside an `asyncio` event loop. Processes 50 events, then prints `done!` and exits.
19+
20+
```
21+
dora/timer/millis/10 ──► send_data ──► receive_data_with_sleep
22+
```
23+
24+
### Sync vs async API
25+
26+
| | Sync | Async |
27+
|---|---|---|
28+
| Receive next event | `for event in node:` or `node.next()` | `await node.recv_async()` |
29+
| Thread behaviour | Blocks until event arrives | Yields to event loop while waiting |
30+
| Use when | Simple scripts | Integrating with asyncio / async frameworks |
31+
32+
## Getting started
33+
34+
Install dependencies and build the dataflow:
435

536
```bash
37+
cd examples/python-async
638
uv venv --seed -p 3.11
739
uv pip install -e ../../apis/python/node
840
dora build dataflow.yaml --uv
41+
```
42+
43+
Run the dataflow:
44+
45+
```bash
946
dora run dataflow.yaml --uv
1047
```
48+
49+
## Expected output
50+
51+
The `receive_data_with_sleep` node prints a single line after processing 50 events:
52+
53+
```
54+
done!
55+
```
56+
57+
No output is produced by `send_data` — it sends timestamps silently and exits after
58+
100 sends.

0 commit comments

Comments
 (0)