-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Added a test for invalid inputs for parse_raw_prompts #30446
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
Conversation
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run You ask your reviewers to trigger select CI tests on top of Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. 🚀 |
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.
Code Review
This pull request correctly adds tests for invalid inputs to parse_raw_prompts that should raise a TypeError. While reviewing, I found a related validation bug where partially empty batches like [[1], []] are incorrectly accepted. I've added a comment suggesting a new test case to expose this issue, which would further improve the robustness of the input parsing.
| @pytest.mark.parametrize( | ||
| "invalid_input", | ||
| [ | ||
| ["foo", 1], # mixed of string and token | ||
| [["foo"], ["bar"]] # list of list of strings | ||
| ] | ||
| ) | ||
| def test_invalid_input_raise_type_error(invalid_input): | ||
| with pytest.raises(TypeError): | ||
| parse_raw_prompts(invalid_input) |
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.
This is a good addition for testing TypeError cases. While reviewing this, I noticed a potential logic issue in parse_raw_prompts that isn't covered.
The function currently only checks if the first sublist is empty for list[list[int]] style inputs. This means an input like [[1], []] would be accepted, which is inconsistent with the fact that [[]] correctly raises a ValueError.
This could lead to unexpected behavior with partially empty batch prompts.
I'd recommend adding another test to assert that prompts containing empty sublists also raise a ValueError. Since this test is focused on TypeError, a new test function would be appropriate. For example:
def test_parse_raw_list_of_list_with_empty_sublist():
with pytest.raises(ValueError, match="at least one prompt"):
parse_raw_prompts([[1], []])Adding this test would expose the issue and allow for a fix in parse_raw_prompts.
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
tests/test_inputs.py
Outdated
| ["foo", 1], # mixed of string and token | ||
| [["foo"], ["bar"]] # list of list of strings | ||
| ] | ||
| ) | ||
| def test_invalid_input_raise_type_error(invalid_input): |
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.
New invalid-input test fails with current parser logic
The new test_invalid_input_raise_type_error expects ["foo", 1] to trigger a TypeError, but parse_raw_prompts currently checks only the first element of a list (is_list_of(prompt, str) at vllm/inputs/parse.py:36) and treats such input as an array of strings, returning TextPrompt objects instead of raising. With the existing implementation, this test will deterministically fail whenever the suite runs against a mixed string/int list.
Useful? React with 👍 / 👎.
|
Hi @mivehk, the pre-commit checks have failed. Please run: uv pip install pre-commit
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, Tip Is
|
DarkLight1337
left a comment
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.
Thanks for adding the test, see if it passes
|
Also please fix pre-commit |
|
Hi @mivehk, the pre-commit checks have failed. Please run: uv pip install pre-commit
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, Tip Is
|
|
Hi, |
|
Closing as superseded by #30512 |
Purpose
Strengthening the input validation tests for parse_raw_prompts, raising the TypeError when mix of strings and tokens, or array of array of strings are used as input.
Test Plan
pytest tests/inputs/test_inputs.py
New test case is passed for cpu only execution.
Test Result
All tests will be passed, including the newly added test case raising 'TypeError'
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.