Skip to content

fix: grpc_servicer add check empty input and centralize tokenized validation#979

Open
gongwei-130 wants to merge 10 commits intomainfrom
wei/add-empty-check
Open

fix: grpc_servicer add check empty input and centralize tokenized validation#979
gongwei-130 wants to merge 10 commits intomainfrom
wei/add-empty-check

Conversation

@gongwei-130
Copy link
Copy Markdown
Collaborator

@gongwei-130 gongwei-130 commented Mar 30, 2026

Summary

  • extract SGLang tokenized request validation into a lightweight module: smg_grpc_servicer/sglang/validation.py
  • update SGLang servicer request conversion paths to reuse validate_tokenized_input for both Generate and Embed requests
  • add unit tests for tokenized validation behavior in grpc_servicer/tests/test_sglang_validation.py
  • wire this test into PR CI by adding grpc-servicer-unit-tests in .github/workflows/pr-test-rust.yml

What Changed

  • validation now consistently enforces:
    • tokenized field must be present
    • input_ids must be non-empty (request-kind-specific error)
  • duplicated inline validation logic in servicer.py is removed

Test Plan

  • local checks:
    • python3 -m py_compile grpc_servicer/smg_grpc_servicer/sglang/servicer.py
    • python3 -m py_compile grpc_servicer/smg_grpc_servicer/sglang/validation.py
    • python3 -m py_compile grpc_servicer/tests/test_sglang_validation.py
  • CI:
    • grpc-servicer-unit-tests runs pytest -q grpc_servicer/tests/test_sglang_validation.py

Notes

  • this keeps validation directly importable for unit tests without importing heavy servicer.py runtime dependencies

Summary by CodeRabbit

  • Tests

    • Added unit tests for tokenized-input validation.
    • CI now runs these tests on PRs and fails the pipeline if they fail.
  • Chores

    • Centralized and tightened tokenized input validation and error messages.
  • Refactor

    • Deferred loading of a service class to improve import/startup behavior.

Signed-off-by: gongwei-130 <weigong28@gmail.com>
@github-actions github-actions bot added ci CI/CD configuration changes tests Test changes labels Mar 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Extracted tokenized-input validation into a shared helper used by generate/embed conversion functions, added unit tests for that helper, made SGLangSchedulerServicer a lazily-loaded attribute, and added a CI job to run the new tests.

Changes

Cohort / File(s) Summary
Validation helper
grpc_servicer/smg_grpc_servicer/sglang/validation.py
New validate_tokenized_input(grpc_req, request_kind) that enforces presence of tokenized, returns (original_text, input_ids: list[int]), and raises request-kind-specific errors for missing/empty input_ids.
Servicer updates
grpc_servicer/smg_grpc_servicer/sglang/servicer.py
Replaced inline tokenized-field checks in _convert_generate_request and _convert_embed_request with calls to validate_tokenized_input and use its returned (input_text, input_ids).
Tests
grpc_servicer/tests/test_sglang_validation.py
New unit tests covering missing tokenized, empty input_ids for generate and embed, and valid cases returning expected tuple.
CI workflow
.github/workflows/pr-test-rust.yml
Added grpc-servicer-unit-tests job (Python 3.13 + pytest) running pytest -q grpc_servicer/tests/test_sglang_validation.py; updated finish job needs and failure gating to include this job.
Package init
grpc_servicer/smg_grpc_servicer/sglang/__init__.py
Replaced eager import of SGLangSchedulerServicer with module-level __getattr__ that lazily imports it; adjusted module docstring.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

grpc

Suggested reviewers

  • CatherineSue
  • key4ng
  • slin1237
  • XinyueZhang369

Poem

🐇 I nibbled lines and stitched a tiny seam,

One helper to tidy tokenized dreams,
Tests now hop in CI's bright light,
Lazy imports awake only when right,
A rabbit's patch — quick, neat, and light.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding empty input validation and centralizing tokenized validation logic into a shared helper module.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wei/add-empty-check

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

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c66bdf7b47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a centralized validation helper, validate_tokenized_input, for SGLang gRPC request payloads. It refactors the _convert_generate_request and _convert_embed_request methods in the servicer to use this helper, which now also ensures that input_ids are not empty. Additionally, a new test suite has been added to verify the validation logic. I have no feedback to provide.

Copy link
Copy Markdown

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/pr-test-rust.yml (1)

892-892: ⚠️ Potential issue | 🟠 Major

Add grpc-servicer-unit-tests to the finish job's needs array.

The new job is not included in the finish job's dependency list, so CI failures in grpc-servicer-unit-tests won't be reflected in the overall PR status.

🐛 Proposed fix
   finish:
