Skip to content

docs: flush subscribers before deregister in package README examples#201

Merged
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
zhongxuanwang-nv:docs/readme-subscriber-flush
Jun 2, 2026
Merged

docs: flush subscribers before deregister in package README examples#201
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
zhongxuanwang-nv:docs/readme-subscriber-flush

Conversation

@zhongxuanwang-nv
Copy link
Copy Markdown
Member

@zhongxuanwang-nv zhongxuanwang-nv commented Jun 2, 2026

Overview

The package READMEs' "Getting Started" examples register a subscriber, emit events, then deregister without calling flush. Native subscriber delivery is non-blocking, so an example that exits right after deregistering can lose queued events. This updates all four package READMEs to flush before deregister, matching the quickstarts (which already flush).

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

Functional fixes (verified by running — the example dropped events without flush):

  • python/nemo_relay/README.md: printed nothing, or intermittently a single partial line; the to_dict() / to_json() callback never ran. Adds nemo_relay.subscribers.flush() before each deregister(...).
  • go/nemo_relay/README.md: flaky — dropped the trailing tool-end and scope-end events on exit (2 of 3 runs partial). Adds defer nemo.FlushSubscribers(), ordered to run after the deferred scope.Pop emits the scope-end event and before the deferred deregister.

Parity (not currently broken; updated so every README models the same pattern):

  • crates/node/README.md: Node keeps the event loop alive via the ref'd ThreadsafeFunction, so it already delivers; adds flushSubscribers() for consistency.
  • crates/wasm/README.md: WASM's flushSubscribers() is a single-threaded no-op (tested as such); adds it for consistency.

Where should the reviewer start?

The four README diffs — each adds a flush before deregister(...) (Node/WASM also import flushSubscribers). Verified by running each example with the flush added: events deliver deterministically (Go 5/5, Python and Node 3/3 across repeated runs). WASM's flushSubscribers is an exported no-op (crates/wasm/src/api/mod.rs; covered by crates/wasm/tests-js/scope_tests.mjs).

Note: the crates/node/README.md example also depends on the Node binding change in #196 (pass a real ScopeHandle to withScope callbacks). That is orthogonal to this flush change — #196 is code-only and does not touch the README.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Summary by CodeRabbit

  • Documentation
    • Updated Getting Started examples across Python, Node.js, WebAssembly, and Go language bindings to reflect the proper sequence for flushing subscribers before deregistration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: acd532a5-3ef2-4739-9fc1-feccb7b4fd48

📥 Commits

Reviewing files that changed from the base of the PR and between 8ce4a66 and 5458193.

📒 Files selected for processing (4)
  • crates/node/README.md
  • crates/wasm/README.md
  • go/nemo_relay/README.md
  • python/nemo_relay/README.md
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (17)
**/*.{md,rst,html,txt}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)

**/*.{md,rst,html,txt}: Always spell NVIDIA in all caps. Do not use Nvidia, nvidia, nVidia, nVIDIA, or NV.
Use an NVIDIA before a noun because the name starts with an 'en' sound.
Do not add a registered trademark symbol after NVIDIA when referring to the company.
Use trademark symbols with product names only when the document type or legal guidance requires them.
Verify official capitalization, spacing, and hyphenation for product names.
Precede NVIDIA product names with NVIDIA on first mention when it is natural and accurate.
Do not rewrite product names for grammar or title-case rules.
Preserve third-party product names according to the owner's spelling.
Include the company name and full model qualifier on first use when it helps identify the model.
Preserve the official capitalization and punctuation of model names.
Use shorter family names only after the full name is established.
Spell out a term on first use and put the acronym in parentheses unless the acronym is widely understood by the intended audience.
Use the acronym on later mentions after it has been defined.
For long documents, reintroduce the full term if readers might lose context.
Form plurals of acronyms with s, not an apostrophe, such as GPUs.
In headings, common acronyms can remain abbreviated. Spell out the term in the first or second sentence of the body.
Common terms such as CPU, GPU, PC, API, and UI usually do not need to be spelled out for developer audiences.

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
**/*.{md,rst,html}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)

Link the first mention of a product name when the destination helps the reader.

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
**/*.md

📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

