Skip to content

[CI]【Hackathon 10th Spring No.36】worker_process 单测补充#6736

Open
cloudforge1 wants to merge 17 commits intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-036-worker-process-test
Open

[CI]【Hackathon 10th Spring No.36】worker_process 单测补充#6736
cloudforge1 wants to merge 17 commits intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-036-worker-process-test

Conversation

@cloudforge1
Copy link
Copy Markdown
Contributor

@cloudforge1 cloudforge1 commented Mar 9, 2026

Motivation

No.36 功能模块 fastdeploy/worker/worker_process.py 单测补充

Modifications

add unittest tests/worker/test_worker_process.py

develop 分支:覆盖率61%,Miss行数169(85-87, 92-111, 134, 193-209, 300-314, 317-320, 332-385, 399-436, 452-453, 464-465, 486-488, 496->505, 500, 508-558, 568, 575, 582-585, 606-608, 620, 660, 683, 693-699, 713, 740-763, 1126-1127, 1132-1143, 1170, 1205-1206, 1234, 1259-1261, 1273-1277)

当前PR:覆盖率97%,Miss行数17

注:截图为本测试文件单独运行的 pytest --cov 输出(含 branch coverage),上方文字为 develop 已有测试与本 PR 合并后的 statement 覆盖率预估值,两者统计口径不同,以 CI 合并后实际值为准。

完成单测覆盖行数 169-17 = 152 → 四舍五入 200 → 预估贡献度 0.2⭐

Usage or Command

pytest tests/worker/test_worker_process.py

Accuracy Tests

no need

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Mar 9, 2026

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Mar 9, 2026
@cloudforge1 cloudforge1 marked this pull request as draft March 9, 2026 14:50
@cloudforge1 cloudforge1 force-pushed the task/h10-036-worker-process-test branch from 3162a1f to a39c57e Compare March 9, 2026 16:30
@cloudforge1 cloudforge1 force-pushed the task/h10-036-worker-process-test branch from a39c57e to 9b0b166 Compare March 9, 2026 16:39
@cloudforge1 cloudforge1 changed the title [Tests]【Hackathon 10th Spring No.36】add unit tests for worker/worker_process.py [CI]【Hackathon 10th Spring No.36】worker_process 单测补充 Mar 9, 2026
@cloudforge1 cloudforge1 marked this pull request as ready for review March 9, 2026 16:49
@cloudforge1 cloudforge1 marked this pull request as draft March 9, 2026 17:25
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@938e7dd). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #6736   +/-   ##
==========================================
  Coverage           ?   73.99%           
==========================================
  Files              ?      376           
  Lines              ?    52850           
  Branches           ?     8239           
==========================================
  Hits               ?    39106           
  Misses             ?    11052           
  Partials           ?     2692           
Flag Coverage Δ
GPU 73.99% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…lat structure, 80% coverage

- Flatten class-based tests to flat pytest functions (32→25 tests)
- Add _run_eplb enabled path (token stats + weight update + value=None)
- Add initialize_fd_config EP branch + quant_config branch
- Add kv_cache cap at 40000, graph_optimize splitwise path
- Add run_worker_proc with deterministic mode + iluvatar dispatch
- Coverage: 69% → 80% (395/493 stmts)
Add test cases for:
- EP config with int moe_num_experts (else branch)
- Non-CUDA/XPU platform V1 scheduler fallback
- v1_loader_support fallback to default
- PaddleOCR architecture branch
- num_hidden_layers=None ValueError
@cloudforge1 cloudforge1 force-pushed the task/h10-036-worker-process-test branch from 906e312 to 6022842 Compare March 12, 2026 16:13
- Replace 33 MagicMock instances with types.SimpleNamespace, real numpy
  arrays, and real callables (lambda/async def)
- Remove unittest.mock.MagicMock and AsyncMock imports
- Keep only unittest.mock.patch for module-level substitution
- All 21 tests pass, coverage unchanged at 80%
@CSWYF3634076
Copy link
Copy Markdown
Collaborator

/skip-ci ci_iluvatar
/skip-ci ci_hpu
/skip-ci build_xpu
/skip-ci gpu_4cards_test
/skip-ci pre_ce_test
/skip-ci stable_test
/skip-ci base_test
/skip-ci logprob_test

Copilot AI review requested due to automatic review settings April 2, 2026 02:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@CSWYF3634076
Copy link
Copy Markdown
Collaborator

@cloudforge1
感谢贡献!
代码需要保留原来文件格式的风格,把单测都保留在class Testxxx(unittest.TestCase)中,尽最大可能减少mock的内容,使用真实的逻辑

Per reviewer @CSWYF3634076 feedback:
- Keep all tests in unittest.TestCase classes
- Minimize mock content, use real logic
- Two classes: TestWorkerUtils (real logic) + TestPaddleDisWorkerProc
- Removed MagicMock entirely (83 → 0 references)
- Reduced patch usage (was excessive, now 35 targeted patches)
Copilot AI review requested due to automatic review settings April 2, 2026 13:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment on lines +27 to +33
# fmt: off
def _cfg(**overrides):
"""Minimal FDConfig-like namespace."""
c = types.SimpleNamespace(
parallel_config=types.SimpleNamespace(
local_engine_worker_queue_port=9999, tensor_parallel_size=1,
tensor_parallel_rank=0, data_parallel_size=1, data_parallel_rank=0,
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

这里使用了 # fmt: off 但文件中没有对应的 # fmt: on,会导致 Black 在后续整文件都跳过格式化,长期会增加维护成本。建议只在需要的代码块前后成对添加 # fmt: off/on

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — added matching # fmt: on after the compact config block so Black resumes formatting for the rest of the file.

Address 3 Copilot review comments:
1. Fix double space in copyright header
2. Add # fmt: on to close the # fmt: off block after _cfg()
3. Use assertEqual instead of assertIs for integer comparison
…ker-process-test

# Conflicts:
#	tests/worker/test_worker_process.py
Copilot AI review requested due to automatic review settings April 2, 2026 16:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

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.

6 participants