-
Notifications
You must be signed in to change notification settings - Fork 659
[CI]【Hackathon 9th Sprint Example NO 22】功能模块 fastdeploy/input/ernie4_5_vl_processor/ernie4_5_vl_processor.py 单测补充 #5263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
Thanks for your contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
该 PR 为 Hackathon 9th Sprint Example NO 22 任务补充了 fastdeploy/input/ernie4_5_vl_processor/ernie4_5_vl_processor.py 模块的单元测试。主要目的是提高代码测试覆盖率,针对多个内部方法添加了全面的测试用例。
主要变更:
- 新增了
_parse_processor_kwargs、_parse_limits、_check_mm_limits和_apply_default_parameters方法的单元测试 - 测试覆盖了正常场景、异常场景和边界条件
- 删除了原有的部分重复测试代码
Comments suppressed due to low confidence (5)
tests/input/test_ernie4_5_vl_processor.py:151
- 在
test_parse_processor_kwargs_valid测试中手动绑定了方法_parse_processor_kwargs,但在test_parse_processor_kwargs_invalid_type中没有进行同样的绑定。为了保持一致性,建议在test_parse_processor_kwargs_invalid_type中也手动绑定该方法,或者在两个测试中都使用类方法直接调用的方式。
建议修改为:
processor._parse_processor_kwargs = Ernie4_5_VLProcessor._parse_processor_kwargs.__get__(
processor, Ernie4_5_VLProcessor
)
result = processor._parse_processor_kwargs(invalid_kwargs)tests/input/test_ernie4_5_vl_processor.py:164
- 在
test_parse_processor_kwargs_not_dict测试中没有绑定方法_parse_processor_kwargs,但直接调用了Ernie4_5_VLProcessor._parse_processor_kwargs(processor, ...)。为了保持一致性,建议使用与test_parse_processor_kwargs_valid相同的方法绑定方式。
建议修改为:
processor._parse_processor_kwargs = Ernie4_5_VLProcessor._parse_processor_kwargs.__get__(
processor, Ernie4_5_VLProcessor
)
result = processor._parse_processor_kwargs("not a dict")tests/input/test_ernie4_5_vl_processor.py:201
- 在
test_parse_limits_invalid_type测试中没有绑定方法_parse_limits,但直接调用了Ernie4_5_VLProcessor._parse_limits(processor, ...)。为了保持一致性,建议使用与test_parse_limits_valid相同的方法绑定方式。
建议修改为:
processor._parse_limits = Ernie4_5_VLProcessor._parse_limits.__get__(processor, Ernie4_5_VLProcessor)
result = processor._parse_limits("not a dict")tests/input/test_ernie4_5_vl_processor.py:269
- 在
test_apply_default_parameters_with_dict测试中,generation_config只设置了top_p和temperature属性,但根据源代码(第111-115行),_apply_default_parameters方法还会设置其他参数(repetition_penalty、frequency_penalty、presence_penalty)。为了使测试更加完整和准确,建议也为这些参数设置 mock 值或验证它们使用的默认值。
建议添加:
processor.generation_config.repetition_penalty = 1.0
processor.generation_config.frequency_penalty = 0.0
processor.generation_config.presence_penalty = 0.0tests/input/test_ernie4_5_vl_processor.py:294
- 在
test_apply_default_parameters_with_object测试中,generation_config只设置了top_p属性,但根据源代码(第111-115行),_apply_default_parameters方法会设置多个参数。测试只验证了top_p,没有验证其他参数(如temperature、repetition_penalty等)。为了提高测试覆盖率,建议添加对所有参数的验证。
建议修改 MockRequest 类:
class MockRequest:
def __init__(self):
self.top_p = None
self.temperature = None
self.repetition_penalty = None
self.frequency_penalty = None
self.presence_penalty = None并添加相应的 mock 配置和断言。
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5263 +/- ##
==========================================
Coverage ? 61.51%
==========================================
Files ? 317
Lines ? 38812
Branches ? 5849
==========================================
Hits ? 23876
Misses ? 13049
Partials ? 1887
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6f96ca9 to
666f81c
Compare
Motivation
Modifications
Usage or Command
Accuracy Tests
Checklist
[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]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.