refactor(api): use sessionmaker in relyt & tidb_vector VDB services#34848
Merged
crazywoola merged 1 commit intolanggenius:mainfrom Apr 10, 2026
Merged
Conversation
Contributor
Pyrefly DiffNo changes detected. |
2 tasks
asukaminato0721
approved these changes
Apr 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors write-transaction handling in the Relyt and TiDB Vector DB services to use sessionmaker(bind=...).begin() instead of manually calling session.begin()/session.commit(), and updates unit tests accordingly.
Changes:
- Switched RelytVector write operations (
create_collection,delete) tosessionmaker(...).begin()context manager transactions. - Switched TiDBVector write operations (
_create_collection,delete) tosessionmaker(...).begin()context manager transactions. - Updated unit test monkeypatch/mocks to align with the new sessionmaker-based transaction pattern.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| api/core/rag/datasource/vdb/tidb_vector/tidb_vector.py | Uses sessionmaker(...).begin() for TiDB write transactions (create/drop table). |
| api/core/rag/datasource/vdb/relyt/relyt_vector.py | Uses sessionmaker(...).begin() for Relyt write transactions (create/drop table). |
| api/tests/unit_tests/core/rag/datasource/vdb/tidb_vector/test_tidb_vector.py | Updates mocks/patching for TiDB sessionmaker .begin() context manager. |
| api/tests/unit_tests/core/rag/datasource/vdb/relyt/test_relyt_vector.py | Adds shared patch helper for Session+sessionmaker; updates tests for new transaction semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
@asukaminato0721 @crazywoola |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
with Session(self.client/self._engine)+session.commit()withsessionmaker(bind=...).begin()in relyt (2 blocks) and tidb_vector (2 blocks)Part of #24245
Test plan
ruff checkpasses