#69 - Add Python bindings API reference#104
Conversation
Add docs/api-reference/python.md alongside the existing C++ and YAML references. The page mirrors cpp.md's structure (init → RX 1/2/3 → reorder → TX 1/2/3 → file writes → socket/RDMA → utilities → GIL → function reference → constants/enums/classes) and is derived from the binding surface in python/daqiri_common_pybind.cpp. Wire the new page through mkdocs.yml nav, the README documentation table, the docs/index.html footer, the AGENTS.md doc structure list, and the docs-sync agent rule. Extend scripts/check_doc_refs.py's binary-name regex to also exclude .py filenames so the link to examples/daqiri_bench_raw_tx_rx.py is not mistaken for a missing binary. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Denis Leshchev <dleshchev@nvidia.com>
…Started Update docs/api-reference/index.md so the six-step lifecycle and the "See also" section both point at Python API Usage alongside C++ API Usage, now that the Python page is in the nav. Soften docs/api-reference/python.md "Building and Importing" to defer to Getting Started for the container vs bare-metal choice and only highlight the DAQIRI_BUILD_PYTHON=ON flag, rather than re-inventing build instructions. The container path is the recommended one. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Denis Leshchev <dleshchev@nvidia.com>
|
| Filename | Overview |
|---|---|
| docs/api-reference/python.md | New Python API reference page — well-structured and mirrors cpp.md, but the RDMA snippet at line 406 calls create_tx_burst_params() without a matching free or send, leaking burst metadata. |
| scripts/check_doc_refs.py | Correctly extends BIN_RE negative lookahead to also exclude .py extensions, preventing daqiri_bench_raw_tx_rx.py from being flagged as a missing binary. |
| mkdocs.yml | Adds Python API Usage nav entry alongside C++ API Usage — correct placement and path. |
| .claude/rules/docs-sync.md | Correctly adds python.md to the doc-sync trigger table for common.h, types.h, and the new python/daqiri_common_pybind.cpp and examples/*.py rows. |
| AGENTS.md | Adds python.md to the doc structure list and extends the Public API include drift hotspot — consistent with the rest of the PR. |
| README.md | Adds Python API Usage entry to the Documentation table — correct URL and description. |
| docs/api-reference/index.md | Updates lifecycle description and See Also section to link Python page alongside C++ page — clean wording. |
| docs/index.html | Adds Python API Usage footer link matching the mkdocs nav addition — consistent. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[create_tx_burst_params] --> B[set_header]
B --> C{is_tx_burst_available?}
C -- No --> D[free_tx_metadata]
C -- Yes --> E[get_tx_packet_burst]
E -- FAIL --> F[free_tx_metadata]
E -- SUCCESS --> G[fill packets]
G --> H[send_tx_burst]
H -- FAIL --> I[free_all_packets_and_burst_tx]
H -- SUCCESS --> J[worker thread owns burst]
K[RDMA example gap] -.->|create_tx_burst_params + rdma_set_header only - no send or free shown| A
Reviews (2): Last reviewed commit: "#69 - fixing the TX burst leak in python..." | Re-trigger Greptile
| | `log_level_from_string(str)` / `log_level_to_string(level)` | Convert log levels. | | ||
|
|
||
| ### Burst Metadata and Packet Access | ||
|
|
||
| | Function | Purpose | | ||
| | --- | --- | | ||
| | `create_burst_params()` | Allocate generic burst metadata. | | ||
| | `create_tx_burst_params()` | Allocate TX burst metadata. | | ||
| | `set_header(burst, port, q, num, segs)` | Set burst port, queue, packet count, and segment count. | |
There was a problem hiding this comment.
TX burst leak on
send_tx_burst failure in socket example
send_tx_burst is called without capturing its return value. When get_tx_packet_burst succeeds, packet buffers are allocated from the TX pool. If send_tx_burst subsequently fails, the tx_burst (with those buffers) is never freed — silently draining the TX packet pool until the NIC starts dropping traffic. Per the project's BurstParams zero-copy invariant, every exit path through create_tx_burst_params → get_tx_packet_burst must have a matching free. The corresponding pattern in TX Step 3 (earlier in this same doc) correctly checks the return value; this example should too.
chloecrozier
left a comment
There was a problem hiding this comment.
Ran the three CI scripts locally, all passed:
- mkdocs build --strict
- scripts/check_html_links.py site
- scripts/check_doc_refs.py
Also checked:
- The .py lookahead in check_doc_refs.py is actually needed. python.md links examples/daqiri_bench_raw_tx_rx.py.
- python.md function tables match every m.def, m.attr, py::enum_, and py::class_ in python/daqiri_common_pybind.cpp. GIL section lists every gil_scoped_release site.
- Wiring is in place: mkdocs.yml nav, docs/index.html footer, README.md, AGENTS.md, and .claude/rules/docs-sync.md all point at python.md.
- index.md links python.md from the six-step lifecycle and See Also.
One thing to fix as per greptile:
- python.md line 394 (Socket and RDMA TX snippet): the example calls send_tx_burst without checking the return value, so on a send failure the buffers from get_tx_packet_burst never get freed and eventually drain the TX pool (forcing the need for a manual free). The TX Step 3 example at line 333 already shows the right pattern, copy that check-and-free into this snippet too.
The "RX Reorder Configs (DPDK v1)" heading in configuration.md was shortened to "RX Reorder Configs" in this PR, which renamed its generated anchor. Update the link from python.md (added in #104) so `mkdocs build --strict` passes. Signed-off-by: Chloe Crozier <chloecrozier@gmail.com>
Summary
docs/api-reference/python.mddocumenting the pybind11 bindings: RX/TX workflows mirroringcpp.md's step-by-step structure, reordered RX, file writes, socket/RDMA helpers, GIL behavior, and a full function / enum / class reference derived frompython/daqiri_common_pybind.cpp.mkdocs.ymlnav,README.mddocs table,docs/index.htmlfooter,AGENTS.mddoc structure list, and the docs-sync agent rule.docs/api-reference/index.mdso the six-step lifecycle and the "See also" section link the Python page alongside the C++ page.scripts/check_doc_refs.py's binary-name regex to also exclude.pyso the link toexamples/daqiri_bench_raw_tx_rx.pyis not mistaken for a missing binary.Context
This builds on #94 (already merged), which restructured the API reference under
docs/api-reference/and split it intoindex.md,cpp.md, andconfiguration.md. With this PR landed, the reference covers the three surfaces a user actually touches — C++, Python, and the YAML schema — completing the Python-bindings docs work tracked in #69 and the broader API documentation effort tracked in #9.The Python page deliberately mirrors
cpp.md's section flow (Initialization → Receiving Packets w/ RX 1/2/3 → Reordered RX → Transmitting Packets w/ TX 1/2/3 → Writing Bursts to Storage → Socket and RDMA → Utility Functions → Function Reference) so a reader switching between the two surfaces sees the same shape, with Python-specific additions for GIL behavior and pointer/buffer semantics.Closes #9.
Closes #69.
Test plan
python3 scripts/check_doc_refs.pypassesmkdocs build --strictpasses (no broken links, missing anchors, or unrecognized nav entries)api-reference/python/and visually confirm: TOC renders, code blocks highlight, internal links tocpp.md,configuration.md,../concepts.md(incl.#zero-copy-ownershipand#rx-packet-aggregation-and-reorderanchors) all resolvepython/daqiri_common_pybind.cpp— everym.def/m.attr/py::enum_/py::class_is represented; GIL section lists everypy::gil_scoped_releasesite🤖 Generated with Claude Code