Skip to content

Conversation

Echo-Nie
Copy link
Contributor

Objective

  1. guided_json: Verify whether the JSON schema is compatible with XGrammar.
  2. guided_grammar: Verify the validity of custom grammar strings.
  3. guided_json_object: Verify that the simplified JSON object pattern { "type": "object" } can be correctly generated.
  4. guided_choice: Verify whether a list of choices can be correctly transformed into grammar rules.
  5. structural_tag: Verify that structured tags can be correctly parsed.
  6. regex: Verify that regular expressions are passed through without validation errors.

Test Results

/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddle/utils/cpp_extension/extension_utils.py:717: UserWarning: No ccache found. Please be aware that recompiling all source files may be required. You can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md
  warnings.warn(warning_message)
/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils. Support for replacing an already imported distutils is deprecated. In the future, this condition will fail. Register concerns at https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml
  warnings.warn(
test_guided_choice_invalid (__main__.TestXGrammarChecker) ... ok
test_guided_choice_valid (__main__.TestXGrammarChecker) ... ok
test_guided_grammar_invalid (__main__.TestXGrammarChecker) ... ok
test_guided_grammar_valid (__main__.TestXGrammarChecker) ... ok
test_guided_json_invalid (__main__.TestXGrammarChecker) ... ok
test_guided_json_object (__main__.TestXGrammarChecker) ... ok
test_guided_json_valid (__main__.TestXGrammarChecker) ... ok
test_regex_passthrough (__main__.TestXGrammarChecker) ... ok
test_structural_tag_invalid (__main__.TestXGrammarChecker) ... ok
test_structural_tag_valid (__main__.TestXGrammarChecker) ... ok

----------------------------------------------------------------------
Ran 10 tests in 0.002s

OK

Analysis

guided_json: Valid schemas pass correctly. Invalid schemas correctly return an error.

guided_grammar: Valid grammar strings generate the corresponding Grammar object. Invalid grammar strings return errors as expected.

guided_json_object: Simplified JSON object patterns are generated correctly.

guided_choice: Valid choice lists are correctly converted into grammar rules. Invalid choices (e.g., containing None) trigger exceptions.

structural_tag: Correct structured tags are parsed successfully. Missing trigger fields trigger a KeyError.

regex: Regular expressions are passed through directly without validation errors.

Copy link

paddle-bot bot commented Sep 12, 2025

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Sep 12, 2025
@Echo-Nie
Copy link
Contributor Author

Echo-Nie commented Sep 12, 2025

取消了 .github/workflows/_unit_test_coverage.yml 文件中的修改,在 scripts/unittest_requirement.txt 中增加 xgrammar==0.1.19

因为上一个PR的commit太乱了,所以重新提交。
前置PR:#3560

@kevincheng2 pls review~ thx

@kevincheng2
Copy link
Collaborator

coverage ci安装xgrammar 太慢了,会导致ci超时,我已经联系同事把xgrammar直接打到ci镜像中了。这个需要全面的测试一下新增这个环境会不会影响其他功能,稍等几天哈

@Echo-Nie
Copy link
Contributor Author

coverage ci安装xgrammar 太慢了,会导致ci超时,我已经联系同事把xgrammar直接打到ci镜像中了。这个需要全面的测试一下新增这个环境会不会影响其他功能,稍等几天哈

收到!辛苦老师们🫡

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.

3 participants