Skip to content

refactor(api): use sessionmaker in relyt & tidb_vector VDB services#34848

Merged
crazywoola merged 1 commit intolanggenius:mainfrom
carlos4s:refactor/sessionmaker-vdb-relyt-tidb
Apr 10, 2026
Merged

refactor(api): use sessionmaker in relyt & tidb_vector VDB services#34848
crazywoola merged 1 commit intolanggenius:mainfrom
carlos4s:refactor/sessionmaker-vdb-relyt-tidb

Conversation

@carlos4s
Copy link
Copy Markdown
Contributor

@carlos4s carlos4s commented Apr 9, 2026

Summary

  • Replace with Session(self.client/self._engine) + session.commit() with
    sessionmaker(bind=...).begin() in relyt (2 blocks) and tidb_vector (2 blocks)
  • Read-only session blocks left unchanged
  • Updated test mocks to match new sessionmaker pattern

Part of #24245

Test plan

  • ruff check passes
  • 42 relyt + tidb_vector tests pass

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. refactor labels Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Pyrefly Diff

No changes detected.

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 9, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 9, 2026
@asukaminato0721 asukaminato0721 removed this pull request from the merge queue due to a manual request Apr 9, 2026
@asukaminato0721 asukaminato0721 requested a review from Copilot April 10, 2026 00:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) to sessionmaker(...).begin() context manager transactions.
  • Switched TiDBVector write operations (_create_collection, delete) to sessionmaker(...).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.

@crazywoola crazywoola added this pull request to the merge queue Apr 10, 2026
Merged via the queue into langgenius:main with commit 86fd947 Apr 10, 2026
31 checks passed
@carlos4s carlos4s deleted the refactor/sessionmaker-vdb-relyt-tidb branch April 10, 2026 14:12
@carlos4s
Copy link
Copy Markdown
Contributor Author

@asukaminato0721 @crazywoola
Thanks for merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants