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
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
from uuid import UUID
|
|
from typing import Optional, List
|
|
from datetime import datetime, timezone
|
|
from cognee.modules.sync.models import SyncOperation, SyncStatus
|
|
from cognee.infrastructure.databases.relational import get_relational_engine
|
|
|
|
|
|
async def create_sync_operation(
|
|
run_id: str,
|
|
dataset_ids: List[UUID],
|
|
dataset_names: List[str],
|
|
user_id: UUID,
|
|
total_records_to_sync: Optional[int] = None,
|
|
total_records_to_download: Optional[int] = None,
|
|
total_records_to_upload: Optional[int] = None,
|
|
) -> SyncOperation:
|
|
"""
|
|
Create a new sync operation record in the database.
|
|
|
|
Args:
|
|
run_id: Unique public identifier for this sync operation
|
|
dataset_ids: List of dataset UUIDs being synced
|
|
dataset_names: List of dataset names being synced
|
|
user_id: UUID of the user who initiated the sync
|
|
total_records_to_sync: Total number of records to sync (if known)
|
|
total_records_to_download: Total number of records to download (if known)
|
|
total_records_to_upload: Total number of records to upload (if known)
|
|
|
|
Returns:
|
|
SyncOperation: The created sync operation record
|
|
"""
|
|
db_engine = get_relational_engine()
|
|
|
|
sync_operation = SyncOperation(
|
|
run_id=run_id,
|
|
dataset_ids=[
|
|
str(uuid) for uuid in dataset_ids
|
|
], # Convert UUIDs to strings for JSON storage
|
|
dataset_names=dataset_names,
|
|
user_id=user_id,
|
|
status=SyncStatus.STARTED,
|
|
total_records_to_sync=total_records_to_sync,
|
|
total_records_to_download=total_records_to_download,
|
|
total_records_to_upload=total_records_to_upload,
|
|
created_at=datetime.now(timezone.utc),
|
|
)
|
|
|
|
async with db_engine.get_async_session() as session:
|
|
session.add(sync_operation)
|
|
await session.commit()
|
|
await session.refresh(sync_operation)
|
|
|
|
return sync_operation
|