Documentation must be updated if activation or usage changed

**/*.md: Use title case consistently in technical documentation headings
Avoid quotation marks, ampersands, and exclamation marks in headings
Keep product, event, research, and whitepaper names in their official title case
Use title case for table headers
Do not force social-media sentence case into technical docs
Format code elements, commands, parameters, package names, and expressions in monospace
Format directories, file names, and paths in monospace using backticks
Use angle brackets inside monospace for variables inside paths, such as /home/<username>/.login
Format error messages and strings in quotation marks, keeping literal code strings in code formatting when clearer
Format UI buttons, menus, fields, and labels in bold
Use angle brackets between UI labels for menu paths, such as File > Save As
Use italics for new terms on first use, sparingly and only when introducing the term
Use italics for publication titles
Format keyboard shortcuts in plain text, such as Press Ctrl+Alt+Delete
Use owner/repo link text for GitHub repositories, preferring [NVIDIA/NeMo](link) over prose references like 'the GitHub repo'
Introduce every code block with a complete sentence
Do not make a code block complete the grammar of the previous sentence
Do not continue a sentence after a code block
Use syntax highlighting when the format supports it for code blocks
Avoid the word 'snippet' unless the surrounding docs already use it as a term of art
Keep inline method, function, and class references consistent with nearby docs, omitting empty parentheses for prose readability when no call is shown
Use descriptive anchor text that matches the destination title when possible for links
Avoid raw URLs in running text
Avoid generic anchor text such as 'here,' 'this page,' and 'read more'
Include acronyms in link text when a linked term includes an acronym
Do not link long sentences or multiple sentences
Avoid links ...

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
**/{docs,examples,**/*.md,*.patch,*.diff,.github,*.sh,*.yaml,*.yml}

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update documentation, examples, CI configuration, and patch artifacts when performing rename operations

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
**/*.{md,rst,txt}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)

Spell NVIDIA in all caps. Do not use Nvidia, nvidia, or NV.

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
**/*.{md,rst}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)

**/*.{md,rst}: Format commands, code elements, expressions, package names, file names, and paths as inline code.
Use descriptive link text. Avoid raw URLs and weak anchors such as "here" or "read more."
Use title case consistently for technical documentation headings.
Introduce code blocks, lists, tables, and images with complete sentences.
Write procedures as imperative steps. Keep steps parallel and split long procedures into smaller tasks.
Prefer active voice, present tense, short sentences, contractions, and plain English.
Use can for possibility and reserve may for permission.
Use after for temporal relationships instead of once.
Prefer refer to over see when the wording points readers to another resource.
Avoid culture-specific idioms, unnecessary Latinisms, jokes, and marketing exaggeration in technical docs.
Spell out months in body text, avoid ordinal dates, and use clear time zones.
Spell out whole numbers from zero through nine unless they are technical values, parameters, versions, or UI values.
Use numerals for 10 or greater and include commas in thousands.
Do not add trademark symbols to learning-oriented docs unless the source, platform, or legal guidance explicitly requires them.

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
{docs/**,README.md,CONTRIBUTING.md,**/*.md}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Run docs link validation with just docs-linkcheck when links change

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
{docs/**,README.md,**/Cargo.toml,**/package.json,**/*.md}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Ensure renamed public surfaces are reflected consistently in manifests and docs for large or public-facing changes

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
**/*.{md,mdx,py,sh,yaml,yml,toml,json}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Keep package names, repo references, and build commands current

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
**/*.{html,md,mdx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Include SPDX license header in HTML and Markdown files using HTML comment syntax

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
**/README.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update relevant crate or package README when that surface changed

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}

📄 CodeRabbit inference engine (AGENTS.md)

Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.

Files:

  • python/nemo_relay/README.md
  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
python/nemo_relay/**/*

⚙️ CodeRabbit configuration file

python/nemo_relay/**/*: Review Python wrapper changes for typed API consistency, contextvars-based scope isolation, async behavior, and parity with the native extension.
Stubs and runtime implementations should stay aligned.

Files:

  • python/nemo_relay/README.md
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}

📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)

{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}: Maintain consistent plugin lifecycle across all language bindings (Python, Go, Node/WebAssembly, and Rust)
Keep plugin context surfaces aligned across all language implementations

