Skip to content

Commit

Permalink
Add logging of the full exception in base_writer. (#1069)
Browse files Browse the repository at this point in the history
Without this, tracking down what went wrong is much harder.
  • Loading branch information
eric-anderson authored Dec 9, 2024
1 parent faea58d commit b68a8e3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/sycamore/sycamore/connectors/base_writer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass
import logging

from abc import ABC, abstractmethod
from typing import Callable
Expand All @@ -8,6 +9,8 @@
from sycamore.transforms.map import MapBatch
from sycamore.utils.time_trace import TimeTrace

logger = logging.getLogger(__name__)


class BaseDBWriter(MapBatch, Write):

Expand Down Expand Up @@ -80,6 +83,10 @@ def write_docs(self, docs: list[Document]) -> list[Document]:
records = [self.Record.from_doc(d, created_target_params) for d in docs if self._filter(d)]
client.write_many_records(records, self._target_params)
except Exception as e:
import traceback

tb = traceback.format_exc()
logger.warning(f"Error writing records to target:\n{tb}")
raise ValueError(f"Error writing to target: {e}")
finally:
client.close()
Expand Down

0 comments on commit b68a8e3

Please sign in to comment.