c889a57b6b
Test Suites / Build CI Environment (push) Has been cancelled
Test Suites / Basic Tests (push) Has been cancelled
Test Suites / End-to-End Tests (push) Has been cancelled
Test Suites / CLI Tests (push) Has been cancelled
Test Suites / Slow End-to-End Tests (push) Has been cancelled
Test Suites / Graph Database Tests (push) Has been cancelled
Test Suites / Vector DB Tests (push) Has been cancelled
Test Suites / Temporal Graph Test (push) Has been cancelled
Test Suites / Search Test on Different DBs (push) Has been cancelled
Test Suites / Example Tests (push) Has been cancelled
Test Suites / Notebook Tests (push) Has been cancelled
Test Suites / OS and Python Tests Ubuntu (push) Has been cancelled
Test Suites / OS and Python Tests Extended (push) Has been cancelled
Test Suites / LLM Test Suite (push) Has been cancelled
Test Suites / S3 File Storage Test (push) Has been cancelled
Test Suites / Run Integration Tests (push) Has been cancelled
Test Suites / MCP Tests (push) Has been cancelled
Test Suites / Docker Compose Test (push) Has been cancelled
Test Suites / Docker CI test (push) Has been cancelled
Test Suites / Relational DB Migration Tests (push) Has been cancelled
Test Suites / Distributed Cognee Test (push) Has been cancelled
Test Suites / DB Examples Tests (push) Has been cancelled
Test Suites / Test Completion Status (push) Has been cancelled
Test Suites / Claude Code Review (push) Has been cancelled
Test Suites / basic checks (push) Has been cancelled
build | Build and Push Cognee MCP Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
build | Build and Push Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.11) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.12) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (kuzu, kuzu) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (neo4j, neo4j) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Examples (push) Has been cancelled
Weighted Edges Tests / Code Quality for Weighted Edges (push) Has been cancelled
63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
from datetime import datetime, timezone
|
|
from uuid import uuid4
|
|
from sqlalchemy import UUID, Column, DateTime, String, JSON, Integer, Float
|
|
from sqlalchemy.ext.mutable import MutableDict
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from cognee.infrastructure.databases.relational import Base
|
|
|
|
from .DatasetData import DatasetData
|
|
|
|
|
|
class Data(Base):
|
|
__tablename__ = "data"
|
|
|
|
id = Column(UUID, primary_key=True, default=uuid4)
|
|
label = Column(String, nullable=True)
|
|
name = Column(String)
|
|
extension = Column(String)
|
|
mime_type = Column(String)
|
|
original_extension = Column(String, nullable=True)
|
|
original_mime_type = Column(String, nullable=True)
|
|
loader_engine = Column(String)
|
|
raw_data_location = Column(String)
|
|
original_data_location = Column(String)
|
|
owner_id = Column(UUID, index=True)
|
|
tenant_id = Column(UUID, index=True, nullable=True)
|
|
content_hash = Column(String)
|
|
raw_content_hash = Column(String)
|
|
external_metadata = Column(JSON)
|
|
# Store NodeSet as JSON list of strings
|
|
node_set = Column(JSON, nullable=True)
|
|
# MutableDict allows SQLAlchemy to notice key-value pair changes, without it changing a value for a key
|
|
# wouldn't be noticed when commiting a database session
|
|
pipeline_status = Column(MutableDict.as_mutable(JSON))
|
|
token_count = Column(Integer)
|
|
data_size = Column(Integer, nullable=True) # File size in bytes
|
|
created_at = Column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))
|
|
updated_at = Column(DateTime(timezone=True), onupdate=lambda: datetime.now(timezone.utc))
|
|
last_accessed = Column(DateTime(timezone=True), nullable=True)
|
|
importance_weight = Column(Float, nullable=True)
|
|
|
|
datasets = relationship(
|
|
"Dataset",
|
|
secondary=DatasetData.__tablename__,
|
|
back_populates="data",
|
|
lazy="selectin",
|
|
cascade="all, delete",
|
|
)
|
|
|
|
def to_json(self) -> dict:
|
|
return {
|
|
"id": str(self.id),
|
|
"name": self.name,
|
|
"label": self.label,
|
|
"extension": self.extension,
|
|
"mimeType": self.mime_type,
|
|
"rawDataLocation": self.raw_data_location,
|
|
"createdAt": self.created_at.isoformat(),
|
|
"updatedAt": self.updated_at.isoformat() if self.updated_at else None,
|
|
"nodeSet": self.node_set,
|
|
# "datasets": [dataset.to_json() for dataset in self.datasets]
|
|
}
|