Files:

  • go/nemo_relay/README.md
  • crates/node/README.md
  • crates/wasm/README.md
go/nemo_relay/**/*

⚙️ CodeRabbit configuration file

go/nemo_relay/**/*: Review Go binding changes for cgo memory ownership, race safety, callback cleanup, idiomatic exported APIs, and parity with Rust/FFI behavior.
Any API change should include focused Go tests and consider race-test behavior.

Files:

  • go/nemo_relay/README.md
{crates/adaptive/**,python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,go/nemo_relay/!(adaptive)/**,**/node/**,**/wasm/**}

📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)

Keep adaptive surface in sync across crates/adaptive, shared plugin behavior in core and bindings, Python adaptive/plugin wrappers in python/nemo_relay/adaptive.py and python/nemo_relay/plugin.py, Go adaptive helpers under go/nemo_relay/adaptive plus shared plugin helpers in go/nemo_relay, and Node/WebAssembly adaptive helpers and plugin wrappers

Files:

  • crates/node/README.md
  • crates/wasm/README.md
crates/{python,ffi,node,wasm}/**/*

⚙️ CodeRabbit configuration file

crates/{python,ffi,node,wasm}/**/*: Treat binding changes as public API changes. Check for parity with the other language bindings, FFI ownership/lifetime safety,
callback error propagation, stable type conversion, and consistent async/stream semantics.
Flag changes that update one binding without corresponding tests or documentation for the same surface elsewhere.

Files:

  • crates/node/README.md
  • crates/wasm/README.md
🔇 Additional comments (7)
python/nemo_relay/README.md (2)

145-150: LGTM!


171-171: LGTM!

crates/node/README.md (2)

69-69: LGTM!


84-84: LGTM!

crates/wasm/README.md (2)

86-86: LGTM!


101-101: LGTM!

go/nemo_relay/README.md (1)

103-103: LGTM!


Walkthrough

README examples for Python, Node, WASM, and Go were updated to call the appropriate subscriber flush helper before deregistration; Python’s first example also adds explanatory text about asynchronous native subscriber delivery.

Changes

Getting Started example updates

Layer / File(s) Summary
Python examples
python/nemo_relay/README.md
Inserted nemo_relay.subscribers.flush() before deregister("printer") with explanatory prose and added flush() in the host-integration example's finally block before deregister("host-exporter").
Node.js example
crates/node/README.md
Added flushSubscribers to the destructured import and called flushSubscribers(); in main() before deregisterSubscriber(...).
WASM example
crates/wasm/README.md
Added flushSubscribers to the import destructuring and invoked flushSubscribers(); before deregisterSubscriber(...) in the example.
Go example
go/nemo_relay/README.md
Deferred nemo.FlushSubscribers() after registering a subscriber to flush events during shutdown.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title follows Conventional Commits format with 'docs' type and concise imperative summary under 72 characters, accurately reflecting the documentation updates across all four package READMEs.
Description check ✅ Passed Description includes all required template sections with detailed context, specific file changes, verification details, and proper issue references, enabling reviewers to understand the functional and parity fixes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size:XS PR is extra small Documentation documentation-related labels Jun 2, 2026
@zhongxuanwang-nv zhongxuanwang-nv self-assigned this Jun 2, 2026
@zhongxuanwang-nv zhongxuanwang-nv marked this pull request as ready for review June 2, 2026 20:04
@zhongxuanwang-nv zhongxuanwang-nv requested a review from a team as a code owner June 2, 2026 20:04
@zhongxuanwang-nv zhongxuanwang-nv marked this pull request as draft June 2, 2026 20:04
@zhongxuanwang-nv
Copy link
Copy Markdown
Member Author

zhongxuanwang-nv commented Jun 2, 2026

I'm sorry about putting this PR ready and then immediately removing this PR's ready status...

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

The package READMEs' "Getting Started" examples register a subscriber, emit
events, then deregister without calling flush. Native subscriber delivery is
non-blocking (a background dispatcher), so examples that exit right after
deregistering can lose queued events:

- Python (`python/nemo_relay/README.md`): printed nothing, or intermittently a
  single partial line; the `to_dict()` / `to_json()` callback never ran.
- Go (`go/nemo_relay/README.md`): flaky -- dropped the trailing tool-end and
  scope-end events on exit (verified: 2 of 3 runs were partial).

Node and WASM are not currently broken (Node keeps the event loop alive via the
ref'd ThreadsafeFunction until delivery; WASM's flush is a single-threaded
no-op), but their READMEs are updated for parity so every package README models
the same flush-before-deregister pattern the quickstarts already use.

- Python / Node / WASM: call `flushSubscribers()` (`subscribers.flush()` in
  Python) before `deregister(...)`.
- Go: `defer nemo.FlushSubscribers()`, ordered so it runs after the deferred
  `scope.Pop` emits the scope-end event and before the deferred deregister.

Verified by running each example: with the flush, all events are delivered
deterministically (Go 5/5, Python and Node 3/3 across repeated runs).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
@zhongxuanwang-nv zhongxuanwang-nv force-pushed the docs/readme-subscriber-flush branch from 8ce4a66 to 5458193 Compare June 2, 2026 20:55
@zhongxuanwang-nv zhongxuanwang-nv changed the title docs: flush subscribers before deregister in Python README examples docs: flush subscribers before deregister in package README examples Jun 2, 2026
@zhongxuanwang-nv zhongxuanwang-nv marked this pull request as ready for review June 2, 2026 21:02
@willkill07
Copy link
Copy Markdown
Member

/merge

@rapids-bot rapids-bot Bot merged commit 804661a into NVIDIA:main Jun 2, 2026
27 checks passed
yczhang-nv pushed a commit to yczhang-nv/NeMo-Flow that referenced this pull request Jun 3, 2026
…VIDIA#201)

#### Overview

The package READMEs' "Getting Started" examples register a subscriber, emit events, then deregister without calling flush. Native subscriber delivery is non-blocking, so an example that exits right after deregistering can lose queued events. This updates all four package READMEs to flush before deregister, matching the quickstarts (which already flush).

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

**Functional fixes** (verified by running — the example dropped events without flush):
- `python/nemo_relay/README.md`: printed nothing, or intermittently a single partial line; the `to_dict()` / `to_json()` callback never ran. Adds `nemo_relay.subscribers.flush()` before each `deregister(...)`.
- `go/nemo_relay/README.md`: flaky — dropped the trailing tool-end and scope-end events on exit (2 of 3 runs partial). Adds `defer nemo.FlushSubscribers()`, ordered to run after the deferred `scope.Pop` emits the scope-end event and before the deferred deregister.

**Parity** (not currently broken; updated so every README models the same pattern):
- `crates/node/README.md`: Node keeps the event loop alive via the ref'd ThreadsafeFunction, so it already delivers; adds `flushSubscribers()` for consistency.
- `crates/wasm/README.md`: WASM's `flushSubscribers()` is a single-threaded no-op (tested as such); adds it for consistency.

#### Where should the reviewer start?

The four README diffs — each adds a flush before `deregister(...)` (Node/WASM also import `flushSubscribers`). Verified by running each example with the flush added: events deliver deterministically (Go 5/5, Python and Node 3/3 across repeated runs). WASM's `flushSubscribers` is an exported no-op (`crates/wasm/src/api/mod.rs`; covered by `crates/wasm/tests-js/scope_tests.mjs`).

Note: the `crates/node/README.md` example also depends on the Node binding change in NVIDIA#196 (pass a real `ScopeHandle` to `withScope` callbacks). That is orthogonal to this flush change — NVIDIA#196 is code-only and does not touch the README.

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Relates to: NVIDIA#196 (Node `withScope` ScopeHandle; orthogonal, touches the same Node README example)

## Summary by CodeRabbit

* **Documentation**
  * Updated Getting Started examples across Python, Node.js, WebAssembly, and Go language bindings to reflect the proper sequence for flushing subscribers before deregistration.

Authors:
  - Zhongxuan (Daniel) Wang (https://github.com/zhongxuanwang-nv)

Approvers:
  - Will Killian (https://github.com/willkill07)

URL: NVIDIA#201
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation documentation-related size:XS PR is extra small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants