Skip to content

#69 - Add Python bindings API reference#104

Merged
dleshchev merged 3 commits into
mainfrom
docs/python-bindings-api-reference
Jun 2, 2026
Merged

#69 - Add Python bindings API reference#104
dleshchev merged 3 commits into
mainfrom
docs/python-bindings-api-reference

Conversation

@dleshchev
Copy link
Copy Markdown
Collaborator

Summary

  • Adds docs/api-reference/python.md documenting the pybind11 bindings: RX/TX workflows mirroring cpp.md's step-by-step structure, reordered RX, file writes, socket/RDMA helpers, GIL behavior, and a full function / enum / class reference derived from python/daqiri_common_pybind.cpp.
  • Wires the new page through mkdocs.yml nav, README.md docs table, docs/index.html footer, AGENTS.md doc structure list, and the docs-sync agent rule.
  • Updates docs/api-reference/index.md so the six-step lifecycle and the "See also" section link the Python page alongside the C++ page.
  • Extends scripts/check_doc_refs.py's binary-name regex to also exclude .py so the link to examples/daqiri_bench_raw_tx_rx.py is 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 into index.md, cpp.md, and configuration.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.py passes
  • mkdocs build --strict passes (no broken links, missing anchors, or unrecognized nav entries)
  • Browse to api-reference/python/ and visually confirm: TOC renders, code blocks highlight, internal links to cpp.md, configuration.md, ../concepts.md (incl. #zero-copy-ownership and #rx-packet-aggregation-and-reorder anchors) all resolve
  • Spot-check the function-reference tables against python/daqiri_common_pybind.cpp — every m.def/m.attr/py::enum_/py::class_ is represented; GIL section lists every py::gil_scoped_release site

🤖 Generated with Claude Code

dleshchev and others added 2 commits May 28, 2026 15:19
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>
@dleshchev dleshchev requested review from RamyaGuru and chloecrozier and removed request for RamyaGuru May 28, 2026 16:39
@dleshchev dleshchev marked this pull request as ready for review May 28, 2026 16:48
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 28, 2026

Greptile Summary

Adds docs/api-reference/python.md, a comprehensive Python bindings reference mirroring cpp.md's structure, and wires it into mkdocs.yml, README.md, docs/index.html, AGENTS.md, and the docs-sync agent rule. The check_doc_refs.py binary-name regex is also extended to exclude .py filenames.

  • New Python API page — covers initialization, RX/TX workflows, reordered bursts, file writes, socket/RDMA helpers, GIL behavior, and a full function/enum/class reference derived from python/daqiri_common_pybind.cpp.
  • RDMA snippet leaks burst metadata — the RDMA example calls create_tx_burst_params() but ends without a send_tx_burst or free_tx_metadata call; the head commit claims to fix both socket and RDMA burst leaks but only addressed the socket side.
  • HEAD commit missing DCO sign-off — commit 18b702d has no Signed-off-by: trailer; the two earlier commits in this PR are correctly signed.

Confidence Score: 3/5

Two issues need fixing before merge: the RDMA documentation example leaks burst metadata, and the HEAD commit is missing its DCO sign-off trailer.

The RDMA code snippet in the new Python reference page calls create_tx_burst_params() but never reaches a send_tx_burst or free_tx_metadata call. Users following this example will drain the TX metadata pool in the same silent way the custom rules warn about. Additionally, the HEAD commit (18b702d) has no Signed-off-by: trailer, which blocks merge under the project's DCO policy.

docs/api-reference/python.md — RDMA snippet at line 406 needs a matching free or a complete send/free path to close the burst lifecycle.

Important Files Changed

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
Loading

Reviews (2): Last reviewed commit: "#69 - fixing the TX burst leak in python..." | Re-trigger Greptile

Comment on lines +490 to +498
| `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. |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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_paramsget_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.

Copy link
Copy Markdown
Member

@chloecrozier chloecrozier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dleshchev dleshchev merged commit fcec2dd into main Jun 2, 2026
3 checks passed
chloecrozier added a commit that referenced this pull request Jun 3, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DOC] Add API documentation for Python bindings [DOC] Add DAQIRI API Documentation

2 participants