Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(models): remove legacy db.session property wrappers on DocumentSegment and DatasetQuery (#41794)
Keith62a286332abe
diff --git a/api/models/dataset.py b/api/models/dataset.pyindex 327c9503420..ad9d1d97817 100644--- a/api/models/dataset.py+++ b/api/models/dataset.py@@ -922,18 +922,10 @@ class DocumentSegment(TypeBase):stopped_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, default=None)hit_count: Mapped[int] = mapped_column(sa.Integer, nullable=False, default=0)- @property- def dataset(self) -> Dataset | None:- return self.get_dataset(session=db.session())-def get_dataset(self, *, session: Session) -> Dataset | None:"""Load the owning dataset with the caller-owned database session."""return session.get(Dataset, self.dataset_id)- @property- def document(self) -> Document | None:- return self.get_document(session=db.session())-def get_document(self, *, session: Session) -> Document | None:"""Load the owning document with the caller-owned database session."""return session.get(Document, self.document_id)@@ -952,10 +944,6 @@ class DocumentSegment(TypeBase):))- @property- def child_chunks(self):- return self.get_child_chunks(session=db.session(), include_full_doc=False)-def get_child_chunks(self, *, session: Session, include_full_doc: bool = True) -> Sequence["ChildChunk"]:"""Load hierarchical child chunks with the caller-owned database session."""document = session.get(Document, self.document_id)@@ -1042,10 +1030,6 @@ class DocumentSegment(TypeBase):return text- @property- def attachments(self) -> list[AttachmentItem]:- return self.get_attachments(session=db.session())-def get_attachments(self, *, session: Session) -> list[AttachmentItem]:"""Load attachment metadata with the caller-owned database session."""# Use JOIN to fetch attachments in a single query instead of two separate queries@@ -1195,10 +1179,6 @@ class DatasetQuery(TypeBase):DateTime, nullable=False, server_default=sa.func.current_timestamp(), init=False)- @property- def queries(self) -> list[dict[str, Any]]:- return self.get_queries(session=db.session())-def get_queries(self, *, session: Session) -> list[dict[str, Any]]:try:queries = json.loads(self.content)@@ -1467,7 +1447,7 @@ class ExternalKnowledgeApis(TypeBase):return None@property- def dataset_bindings(self) -> list[DatasetBindingItem]:+ def dataset_bindings(self):return self.get_dataset_bindings(session=db.session())def get_dataset_bindings(self, *, session: Session) -> list[DatasetBindingItem]:diff --git a/api/tests/test_containers_integration_tests/models/test_dataset_models.py b/api/tests/test_containers_integration_tests/models/test_dataset_models.pyindex d817894b1de..939e87d8695 100644--- a/api/tests/test_containers_integration_tests/models/test_dataset_models.py+++ b/api/tests/test_containers_integration_tests/models/test_dataset_models.py@@ -322,7 +322,7 @@ class TestDocumentSegmentNavigationProperties:db_session_with_containers.flush()# Act- related_dataset = segment.dataset+ related_dataset = segment.get_dataset(session=db_session_with_containers)# Assertassert related_dataset is not None@@ -369,7 +369,7 @@ class TestDocumentSegmentNavigationProperties:db_session_with_containers.flush()# Act- related_document = segment.document+ related_document = segment.get_document(session=db_session_with_containers)# Assertassert related_document is not None