feat: add --strict-ports option for predictable port assignment#21320
feat: add --strict-ports option for predictable port assignment#21320mickqian merged 3 commits intosgl-project:mainfrom
Conversation
…ound This allows proper fallback to diffusers backend when native config is not available for a model. Fixes sgl-project#21311
When --strict-ports is enabled, the server will fail immediately if the requested ports are unavailable instead of automatically selecting alternative ports. This ensures predictable port assignment for users who need to know exactly which ports will be used. Related to sgl-project#21284
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement to the server's port management by adding a Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new strict_ports option, which, when enabled, causes the server to fail if requested ports are unavailable instead of auto-selecting them. It also modifies the model registry to log a debug message and return None instead of raising a RuntimeError when model information is not found. The review suggests that changing the RuntimeError to a debug log in the registry might hide critical configuration issues and recommends reverting to an exception. Additionally, it recommends making the error messages for scheduler_port and master_port more consistent and helpful when strict_ports is enabled.
| logger.debug(f"No model info found for model path: {model_path}") | ||
| return None |
There was a problem hiding this comment.
Changing RuntimeError to logger.debug and returning None can hide potential configuration issues. If model info is not found for a given model_path, it's likely an error that should be surfaced to the user, rather than being silently ignored at the debug log level. This change could lead to hard-to-debug NoneType errors later in the execution flow. It's better to fail fast. Please consider reverting to raising an exception.
| logger.debug(f"No model info found for model path: {model_path}") | |
| return None | |
| raise RuntimeError(f"No model info found for model path: {model_path}") |
| if not is_port_available(self.scheduler_port): | ||
| raise RuntimeError( | ||
| f"Scheduler port {self.scheduler_port} is unavailable and --strict-ports is enabled." | ||
| ) | ||
| if self.master_port is not None and not is_port_available(self.master_port): | ||
| raise RuntimeError( | ||
| f"Master port {self.master_port} is unavailable and --strict-ports is enabled." | ||
| ) |
There was a problem hiding this comment.
The error messages for unavailable scheduler_port and master_port are not as helpful as the one for the main port. For consistency and better user experience, consider including the suggestion to 'Either use a different port or remove --strict-ports to allow auto-selection' in all error messages when strict_ports is enabled.
| if not is_port_available(self.scheduler_port): | |
| raise RuntimeError( | |
| f"Scheduler port {self.scheduler_port} is unavailable and --strict-ports is enabled." | |
| ) | |
| if self.master_port is not None and not is_port_available(self.master_port): | |
| raise RuntimeError( | |
| f"Master port {self.master_port} is unavailable and --strict-ports is enabled." | |
| ) | |
| if not is_port_available(self.scheduler_port): | |
| raise RuntimeError( | |
| f"Scheduler port {self.scheduler_port} is unavailable and --strict-ports is enabled. " | |
| f"Either use a different port or remove --strict-ports to allow auto-selection." | |
| ) | |
| if self.master_port is not None and not is_port_available(self.master_port): | |
| raise RuntimeError( | |
| f"Master port {self.master_port} is unavailable and --strict-ports is enabled. " | |
| f"Either use a different port or remove --strict-ports to allow auto-selection." | |
| ) |
- Reverted registry.py to raise RuntimeError instead of returning None to avoid hiding critical configuration issues - Made strict_ports error messages consistent across all ports - Added helpful hints for resolving port conflicts
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
…gnment (sgl-project#21320) Co-authored-by: 阳虎 <yanghu@yanghudeMacBook-Pro.local>
…gnment (sgl-project#21320) Co-authored-by: 阳虎 <yanghu@yanghudeMacBook-Pro.local>
…gnment (sgl-project#21320) Co-authored-by: 阳虎 <yanghu@yanghudeMacBook-Pro.local>
Summary
--strict-portsoption to disable automatic port selectionProblem
Currently, when a requested port is occupied,
settle_portautomatically selects an available port. This causes issues for users who:Solution
Add
--strict-portsoption. When enabled:Usage
Related to #21284
Test Plan