From 7a55526d0a65bcec49ee20ffc18555d82761c812 Mon Sep 17 00:00:00 2001 From: Angus Jelinek Date: Wed, 25 Dec 2024 14:07:48 -0500 Subject: [PATCH 1/2] fix: Flush zstd and correctly get buffer size --- python/langsmith/_internal/_background_thread.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/langsmith/_internal/_background_thread.py b/python/langsmith/_internal/_background_thread.py index ef83ac23f..82c1c35c7 100644 --- a/python/langsmith/_internal/_background_thread.py +++ b/python/langsmith/_internal/_background_thread.py @@ -100,7 +100,8 @@ def _tracing_thread_drain_compressed_buffer( ) -> Optional[io.BytesIO]: assert client.compressed_runs is not None with client.compressed_runs.lock: - current_size = client.compressed_runs.buffer.tell() + client.compressed_runs.compressor_writer.flush() + current_size = client.compressed_runs.buffer.getbuffer().nbytes if size_limit is not None and size_limit <= 0: raise ValueError(f"size_limit must be positive; got {size_limit}") From fbd8c7cc5c18182ff7c74287361c329c408cd36b Mon Sep 17 00:00:00 2001 From: Angus Jelinek Date: Wed, 25 Dec 2024 18:18:34 -0500 Subject: [PATCH 2/2] chore: use tell() instead of getbuffer() --- python/langsmith/_internal/_background_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/langsmith/_internal/_background_thread.py b/python/langsmith/_internal/_background_thread.py index 82c1c35c7..6647e87c9 100644 --- a/python/langsmith/_internal/_background_thread.py +++ b/python/langsmith/_internal/_background_thread.py @@ -101,7 +101,7 @@ def _tracing_thread_drain_compressed_buffer( assert client.compressed_runs is not None with client.compressed_runs.lock: client.compressed_runs.compressor_writer.flush() - current_size = client.compressed_runs.buffer.getbuffer().nbytes + current_size = client.compressed_runs.buffer.tell() if size_limit is not None and size_limit <= 0: raise ValueError(f"size_limit must be positive; got {size_limit}")