Skip to content

Conversation

@biswapanda
Copy link
Contributor

@biswapanda biswapanda commented Aug 21, 2025

Overview:

Prevent crashloops in helloworld k8s example

nvbug: https://nvbugspro.nvidia.com/bug/5471412
closes: DYN-926

Details:

Where should the reviewer start?

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

  • closes GitHub issue: #xxx

Summary by CodeRabbit

  • New Features
    • The hello_world example now continuously issues streaming requests at 1-second intervals, labeling each request sequentially and printing all streamed responses.
  • Documentation
    • Updated the example to demonstrate repeated, tagged streaming requests instead of a single run, helping users see continuous streaming behavior in practice.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Aug 21, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions bot added the fix label Aug 21, 2025
@biswapanda biswapanda self-assigned this Aug 21, 2025
@biswapanda biswapanda force-pushed the bis/dyn-926-hello-world-example-is-crash-looping branch from b2f76b8 to d65ae5f Compare August 21, 2025 22:33
@biswapanda
Copy link
Contributor Author

/ok to test d65ae5f

Copy link
Contributor

@nealvaidya nealvaidya left a comment

Choose a reason for hiding this comment

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

LGTM. In future we can replace client with an http listener

@biswapanda
Copy link
Contributor Author

LGTM. In future we can replace client with an http listener

yeah a simple fastapi service would be better. this is just a quick fix for now

@biswapanda biswapanda requested a review from atchernych August 21, 2025 22:36
@biswapanda biswapanda enabled auto-merge (squash) August 21, 2025 22:39
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

Walkthrough

The example client now runs an infinite loop issuing successive streaming requests. Each iteration increments an index embedded in the query string, opens a new stream, prints all received data chunks, then sleeps for one second before repeating. Previously, it performed a single streaming generate call.

Changes

Cohort / File(s) Summary
Hello world runtime example behavior
examples/runtime/hello_world/client.py
Replace single streaming call with an infinite loop: build f"Query[{idx}] world,sun,moon,star", open stream per iteration, print response.data(), then sleep(1).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Client
  participant Runtime as Runtime Service
  loop Repeat every 1s
    rect rgba(200,230,255,0.25)
      Note over Client: Build request with incremented idx
      Client->>Runtime: Open streaming request "Query[idx] world,sun,moon,star"
      activate Runtime
      Runtime-->>Client: Stream chunk(s)
      Runtime-->>Client: [end of stream]
      deactivate Runtime
      Note over Client: Print all received data
    end
    Client->>Client: sleep(1s)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I tap my paws and set the loop,
Query by query, a hopping troupe.
Stars and moons stream nibble-bright,
I print each crumb of data-light.
One-second nap—then off I zoom,
Hello, world, from this burrowed room! 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
examples/runtime/hello_world/client.py (2)

41-42: Parameterize request cadence to reduce log spam and allow tuning.

Hardcoding sleep(1) is fine for a demo, but making it configurable via an env var improves UX in clusters with stricter rate limits.

Add this outside the shown block:

# imports
import os  # at top-level

# before the loop, near idx initialization
period = float(os.getenv("HELLO_WORLD_PERIOD_SEC", "1.0"))

Then change the sleep to:

await asyncio.sleep(period)

38-40: Ensure the generated stream is always closed on errors

Our inspection of the Python bindings shows that client.generate(...) returns a bare async generator (no __aenter__/__aexit__ support), so using async with won’t work. To avoid leaking the underlying TCP/NATS connection if an exception occurs during iteration, wrap the loop in a try/finally and call await stream.aclose().

• examples/runtime/hello_world/client.py (around lines 38–41)

Suggested diff:

-        stream = await client.generate(f"Query[{idx}] world,sun,moon,star")
-        async for response in stream:
-            print(response.data())
+        stream = await client.generate(f"Query[{idx}] world,sun,moon,star")
+        try:
+            async for response in stream:
+                print(response.data())
+        finally:
+            # ensure the async generator is closed to free network resources
+            await stream.aclose()
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 105436c and d65ae5f.

📒 Files selected for processing (1)
  • examples/runtime/hello_world/client.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Mirror Repository to GitLab
  • GitHub Check: Build and Test - dynamo

@pull-request-size pull-request-size bot added size/M and removed size/S labels Aug 22, 2025
@biswapanda biswapanda merged commit 7076990 into main Aug 22, 2025
9 of 10 checks passed
@biswapanda biswapanda deleted the bis/dyn-926-hello-world-example-is-crash-looping branch August 22, 2025 01:15
hhzhang16 pushed a commit that referenced this pull request Aug 27, 2025
KrishnanPrash pushed a commit that referenced this pull request Sep 2, 2025
nnshah1 pushed a commit that referenced this pull request Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants