fix: avoid constructing DatasetProcessRule in indexing preview#33911
fix: avoid constructing DatasetProcessRule in indexing preview#33911wangji0923 wants to merge 3 commits intolanggenius:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request optimizes the indexing preview functionality by preventing the instantiation of full Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request successfully refactors the indexing_estimate method to avoid constructing a DatasetProcessRule ORM object during previews, which is a good performance optimization. This is achieved by creating a lightweight dictionary and updating ProcessRuleDict to allow optional id and dataset_id fields. The new unit test is well-written and effectively validates that the ORM object is not instantiated. The changes are solid, and I have just one minor suggestion to improve the robustness of the new test's assertion.
| assert transform_kwargs["preview"] is True | ||
| assert transform_kwargs["process_rule"] == { | ||
| "mode": tmp_processing_rule["mode"], | ||
| "rules": tmp_processing_rule["rules"], |
There was a problem hiding this comment.
The assertion uses dictionary-style access (tmp_processing_rule["rules"]), while the implementation being tested uses the safer .get("rules"). While this works for the current test setup, it makes the test less robust. To better align with the implementation's logic and improve robustness, consider using .get("rules") here as well.
| "rules": tmp_processing_rule["rules"], | |
| "rules": tmp_processing_rule.get("rules"), |
Pyrefly DiffNo changes detected. |
Summary
DatasetProcessRuleORM construction inIndexingRunner.indexing_estimatewith a lightweight process rule dictProcessRuleDictto omit persisted-only fields in preview scenariosDatasetProcessRuleTesting
DEBUG=false uv run --project api --no-default-groups --group dev --group tools pytest api/tests/unit_tests/core/rag/indexing/test_indexing_runner.pyCloses #31094