From 965f9e98bf73ab3c30c67a84061f7f84f3837085 Mon Sep 17 00:00:00 2001 From: Chris Weaver <25087905+Weves@users.noreply.github.com> Date: Mon, 10 Mar 2025 08:50:50 -0700 Subject: [PATCH] Eliminate extremely long log line for large checkpointds (#4236) * Eliminate extremely long log line for large checkpointds * address greptile --- backend/onyx/connectors/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/onyx/connectors/models.py b/backend/onyx/connectors/models.py index 6211970f7..6c5ba7691 100644 --- a/backend/onyx/connectors/models.py +++ b/backend/onyx/connectors/models.py @@ -1,3 +1,4 @@ +import json from datetime import datetime from enum import Enum from typing import Any @@ -204,6 +205,15 @@ class ConnectorCheckpoint(BaseModel): def build_dummy_checkpoint(cls) -> "ConnectorCheckpoint": return ConnectorCheckpoint(checkpoint_content={}, has_more=True) + def __str__(self) -> str: + """String representation of the checkpoint, with truncation for large checkpoint content.""" + MAX_CHECKPOINT_CONTENT_CHARS = 1000 + + content_str = json.dumps(self.checkpoint_content) + if len(content_str) > MAX_CHECKPOINT_CONTENT_CHARS: + content_str = content_str[: MAX_CHECKPOINT_CONTENT_CHARS - 3] + "..." + return f"ConnectorCheckpoint(checkpoint_content={content_str}, has_more={self.has_more})" + class DocumentFailure(BaseModel): document_id: str