-    needs: [pre-commit, python-lint, grpc-proto-build-check, build-wheel, python-unit-tests, unit-tests, benchmarks, e2e-1gpu-chat, e2e-1gpu-embeddings, e2e-1gpu-gateway, e2e-2gpu-chat, e2e-2gpu-responses, e2e-2gpu-pd, e2e-4gpu-chat, e2e-4gpu-gateway, e2e-vendor, go-unit-tests, go-bindings-e2e]
+    needs: [pre-commit, python-lint, grpc-proto-build-check, build-wheel, python-unit-tests, grpc-servicer-unit-tests, unit-tests, benchmarks, e2e-1gpu-chat, e2e-1gpu-embeddings, e2e-1gpu-gateway, e2e-2gpu-chat, e2e-2gpu-responses, e2e-2gpu-pd, e2e-4gpu-chat, e2e-4gpu-gateway, e2e-vendor, go-unit-tests, go-bindings-e2e]

And add the corresponding failure check in the "Check CI result" step:

           if [[ "${{ needs.pre-commit.result }}" == "failure" || \
                 "${{ needs.python-lint.result }}" == "failure" || \
                 "${{ needs.grpc-proto-build-check.result }}" == "failure" || \
                 "${{ needs.build-wheel.result }}" == "failure" || \
                 "${{ needs.python-unit-tests.result }}" == "failure" || \
+                "${{ needs.grpc-servicer-unit-tests.result }}" == "failure" || \
                 "${{ needs.unit-tests.result }}" == "failure" || \
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pr-test-rust.yml at line 892, The finish job's needs array
is missing the new grpc-servicer-unit-tests dependency; update the finish job
(the needs: [...] list) to include "grpc-servicer-unit-tests" so that the finish
job waits on that job, and also add the corresponding check for
grpc-servicer-unit-tests in the "Check CI result" step so its failure is
reflected in the overall PR status.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/pr-test-rust.yml:
- Around line 247-251: The CI job fails because the test imports
smg_grpc_servicer.sglang.validation (validate_tokenized_input) but the package
root isn't on PYTHONPATH; update the "Run grpc_servicer unit tests" step so the
package is importable by either exporting PYTHONPATH=grpc_servicer before
running pytest (so tests/test_sglang_validation.py can import
smg_grpc_servicer.sglang.validation) or install the package into the environment
(pip install -e ./grpc_servicer) prior to running pytest.

---

Outside diff comments:
In @.github/workflows/pr-test-rust.yml:
- Line 892: The finish job's needs array is missing the new
grpc-servicer-unit-tests dependency; update the finish job (the needs: [...]
list) to include "grpc-servicer-unit-tests" so that the finish job waits on that
job, and also add the corresponding check for grpc-servicer-unit-tests in the
"Check CI result" step so its failure is reflected in the overall PR status.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 75202845-4cfe-4d05-83a9-c2a02ebad111

📥 Commits

Reviewing files that changed from the base of the PR and between 28f83a3 and c66bdf7.

📒 Files selected for processing (4)
  • .github/workflows/pr-test-rust.yml
  • grpc_servicer/smg_grpc_servicer/sglang/servicer.py
  • grpc_servicer/smg_grpc_servicer/sglang/validation.py
  • grpc_servicer/tests/test_sglang_validation.py

Signed-off-by: gongwei-130 <weigong28@gmail.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a5eb77fd4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/pr-test-rust.yml:
- Around line 235-251: The new job grpc-servicer-unit-tests must be wired into
the finish job so its failure blocks merges: add "grpc-servicer-unit-tests" to
the finish job's needs list and include a check for its result in the finish
job's failure-checking script (the block that iterates job results / checks for
non-success between lines ~898-915); specifically update the arrays/conditions
that count failures to consider the grpc-servicer-unit-tests result and ensure
the final gate fails if that job returned failure or cancelled.

In `@grpc_servicer/tests/test_sglang_validation.py`:
- Around line 46-51: Add a symmetric success-path unit test for request_kind
"generate" in grpc_servicer/tests/test_sglang_validation.py: create a
_GrpcReqStub(tokenized=_Tokenized("world", [3, 4, 5])) and call
validate_tokenized_input(req, "generate"), then assert the returned input_text
equals "world" and input_ids equals [3, 4, 5]; mirror the existing
test_validate_tokenized_input_returns_text_and_ids structure and name it e.g.
test_validate_tokenized_input_returns_text_and_ids_generate to ensure coverage
for validate_tokenized_input across both "embed" and "generate" request kinds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 25573af4-5735-42b7-8439-631ac2b7cc71

📥 Commits

Reviewing files that changed from the base of the PR and between c66bdf7 and 5a5eb77.

📒 Files selected for processing (3)
  • .github/workflows/pr-test-rust.yml
  • grpc_servicer/smg_grpc_servicer/sglang/__init__.py
  • grpc_servicer/tests/test_sglang_validation.py

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Copy link
Copy Markdown

@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.

♻️ Duplicate comments (1)
.github/workflows/pr-test-rust.yml (1)

235-251: ⚠️ Potential issue | 🟠 Major

Wire grpc-servicer-unit-tests into the finish gate.

Line 235 adds a new CI job, but it is not included in the finish job’s needs (Line 891) or failure condition block (Line 898-Line 915). As-is, this job can fail without blocking merge.

🐛 Proposed fix
-  finish:
-    needs: [pre-commit, python-lint, grpc-proto-build-check, build-wheel, python-unit-tests, unit-tests, benchmarks, e2e-1gpu-chat, e2e-1gpu-embeddings, e2e-1gpu-gateway, e2e-2gpu-chat, e2e-2gpu-responses, e2e-2gpu-pd, e2e-4gpu-chat, e2e-4gpu-gateway, e2e-vendor, go-unit-tests, go-bindings-e2e]
+  finish:
+    needs: [pre-commit, python-lint, grpc-proto-build-check, build-wheel, python-unit-tests, grpc-servicer-unit-tests, unit-tests, benchmarks, e2e-1gpu-chat, e2e-1gpu-embeddings, e2e-1gpu-gateway, e2e-2gpu-chat, e2e-2gpu-responses, e2e-2gpu-pd, e2e-4gpu-chat, e2e-4gpu-gateway, e2e-vendor, go-unit-tests, go-bindings-e2e]
@@
           if [[ "${{ needs.pre-commit.result }}" == "failure" || \
                 "${{ needs.python-lint.result }}" == "failure" || \
                 "${{ needs.grpc-proto-build-check.result }}" == "failure" || \
                 "${{ needs.build-wheel.result }}" == "failure" || \
                 "${{ needs.python-unit-tests.result }}" == "failure" || \
+                "${{ needs.grpc-servicer-unit-tests.result }}" == "failure" || \
                 "${{ needs.unit-tests.result }}" == "failure" || \
                 "${{ needs.benchmarks.result }}" == "failure" || \
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pr-test-rust.yml around lines 235 - 251, The new CI job
"grpc-servicer-unit-tests" is not wired into the final gating job ("finish"), so
its failures won't block merges; update the "finish" job to include
"grpc-servicer-unit-tests" in its needs list (the dependency array for the
finish job) and add the same job name into the finish job’s failure condition
block so a failing grpc-servicer-unit-tests run will mark the finish gate as
failed. Locate the "grpc-servicer-unit-tests" job declaration and the "finish"
job (referenced as finish and its needs/failure handling) and add the job name
consistently to both places.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/pr-test-rust.yml:
- Around line 235-251: The new CI job "grpc-servicer-unit-tests" is not wired
into the final gating job ("finish"), so its failures won't block merges; update
the "finish" job to include "grpc-servicer-unit-tests" in its needs list (the
dependency array for the finish job) and add the same job name into the finish
job’s failure condition block so a failing grpc-servicer-unit-tests run will
mark the finish gate as failed. Locate the "grpc-servicer-unit-tests" job
declaration and the "finish" job (referenced as finish and its needs/failure
handling) and add the job name consistently to both places.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6a42308b-dc5f-4295-91ba-fa8a7eac86d0

📥 Commits

Reviewing files that changed from the base of the PR and between 5a5eb77 and a6fd2ac.

📒 Files selected for processing (1)
  • .github/workflows/pr-test-rust.yml

Signed-off-by: gongwei-130 <weigong28@gmail.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Signed-off-by: gongwei-130 <weigong28@gmail.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@grpc_servicer/tests/test_sglang_validation.py`:
- Around line 34-44: Consolidate the two duplicate tests into a single
parametrized test: replace the separate
test_validate_tokenized_input_rejects_empty_generate and
test_validate_tokenized_input_rejects_empty_embed with one test function (e.g.,
test_validate_tokenized_input_rejects_empty_for_kinds) decorated with
pytest.mark.parametrize over request_kind values ("generate", "embed"); inside
the test create the same _GrpcReqStub(tokenized=_Tokenized("hello", [])) and
call validate_tokenized_input(req, request_kind) asserting it raises ValueError
with the appropriate message (use match that can accept either "generate" or
"embed" dynamically, e.g., format or f-string), keeping references to
validate_tokenized_input, _GrpcReqStub, and _Tokenized so the intent and
assertions remain identical.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f0d67f18-19b5-4fd4-93e2-e8a3b5168776

📥 Commits

Reviewing files that changed from the base of the PR and between c6eae0e and a548659.

📒 Files selected for processing (1)
  • grpc_servicer/tests/test_sglang_validation.py

Comment on lines +34 to +44
def test_validate_tokenized_input_rejects_empty_generate(self):
"""Reject generate requests with empty input_ids."""
req = _GrpcReqStub(tokenized=_Tokenized("hello", []))
with pytest.raises(ValueError, match="input_ids cannot be empty for generate requests"):
validate_tokenized_input(req, "generate")

def test_validate_tokenized_input_rejects_empty_embed(self):
"""Reject embed requests with empty input_ids."""
req = _GrpcReqStub(tokenized=_Tokenized("hello", []))
with pytest.raises(ValueError, match="input_ids cannot be empty for embed requests"):
validate_tokenized_input(req, "embed")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Parametrize duplicated empty-input_ids tests to reduce maintenance overhead.

Line 34-44 repeats the same assertion shape with only request_kind changed. Consider consolidating with pytest.mark.parametrize.

♻️ Suggested refactor
 class TestSGLangValidation:
@@
-    def test_validate_tokenized_input_rejects_empty_generate(self):
-        """Reject generate requests with empty input_ids."""
-        req = _GrpcReqStub(tokenized=_Tokenized("hello", []))
-        with pytest.raises(ValueError, match="input_ids cannot be empty for generate requests"):
-            validate_tokenized_input(req, "generate")
-
-    def test_validate_tokenized_input_rejects_empty_embed(self):
-        """Reject embed requests with empty input_ids."""
-        req = _GrpcReqStub(tokenized=_Tokenized("hello", []))
-        with pytest.raises(ValueError, match="input_ids cannot be empty for embed requests"):
-            validate_tokenized_input(req, "embed")
+    `@pytest.mark.parametrize`("request_kind", ["generate", "embed"])
+    def test_validate_tokenized_input_rejects_empty_input_ids(self, request_kind: str):
+        """Reject requests with empty input_ids."""
+        req = _GrpcReqStub(tokenized=_Tokenized("hello", []))
+        with pytest.raises(
+            ValueError,
+            match=rf"input_ids cannot be empty for {request_kind} requests",
+        ):
+            validate_tokenized_input(req, request_kind)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@grpc_servicer/tests/test_sglang_validation.py` around lines 34 - 44,
Consolidate the two duplicate tests into a single parametrized test: replace the
separate test_validate_tokenized_input_rejects_empty_generate and
test_validate_tokenized_input_rejects_empty_embed with one test function (e.g.,
test_validate_tokenized_input_rejects_empty_for_kinds) decorated with
pytest.mark.parametrize over request_kind values ("generate", "embed"); inside
the test create the same _GrpcReqStub(tokenized=_Tokenized("hello", [])) and
call validate_tokenized_input(req, request_kind) asserting it raises ValueError
with the appropriate message (use match that can accept either "generate" or
"embed" dynamically, e.g., format or f-string), keeping references to
validate_tokenized_input, _GrpcReqStub, and _Tokenized so the intent and
assertions remain identical.

Signed-off-by: gongwei-130 <weigong28@gmail.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment on lines +6 to +12
def __getattr__(name: str):
"""Lazily expose `SGLangSchedulerServicer` to avoid eager heavy imports."""
if name == "SGLangSchedulerServicer":
from smg_grpc_servicer.sglang.servicer import SGLangSchedulerServicer

return SGLangSchedulerServicer
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Nit: __getattr__ is called on every attribute access that misses, not just the first. Without caching the result in globals(), repeated access (e.g. sglang.SGLangSchedulerServicer in a loop, or multiple from sglang import SGLangSchedulerServicer statements across modules) re-enters the import machinery each time. The overhead is small (Python caches modules in sys.modules), but the standard pattern caches the binding:

Suggested change
def __getattr__(name: str):
"""Lazily expose `SGLangSchedulerServicer` to avoid eager heavy imports."""
if name == "SGLangSchedulerServicer":
from smg_grpc_servicer.sglang.servicer import SGLangSchedulerServicer
return SGLangSchedulerServicer
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
def __getattr__(name: str):
"""Lazily expose `SGLangSchedulerServicer` to avoid eager heavy imports."""
if name == "SGLangSchedulerServicer":
from smg_grpc_servicer.sglang.servicer import SGLangSchedulerServicer
globals()[name] = SGLangSchedulerServicer
return SGLangSchedulerServicer
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

This is the pattern CPython's stdlib uses (e.g. importlib).

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Signed-off-by: gongwei-130 <weigong28@gmail.com>
@gongwei-130 gongwei-130 changed the title refactor(grpc_servicer): centralize tokenized validation and add unit test grpc_servicer: centralize tokenized validation and add check empty input Mar 31, 2026
@gongwei-130 gongwei-130 changed the title grpc_servicer: centralize tokenized validation and add check empty input fix: grpc_servicer add check empty input and centralize tokenized validation Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI/CD configuration changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant