Skip to content

Conversation

@michaelfeil
Copy link
Contributor

@michaelfeil michaelfeil commented Aug 21, 2025

Overview:

Details:

Playing back a PR from upgrading dynamo from 0.1 to 0.4.
Re-enabled the broken usage of HTTPEngine. Currently, the HTTPEngine can't receive any requests (they get returned with status code 503), because the flag to enable the given engine can't be enabled.

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

    • Added a Python API to enable or disable specific endpoints (chat, completion, embedding) at runtime.
    • Provides clear validation with errors for unsupported endpoint names.
  • Refactor

    • Streamlined internal logic to centralize and standardize endpoint toggling behavior.

@michaelfeil michaelfeil requested a review from a team as a code owner August 21, 2025 04:53
@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
Copy link

👋 Hi michaelfeil! Thank you for contributing to ai-dynamo/dynamo.

Just a reminder: The NVIDIA Test Github Validation CI runs an essential subset of the testing framework to quickly catch errors.Your PR reviewers may elect to test the changes comprehensively before approving your changes.

🚀

@github-actions github-actions bot added the external-contribution Pull request is from an external contributor label Aug 21, 2025
@michaelfeil michaelfeil changed the title sync-enable-endpoint fix: Httpengine sync-enable-endpoint Aug 21, 2025
@github-actions github-actions bot added the fix label Aug 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

Walkthrough

Adds public re-export of EndpointType, a new Python-exposed HttpService.enable_endpoint, and a Rust HttpService.sync_enable_model_endpoint. The Python method maps string types to EndpointType, then calls the synchronous helper, which updates endpoint flags and logs. The async enable_model_endpoint now delegates to the sync helper.

Changes

Cohort / File(s) Change Summary
Python bindings
lib/bindings/python/rust/http.rs
Re-export EndpointType. Add HttpService.enable_endpoint(endpoint_type: String, enabled: bool) exposed to Python; maps "chat"/"completion"/"embedding" to EndpointType and calls inner.sync_enable_model_endpoint. Errors on invalid type.
HTTP service core
lib/llm/src/http/service/service_v2.rs
Add HttpService.sync_enable_model_endpoint(endpoint_type: EndpointType, enable: bool) to set StateFlags and log. Refactor enable_model_endpoint to delegate to the new sync method.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Py as Python Caller
  participant PySvc as Py HttpService
  participant RsSvc as Rust HttpService (v2)
  participant Flags as StateFlags

  Py->>PySvc: enable_endpoint(endpoint_type: str, enabled: bool)
  alt valid type ("chat"/"completion"/"embedding")
    PySvc->>PySvc: Map str -> EndpointType
    PySvc->>RsSvc: sync_enable_model_endpoint(EndpointType, enabled)
    RsSvc->>Flags: set(endpoint_type, enabled)
    Flags-->>RsSvc: updated
    RsSvc-->>PySvc: Ok(())
    PySvc-->>Py: Ok(())
  else invalid type
    PySvc-->>Py: Err(Invalid endpoint_type)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

Possibly related PRs

Poem

I flip small switches, hop by hop,
Chat, embed, or tokens drop—
A whisker-twitch, endpoints wake,
Flags set right for every take.
In rust and py I nimbly play,
Toggle tunes to start the day. 🐇⚙️

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)
lib/llm/src/http/service/service_v2.rs (1)

269-276: Consider stronger atomic ordering (Acquire/Release or SeqCst) for endpoint enable flags.

Using Relaxed loads/stores in StateFlags means other threads may observe stale values briefly. For an on/off gate evaluated in request middleware, stronger ordering can be simpler and safer with negligible cost. If you prefer Relaxed, add a short comment documenting the rationale.

Apply this diff to switch to SeqCst in get/set (referenced here; edits occur in StateFlags::get and StateFlags::set above):

-            EndpointType::Chat => self.chat_endpoints_enabled.load(Ordering::Relaxed),
-            EndpointType::Completion => self.cmpl_endpoints_enabled.load(Ordering::Relaxed),
-            EndpointType::Embedding => self.embeddings_endpoints_enabled.load(Ordering::Relaxed),
-            EndpointType::Responses => self.responses_endpoints_enabled.load(Ordering::Relaxed),
+            EndpointType::Chat => self.chat_endpoints_enabled.load(Ordering::SeqCst),
+            EndpointType::Completion => self.cmpl_endpoints_enabled.load(Ordering::SeqCst),
+            EndpointType::Embedding => self.embeddings_endpoints_enabled.load(Ordering::SeqCst),
+            EndpointType::Responses => self.responses_endpoints_enabled.load(Ordering::SeqCst),
-            EndpointType::Chat => self
-                .chat_endpoints_enabled
-                .store(enabled, Ordering::Relaxed),
-            EndpointType::Completion => self
-                .cmpl_endpoints_enabled
-                .store(enabled, Ordering::Relaxed),
-            EndpointType::Embedding => self
-                .embeddings_endpoints_enabled
-                .store(enabled, Ordering::Relaxed),
-            EndpointType::Responses => self
-                .responses_endpoints_enabled
-                .store(enabled, Ordering::Relaxed),
+            EndpointType::Chat => self
+                .chat_endpoints_enabled
+                .store(enabled, Ordering::SeqCst),
+            EndpointType::Completion => self
+                .cmpl_endpoints_enabled
+                .store(enabled, Ordering::SeqCst),
+            EndpointType::Embedding => self
+                .embeddings_endpoints_enabled
+                .store(enabled, Ordering::SeqCst),
+            EndpointType::Responses => self
+                .responses_endpoints_enabled
+                .store(enabled, Ordering::SeqCst),

Optional: return the previous state from sync_enable_model_endpoint for observability, but that would change the signature and call sites.

lib/bindings/python/rust/http.rs (1)

22-22: Re-exporting EndpointType is fine for Rust usage; consider a Python Enum to avoid stringly-typed API.

Right now Python callers must pass strings. Exposing a Python-visible enum (or simple constants) would give call-time validation and autocompletion. Not required for this PR, but improves ergonomics and reduces typos.

📜 Review details

Configuration used: .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 fb15e20 and 83d7b8d.

📒 Files selected for processing (2)
  • lib/bindings/python/rust/http.rs (2 hunks)
  • lib/llm/src/http/service/service_v2.rs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
lib/bindings/python/rust/http.rs (1)
lib/bindings/python/rust/lib.rs (1)
  • to_pyerr (124-129)
⏰ 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). (3)
  • GitHub Check: Build and Test - dynamo
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (.)
🔇 Additional comments (1)
lib/llm/src/http/service/service_v2.rs (1)

265-268: Good: async wrapper preserves public API while delegating to sync helper.

This keeps the previous async signature intact and centralizes the logic in a sync helper, which unblocks non-async call sites (e.g., Python binding). Looks good.

@grahamking
Copy link
Contributor

re-enabled the broken usage of HTTPEngine, that was never able to be "enabled" by accessing the flag.

I don't understand that. Could you re-phrase?

@michaelfeil
Copy link
Contributor Author

Rephrased @grahamking

@pull-request-size pull-request-size bot added size/M and removed size/S labels Aug 21, 2025
@michaelfeil
Copy link
Contributor Author

@grahamking Modified as you requested.

@grahamking grahamking merged commit 174389e into ai-dynamo:main Aug 21, 2025
11 checks passed
hhzhang16 pushed a commit that referenced this pull request Aug 27, 2025
nv-anants pushed a commit that referenced this pull request Aug 28, 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

Labels

external-contribution Pull request is from an external contributor fix size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants