Skip to content

test: expand OpenAI serving chat coverage - #65

Merged
xunyoyo merged 1 commit into
chatfrom
codex/add-tests-for-serving_chat.py
Jan 20, 2026
Merged

test: expand OpenAI serving chat coverage#65
xunyoyo merged 1 commit into
chatfrom
codex/add-tests-for-serving_chat.py

Conversation

@xunyoyo

@xunyoyo xunyoyo commented Jan 20, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Improve unit-test coverage for fastdeploy.entrypoints.openai.serving_chat by exercising logprobs decoding, error paths, and request lifecycle variants.
  • Centralize and extend test helpers to reduce duplicated setup across tests that exercise streaming and full-generator flows.
  • Validate edge cases such as invalid top-k, byte-replacement decoding, non-master handling, and request-id prefix behavior.

Description

  • Added shared test helpers _make_logprobs_lists, _make_handler, and _setup_semaphore, plus a small paddle.compat shim and additional imports (DeltaMessage, LogProbEntry, StreamOptions, ErrorCode, ParameterError, numpy) to support richer fixtures in tests/entrypoints/openai/test_serving_chat.py.
  • Expanded tests for logprob handling including test_build_prompt_logprobs_no_decode, test_build_logprobs_response_* (invalid request, decode errors, byte replacement), test_create_chat_logprobs_* (invalid input, multiple steps, request false), and test_make_logprob_dict_* edge cases.
  • Added broader create_chat_completion tests covering non-master and unsupported model handling, ParameterError and formatter error handling, request id prefixing and preservation, numpy prompt ids for streaming, streaming multimodal usage, full-generator behavior with draft and prompt logprobs, and finish-reason variants for choices.

Testing

  • Ran PYTHONPATH=. pytest -q tests/entrypoints/openai/test_serving_chat.py which completed successfully with 40 passed and warnings observed.
  • Ran coverage run -m pytest -q tests/entrypoints/openai/test_serving_chat.py which passed and was followed by coverage report -m --include="fastdeploy/entrypoints/openai/serving_chat.py" --fail-under=85 reporting 89% coverage for serving_chat.py.
  • Ran pre-commit run --files tests/entrypoints/openai/test_serving_chat.py which passed all configured hooks.

Codex Task

@xunyoyo
xunyoyo merged commit 132716d into chat Jan 20, 2026

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

Copy link
Copy Markdown

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: 97ea40859d

ℹ️ 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".

Comment on lines +26 to +27
if not hasattr(paddle, "compat"):
paddle.compat = types.SimpleNamespace(enable_torch_proxy=lambda *args, **kwargs: None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid masking missing paddle.compat in tests

Injecting a stub paddle.compat here means the tests will pass even if the installed Paddle build doesn’t actually provide compat, but production code still calls paddle.compat.enable_torch_proxy unguarded (see fastdeploy/__init__.py:52). In environments with older Paddle versions, this shim hides the real import-time failure, so CI can green‑light an unsupported configuration that would crash at runtime. Consider skipping these tests or gating on Paddle version instead of patching the global module.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant